Comment on page
Query the subgraph
Queries on a Graph QL endpoint are written in a JSON with exact content of your query. You can query any of the entities defined in the previous section.
If you want to access the API point without coding, you can use Hasura GraphQL API Explorer using the API link directly (include your personnal API key in the link) :
https://gateway.thegraph.com/api/[your-graph-api-key]/subgraphs/id/78kqSQgaXhtfypzCE1uoB6tTCdgynowp5574ADL6RQrS
Below is an example of a query fetching from the markets entity :
Simple query
Time travel query
query MyQuery {
markets {
id
cash
reserveFactor
symbol
name
}
}
Time-travel queries allow you to retrieve the state of the blockchain as it was at a specific block (snapshot). To use time-travel queries, use the "block" argument :
query MyQuery {
markets (block: {number: 14000000}) {
id
cash
reserveFactor
symbol
name
}
}
To retrieve time series , you can optimize you GraphQL client to bundle a series of the same query above with a different block argument on each one, to retrieve time series data of the markets entity, as in the example below :
query MyQuery {
markets (block: {number: 14000000}) {
id
cash
reserveFactor
symbol
name
}
markets (block: {number: 14001000}) {
id
cash
reserveFactor
symbol
name
}
markets (block: {number: 14002000}) {
id
cash
reserveFactor
symbol
name
}
...
}
The results will be returned as a JSON file as follows :
{
"data": {
"markets": [
{
{
"id": "0x1429a930ec3bcf5aa32ef298ccc5ab09836ef587",
"cash": "0",
"reserveFactor": "0",
"symbol": "anYvCrv3Crypto",
"name": "Inverse Finance: yvCrv3Crypto"
},
{
"id": "0x1637e4e9941d55703a7a5e7807d6ada3f7dcd61b",
"cash": "71078.967383538543557839",
"reserveFactor": "0",
"symbol": "XINV",
"name": "xINV"
}
...
]
}
}
Last modified 1yr ago