Sui GraphQL API

Using a Shared GraphQL Endpoint for Sui Node.

General GraphQL Capability

GraphQL RPC is an efficient data access interface provided by the Sui network, featuring the following characteristics:

  • Supports flexible query structures to minimize redundant data transfer.
  • Provides real-time access to network status (sui-mainnet / sui-testnet).
  • Employs pagination mechanisms to handle large dataset queries.

Support areas

  • supported networks:sui-mainnet,sui-testnet
  • supported methods:

Integration Method

Integration Example Guide

  • Query current epoch

  • curl -X POST https://api.zan.top/node/v1/sui/mainnet/{apiKey}/graphql \
        --header 'Content-Type: application/json' \
        --data '{
          "query": "query ($epochID: Int) { epoch(epochId: $epochID) { referenceGasPrice } }",
          "variables": { "epochID": 988 }
      }'
  • Query Address Information

    curl -X POST https://api.zan.top/node/v1/sui/mainnet/{apiKey}/graphql \
        --header 'Content-Type: application/json' \
        --data '{
          "query": "query AddressQuery{\n  address (address: \"0x5094652429957619e6efa79a404a6714d1126e63f551f4b6c7fb76440f8118c9\") {\n    address\n  }\n}"
      }'

SDK Examples

Refer to SuiGraphQLClient

import { SuiGraphQLClient } from '@mysten/sui/graphql';
import { graphql } from '@mysten/sui/graphql/schemas/latest';

const gqlClient = new SuiGraphQLClient({
	url: 'https://api.zan.top/node/v1/sui/mainnet/{apiKey}/graphql',
});

const chainIdentifierQuery = graphql(`
	query {
		chainIdentifier
	}
`);

async function getChainIdentifier() {
	const result = await gqlClient.query({
		query: chainIdentifierQuery,
	});

	return result.data?.chainIdentifier;
}