What is GraphQL?
GraphQL is a query language for APIs that allows clients to request exactly the data they need. Unlike REST APIs with fixed endpoints, GraphQL enables:- Precise queries - Request only the fields you need
- Nested data - Fetch related data in a single query
- Type safety - Strongly typed schema with introspection
- Single endpoint - All queries go through one endpoint
API Endpoints
Mainnet
Testnet
Local Node
Architecture
The GraphQL server architecture:- Query - Read operations for fetching blockchain data
- Mutation - Write operations for executing transactions
Making Requests
GraphQL requests can be sent via HTTP POST:Interactive IDE
Access the GraphiQL IDE athttps://api.iota.io/graphql in your browser to:
- Write and test queries interactively
- Explore the schema with auto-complete
- View documentation for all types and fields
- See query results in real-time
Basic Query Example
Fetch the chain identifier:Query Features
Field Selection
Request only the fields you need:Nested Queries
Fetch related data in one request:Pagination
Many queries support cursor-based pagination:Schema Organization
The GraphQL schema is organized around these main types:Core Types
- Address - Account addresses and their data
- Object - On-chain objects (coins, packages, etc.)
- TransactionBlock - Transaction blocks and their effects
- Checkpoint - Checkpoints containing finalized transactions
- Epoch - Epoch information and statistics
Query Entry Points
object(address: "...")- Query a specific objectaddress(address: "...")- Query an addresstransactionBlock(digest: "...")- Query a transactioncheckpoint(sequenceNumber: ...)- Query a checkpointepoch(id: ...)- Query an epoch
Connections
Many fields return “Connection” types for paginated results:nodes- Array of itemsedges- Array of edges with cursorspageInfo- Pagination metadata
API Comparison
GraphQL vs JSON-RPC
| Feature | GraphQL | JSON-RPC |
|---|---|---|
| Data Fetching | Request specific fields | Fixed response structure |
| Multiple Resources | Single query | Multiple RPC calls |
| Type Safety | Built-in schema | Manual validation |
| Learning Curve | Medium | Low |
| Flexibility | High | Medium |
When to Use GraphQL
Use GraphQL when you need:- Complex nested data in a single query
- Precise control over returned fields
- Reduced over-fetching of data
- Interactive development with GraphiQL
- Strong typing and schema introspection
When to Use JSON-RPC
Use JSON-RPC when you need:- Simple, straightforward queries
- Compatibility with existing tools
- Lower learning curve
- Direct method-based API calls
Rate Limits
The GraphQL API enforces limits:- Max query depth - 15 levels
- Max query nodes - 500 per query
- Max output nodes - 100,000 per response
- Query timeout - 15 seconds
- Max page size - Varies by query type
GraphQL Categories
Queries
Read blockchain data with flexible GraphQL queries
Mutations
Execute transactions through GraphQL mutations
Examples
Common query patterns and use cases