Sui JSON-RPC vs GraphQL: Which One Should Builders Use?

Use JSON-RPC for tx submission and authoritative reads; use GraphQL/indexers for rich queries and UI history. Clean split + examples + gotchas.

Sui JSON-RPC vs GraphQL: Which One Should Builders Use? — Natsai

TL;DR - JSON-RPC is for tx submission and chain-adjacent reads; GraphQL is for efficient queries, history, and UI data access. - If your UI feels slow, you’re probably using JSON-RPC for queries it was never meant to serve. - For production: cache reads, paginate everything, and treat RPC like a paid dependency.

If your Sui integration feels slow or fragile, you may be using the wrong interface for the job.

Related: - Sui SIP-45 / local fee markets - Seal in 60 seconds


Use JSON-RPC for these

  • submit transactions
  • fetch object state when correctness matters
  • simulate/dry-run transactions (when supported)
  • low-level chain reads that must be authoritative

Why: it’s closer to the fullnode “authoritative view” for those actions.


Use GraphQL for these

  • “show me my last 200 transactions”
  • query objects by owner/type with pagination
  • analytics dashboards and explorer-like experiences
  • complex filtering/sorting

Why: GraphQL/indexer services are built for querying; chains are not.


1) UI reads list/history from GraphQL 2) When user clicks something important, fetch authoritative object state from JSON-RPC 3) Submit tx via JSON-RPC 4) UI updates via GraphQL queries (or streaming if you run it)

This gives you: - faster UI - fewer RPC bottlenecks - fewer “why is this query expensive?” incidents


Quickstart

A) JSON-RPC call (template)

~~bash curl -s\ -H "content-type: application/json" \ --data '{"jsonrpc":"2.0","id":1,"method":"suix_getLatestCheckpointSequenceNumber","params":[]}' ~~

B) GraphQL query (template)

~~bash curl -s\ -H "content-type: application/json" \ --data '{"query":"query { chainIdentifier }"}' ~~

Tip: start by getting one endpoint working reliably, then add caching/pagination.

Common errors

  • Using JSON-RPC to build “explorer-style” history pages (slow, heavy, rate-limited).
  • No pagination on GraphQL queries (you DDoS yourself with large result sets).
  • Treating public endpoints as production infrastructure.
  • Not caching “read-heavy” UI queries (wallet pages, portfolios, inventory lists).

FAQ

Which should I use for a new project?

Prefer GraphQL for most reads and UI queries; use JSON-RPC where you must submit txs or do authoritative checks.

Is JSON-RPC going away on Sui?

Sui’s data-serving roadmap emphasizes GraphQL/gRPC as primary interfaces; plan migrations accordingly.

Can I run my own indexer?

Yes, but it’s an ops commitment. Most teams start with managed GraphQL, then graduate to custom indexing when needed.



References