Polymarket's on-chain data can be efficiently queried using GraphQL via Subgraphs on The Graph Network. Subgraphs serve as decentralized APIs powered by The Graph, a protocol designed for indexing and querying blockchain data.
Exploring the Polymarket Subgraph
Accessing the Graph Explorer
The Polymarket Subgraph provides an interactive playground where you can test queries in real time.
👉 Try the Polymarket Subgraph Playground
Using the Visual Query Editor
The GraphiQL Explorer simplifies query composition by allowing you to select fields interactively.
Example Query: Top 5 Highest Payouts
{
redemptions(
orderBy: payout,
orderDirection: desc,
first: 5
) {
payout
redeemer
id
timestamp
}
}Sample Output
{
"data": {
"redemptions": [
{
"id": "0x8fbb68b7c0cbe9aca6024d063a23d046b5522270fd25c6a81c511cf517d1_0x3b",
"payout": "6274509531681",
"redeemer": "0xfffe4013adfe325c6e02d36dc66e091f5476f52c",
"timestamp": "1722929672"
},
{
"id": "0x2b2826448fcacde7931828cfcd3cc4aaeac8080fdff1e91363f0589c9b503eca_0x7",
"payout": "2246253575996",
"redeemer": "0xfffe4013adfe325c6e02d36dc66e091f5476f52c",
"timestamp": "1726701528"
}
]
}
}Polymarket’s GraphQL Schema
The schema is defined in Polymarket’s GitHub repository.
Subgraph Endpoint
https://gateway.thegraph.com/api/{api-key}/subgraphs/id/Bx1W4S7kDVxs9gC3s2G6DS8kdNBJNVhMviCtin2DiBpAccessible via Graph Explorer.
Obtaining an API Key
- Visit The Graph Studio and connect your wallet.
- Generate an API key here.
- Use the key across any Subgraph in Graph Explorer.
👉 Start with 100k free monthly queries
Additional Polymarket Subgraphs
- Polymarket (Arbitrum)
- Polymarket Activity (Polygon)
- Polymarket Profit & Loss
- Polymarket Open Interest
Querying via API
Submit GraphQL queries to the endpoint to receive JSON responses.
Node.js Example
const axios = require('axios');
const query = `{ positions(first: 5) { condition outcomeIndex } }`;
const endpoint = 'https://gateway.thegraph.com/api/{api-key}/subgraphs/id/Bx1W4S7kDVxs9gC3s2G6DS8kdNBJNVhMviCtin2DiBp';
axios.post(endpoint, { query })
.then(response => console.log(response.data.data))
.catch(error => console.error(error));FAQ
What is a Subgraph?
A Subgraph is a decentralized API that indexes blockchain data for efficient querying via GraphQL.
How do I test queries without coding?
Use the GraphiQL Playground on Graph Explorer.
Are there rate limits?
Free tiers allow 100k queries/month; paid plans offer higher limits.
Can I create my own Subgraph?
Yes! Follow The Graph’s documentation to deploy custom Subgraphs.
For advanced optimizations, explore Subgraph querying best practices.