@mysten/sui v2.0 and a new dApp Kit are here! Check out the migration guide
Mysten Labs SDKs
Clients

Sui Clients

The Sui TypeScript SDK provides multiple client implementations for interacting with the Sui network. Each client connects to a different API but provides two levels of access:

  • Native API - Full access to everything the underlying API offers
  • Core API - A consistent interface across all clients for common operations

Available Clients

All clients are compatible with Mysten SDKs like @mysten/walrus, @mysten/seal and @mysten/suins.

For most application gRPC is a good default. The JSON RPC API has been deprecated and will be decommissioned soon. The GraphQL can be used for more advanced query patterns that can not be supported directly on full nodes (eg, querying for transactions or events with various filters).

Quick Start

import { SuiGrpcClient } from '@mysten/sui/grpc';

const client = new SuiGrpcClient({
	network: 'mainnet',
	baseUrl: 'https://fullnode.mainnet.sui.io:443',
});

// Use the native API for full access to transport-specific features
const { response } = await client.ledgerService.getTransaction({ digest: '0x...' });

// Use the Core API for transport-agnostic operations
const { object } = await client.core.getObject({ objectId: '0x...' });

Native vs Core API

Native API

Each client exposes the full capabilities of its underlying transport. Use the native API when you need transport-specific features or want maximum control:

import { SuiGrpcClient } from '@mysten/sui/grpc';
import { SuiGraphQLClient } from '@mysten/sui/graphql';
import { graphql } from '@mysten/sui/graphql/schema';
import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';

// gRPC - access various service clients to call any gRPC method
const { response } = await grpcClient.stateService.listOwnedObjects({ owner: '0x...' });

// GraphQL - write type-safe custom queries using the graphql function
const result = await graphqlClient.query({
	query: graphql(`
		query {
			chainIdentifier
		}
	`),
});

// JSON-RPC - call any JSON-RPC method
const coins = await jsonRpcClient.getCoins({ owner: '0x...' });

Core API

All clients also implement the Core API through client.core. This provides a consistent interface for common operations that works identically across all transports:

// These methods work the same on any client
const { object } = await client.core.getObject({ objectId: '0x...' });
const balance = await client.core.getBalance({ owner: '0x...' });
await client.core.executeTransaction({ transaction, signatures });

The Core API is essential for building SDKs that work with any client the user chooses.

Client Extensions

All clients support extensions through the $extend method, enabling SDKs like @mysten/walrus to add functionality:

import { walrus } from '@mysten/walrus';

const client = new SuiGrpcClient({ network: 'mainnet', baseUrl: '...' }).$extend(walrus());

await client.walrus.writeBlob({ ... });

See Building SDKs for more on creating client extensions.

On this page