The Graph (Subgraph) API logo

The Graph (Subgraph) API

The Graph (Subgraph) API

正常免费developer-tools

The Graph 是 Web3 数据索引去中心化网络:用 GraphQL 查询区块链数据,由 subgraph 开发者部署各种数据 schema。

访问站点 ↗文档 ↗健康巡检 9 小时前
适合什么时候用

去中心化(不依赖单一服务商)

先注意什么

学习曲线陡(要懂 subgraph manifest + AssemblyScript handlers)

第一步先查

thegraph.com/studio 创建 API key。POST GraphQL query 到 https://gateway-arbitrum.network.thegraph.com/api/{API_KEY}/subgraphs/id/{SUBGRAPH_ID}

认证
api_key
CORS
?
HTTPS
注册
?
延迟
143 ms
协议
GraphQL
计费
freemium

可用率 · 30 天窗口

巡检: 1可用率: 100%平均延迟: 143ms
01

关于这个 API

The Graph 是 Web3 的「Google Indexing」——把链上交易、合约 event 等原始数据 indexing 成可用 GraphQL 查询的 schema(subgraph)。背景:用普通 Ethereum RPC 查询「Uniswap 过去 30 天每个池的 swap 总量」要扫几百万 event,慢且贵;如果有 Uniswap 官方 subgraph,一个 GraphQL 查询就出结果。所有主流 DeFi 协议(Uniswap、Aave、Compound、Curve、Sushi 等)都有官方 subgraph,NFT 集合也有第三方 subgraph。The Graph 网络是去中心化的——subgraph 由社区 indexer 节点托管,开发者用 GRT 代币付费查询。免费 tier 100k queries/月对小项目够。Hosted Service(中心化版本)2024 年 deprecate,必须用 Decentralized Network。

02

你可以做什么

  • 1DeFi 协议数据 dashboard
  • 2NFT 集合分析
  • 3去中心化 DApp 后端
  • 4Web3 数据 indexing 不重复造轮子
03

优劣对比

优点

  • 去中心化(不依赖单一服务商)
  • GraphQL 查询比 RPC 灵活
  • subgraph 生态丰富(Uniswap、Aave、Compound 等都有官方 subgraph)

注意事项

  • 学习曲线陡(要懂 subgraph manifest + AssemblyScript handlers)
  • Hosted Service 已 deprecate,必须用 Decentralized Network
  • 一些 subgraph indexing 慢
04

示例请求

通用模板 — 实际 endpoint 请查阅文档替换 <endpoint>。
curl https://thegraph.com/<endpoint> \
  -H "Authorization: Bearer $API_KEY"
# Some providers use X-Api-Key instead — verify in the docs.
05

快速开始

thegraph.com/studio 创建 API key。POST GraphQL query 到 https://gateway-arbitrum.network.thegraph.com/api/{API_KEY}/subgraphs/id/{SUBGRAPH_ID}

06

常见问题

subgraph 没现成的怎么办?+

自己写 + 部署。学习曲线陡(要懂 subgraph manifest + handlers)但有官方教程。

GRT 代币怎么用?+

通过 Studio/Gateway 付费。10 美元 GRT 通常对应几十万次查询。

07

技术细节

CORS: ?HTTPS: Yes注册: ?开源: No
认证方式
api_key
计费
freemium
速率限制
free 100k queries/月;超额按 GRT 代币计费
协议
GraphQL
SDK
javascript, typescript, python
响应时间
143 ms
上次巡检
2026/5/12 07:38:29
08

标签