Skip to main content
Sui’s GraphQL API provides a flexible, efficient way to query blockchain data. It offers a modern alternative to JSON-RPC with powerful filtering, pagination, and field selection.

GraphQL Endpoint

Mainnet:
Testnet:
Devnet:

Why GraphQL?

GraphQL offers several advantages over REST/JSON-RPC:
  • Precise Queries: Request exactly the fields you need
  • Single Request: Fetch related data in one query
  • Strongly Typed: Schema-based with built-in validation
  • Powerful Filtering: Rich query capabilities
  • Nested Queries: Retrieve related objects in a single request
  • Real-time Updates: Subscriptions for live data

Quick Start

HTTP Request

JavaScript Client

TypeScript SDK

Schema Exploration

Use GraphQL introspection to explore the schema:
Or use GraphQL Playground:
  • Navigate to the GraphQL endpoint in your browser
  • Explore the schema in the “Docs” panel
  • Test queries interactively

Common Queries

Get Chain Information

Get Current Epoch

Get Object by ID

Variables:

Get Owned Objects

Get Transaction Block

Query Events

Variables:

Get Balance

Pagination

GraphQL uses cursor-based pagination:
To get the next page, use the endCursor as the after parameter:

Nested Queries

Fetch related data in a single query:

Filtering

Use filters to narrow results:

Error Handling

GraphQL returns errors in a standardized format:

Rate Limits

The public GraphQL endpoint has rate limits:
  • Query Depth: Maximum 15 levels deep
  • Query Nodes: Maximum 500 nodes per query
  • Request Timeout: 30 seconds
  • Rate Limit: Subject to fair use policies
For production use:
  • Run your own indexer with GraphQL
  • Use a managed RPC provider
  • Implement caching and batching

Next Steps