
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
@aptos-labs/aptos-client
Advanced tools
HTTP client for the Aptos network API. Works standalone or as the transport layer for the Aptos TypeScript SDK.
bcsRequest() returns raw ArrayBuffer for binary-encoded responsesnpm install @aptos-labs/aptos-client
# or
pnpm add @aptos-labs/aptos-client
undici is an optional peer dependency — only needed in Node.js:
npm install undici
import aptosClient from "@aptos-labs/aptos-client";
const { status, data } = await aptosClient<{ chain_id: number }>({
url: "https://fullnode.mainnet.aptoslabs.com/v1",
method: "GET",
});
import { jsonRequest, bcsRequest } from "@aptos-labs/aptos-client";
// JSON (same as default export)
const json = await jsonRequest<MyType>({ url, method: "GET" });
// BCS (returns ArrayBuffer)
const bcs = await bcsRequest({ url, method: "GET" });
The package uses conditional exports to select the right implementation for each runtime:
| Condition | Entry point | HTTP/2 | Notes |
|---|---|---|---|
node | index.node.ts | Configurable via http2 option (default true) | Uses undici Agent({ allowH2 }) |
browser | index.browser.ts | Automatic (browser engine) | Delegates cookies to the browser |
react-native | index.fetch.ts | Automatic (OkHttp / NSURLSession) | Platform negotiates HTTP/2 via ALPN |
deno | index.fetch.ts | Automatic | — |
bun | index.fetch.ts | Automatic | — |
default | index.fetch.ts | Depends on runtime | Fallback for unknown runtimes |
type AptosClientRequest = {
url: string;
method: "GET" | "POST";
body?: unknown;
params?: Record<string, string | number | bigint | boolean | undefined>;
headers?: Record<string, string | undefined>;
overrides?: { WITH_CREDENTIALS?: boolean };
http2?: boolean; // Node only — ignored elsewhere
cookieJar?: CookieJarLike; // Per-request cookie isolation (Node & fetch only)
};
type AptosClientResponse<Res> = {
status: number;
statusText: string;
data: Res;
config?: any;
request?: any;
response?: any;
headers?: any;
};
See
src/types.tsfor the full type definitions with documentation.
| Runtime | How it works |
|---|---|
| Node.js | undici negotiates HTTP/2 via ALPN when http2: true (the default). Set http2: false to force HTTP/1.1. |
| Browser | The browser engine negotiates HTTP/2 with the server automatically. The http2 option is ignored. |
| React Native | OkHttp (Android) and NSURLSession (iOS) negotiate HTTP/2 via ALPN automatically. The http2 option is ignored. |
| Deno / Bun | The runtime negotiates HTTP/2 automatically. The http2 option is ignored. |
Releases are published to npm automatically via GitHub Actions whenever a GitHub release is created. The workflow lives in .github/workflows/publish.yml.
To release a new version:
Update the version in package.json (follows semver):
npm version <major|minor|patch> --no-git-tag-version
Update CHANGELOG.md — move any notes under # Unreleased into a new section for the version being released.
Commit and push the version bump and changelog update to main:
git add package.json CHANGELOG.md
git commit -m "v<VERSION>"
git push
Create a GitHub release with a tag that matches vMAJOR.MINOR.PATCH (e.g. v2.3.0). The tag must match the version in package.json — the publish workflow will fail otherwise. Pre-release tags like v2.3.0-beta.1 are also supported.
The publish workflow will then automatically:
vMAJOR.MINOR.PATCH[-prerelease] pattern.version field in package.json.FAQs
Client package for accessing the Aptos network API.
The npm package @aptos-labs/aptos-client receives a total of 104,512 weekly downloads. As such, @aptos-labs/aptos-client popularity was classified as popular.
We found that @aptos-labs/aptos-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.