Package detail

@aptos-labs/aptos-client

aptos-labs495.6kApache-2.02.0.0

Client package for accessing the Aptos network API.

Aptos, Aptos Labs, Aptos SDK

readme

License NPM Package Version Node Version NPM bundle size NPM Package Downloads

@aptos-labs/aptos-client

This package implements a client with which you can interact with the Aptos network. It can be used standalone, and it is the client package used by the Aptos TypeScript SDK.

Implementation

The @aptos-labs/aptos-client package supports http2 protocol and implements 2 clients environment based:

  1. fetch - implemented in index.browser.ts to use in browser environment (in a browser env it is up to the browser and the server to negotiate http2 connection)
  2. got - implemented in index.node.ts to use in node environment (to support http2 in node environment, still the server must support http2 also)

Function signature

async function aptosClient<Res>(
  requestOptions: AptosClientRequest,
): Promise<AptosClientResponse<Res>>;

Types

type AptosClientResponse<Res> = {
  status: number;
  statusText: string;
  data: Res;
  config?: any;
  request?: any;
  response?: any;
  headers?: any;
};

type AptosClientRequest = {
  url: string;
  method: "GET" | "POST";
  body?: any;
  params?: any;
  headers?: any;
  overrides?: any;
};

Usage

import aptosClient from "@aptos-labs/aptos-client";

const response = await aptosClient<Res>({
  url,
  method,
  body,
  params,
  headers,
  overrides,
});
return response;

changelog

Aptos Client Changelog

All notable changes to the Aptos client will be captured in this file. This changelog is written by hand for now. It adheres to the format set out by Keep a Changelog.

Unreleased

2.0.0

  • Remove axios from browser implementation in favor of native fetch
  • Remove support for Node.js versions earlier than 20.x.x
  • Upgraded pnpm version to 10.10.0

1.2.0

  • Bump axios to >=1.8.4
  • Upgrade dev dependencies
  • Format code

1.1.0

  • Bump axios to 1.8.0

1.0.0

  • Add experimental support for binary client calls

0.2.0

  • Update dependencies to latest versions, move them to peer dependencies

0.1.1

0.1.0

  • Update to Axios v1.6.2, and other dev dependencies