Back to Common Questions

Subgraph vs API — which should you use?

Updated August 2026

Use a hosted data API when the data you need is standard — token balances, transfers, NFT ownership — and you want it working today. Use a subgraph when you need custom logic over specific contracts and want to control the schema.

The decision comes down to whether someone else has already modelled your data correctly.

How do they compare?

Hosted data APISubgraph
Time to first resultMinutesHours to days, plus sync
Custom logicNoYes
Schema controlVendor'sYours
Query interfaceREST or GraphQL, fixedGraphQL, your schema
Cost modelPer requestIndexing plus queries
PortabilityVendor-specificOpen specification
SuitsStandard data, fast startProtocol-specific data

When is a hosted API the better choice?

When your requirements match what the vendor already provides. Wallet balances, token metadata, NFT ownership, transaction history for an address — these are solved problems, and rebuilding them yourself is rarely a good use of time.

The constraint is that you get the vendor's data model. If you need something they did not anticipate — a specific event from your own contract, an aggregate they do not compute, a field they do not expose — you cannot add it. You can only ask them to.

When do you need a subgraph?

When you are indexing your own protocol, or anything where the interesting data is contract-specific.

A subgraph lets you define exactly which events to handle, what to compute from them, and what shape the result takes. If your application needs "total volume per pool per day, with fees split by tier," no general-purpose API will have that — but a subgraph can produce it directly.

You also get a portable definition. Subgraphs follow an open specification rather than a proprietary API surface.

What's the catch with subgraphs?

Sync time. Subgraphs process history sequentially, so a subgraph over a contract with years of activity can take a long time to sync — and every schema change starts that process again. This is the most common complaint, and it has a dedicated answer.

Development effort. You define the schema, write the mappings, and handle deployment.


Frequently asked questions

Can I use both? Commonly, yes — a hosted API for standard data and a subgraph for protocol-specific logic.

Do subgraphs only work on Ethereum? No, they support a range of networks, though the ecosystem is EVM-centric.

What if my subgraph is too slow to sync? See why is my subgraph syncing so slow?


Get an API key at thegraph.market — no personal information required.

Related: Why is my subgraph syncing so slow? · What is blockchain indexing?