Queries
Historical Data and Arguments
Learn how to query historical metric data using date filters and intervals.
Historical Data and Arguments
For historical data, the createdAt_gt filter is needed. Without it, you only get the latest value. The required date format is YYYY-MM-DD.
Query 1: Reward Rate History
Retrieve historical reward rate data for Ethereum:
{
rewardOptions(where: {inputAsset: {symbols: ["ETH"]}, typeKeys: ["solo-staking", "pos"]}, limit: 10) {
metrics(where: { metricKeys: ["reward_rate"], createdAt_lt:"2023-01-01"}, limit: 10) {
metricKey
defaultValue
changePercentages
createdAt
}
}
}Query 2: Daily Interval Data
Query daily historical data for ETH reward rates starting from a specific date:
{
rewardOptions(where: {inputAsset: {symbols: ["ETH"]}}, limit: 1) {
metrics(where: { metricKeys: ["reward_rate"], createdAt_gt:"2023-01-01"}, interval: day, limit: 500) {
metricKey
defaultValue
changePercentages
createdAt
}
}
}Query 3: Weekly Asset Metrics
Query weekly price metrics for an asset between specific dates:
{
assets(where: {ids: ["60a27c3d4d60300008d25ecf"]}, limit: 1){
slug
metrics(limit:500, where:{metricKeys: ["price"], createdAt_gt: "2023-01-01", createdAt_lt: "2023-09-07"}, order: {createdAt: desc}, interval: week, pickItem: last) {
metricKey
defaultValue
createdAt
}
}
}Technical Limitations
- Interval queries work only for single resources
- Results are capped at 500 data points globally
- Supported intervals:
hour,day,week,month,quarter
Using Arguments
You can use GraphQL variables to parameterize your queries:
Arguments:
{
"slugs": ["ethereum-2-0"],
"limit": 100,
"offset": 0,
"metricKeys": ["reward_rate"],
"timeStart": "2023-01-01"
}Query:
query getHistoricalMetrics($slugs: [String!], $limit: Int, $offset: Int, $metricKeys: [String!], $timeStart: Date) {
assets(where: {slugs: $slugs}, limit: 1) {
metrics(where: {metricKeys: $metricKeys, createdAt_gt: $timeStart}, limit: $limit, offset: $offset, order: {createdAt: asc}) {
defaultValue
createdAt
id
}
}
}Date Filters
| Filter | Description |
|---|---|
createdAt_gt | Greater than (after) the specified date |
createdAt_lt | Less than (before) the specified date |
createdAt_gte | Greater than or equal to the specified date |
createdAt_lte | Less than or equal to the specified date |
Interval Options
| Interval | Description |
|---|---|
hour | Hourly data points |
day | Daily data points |
week | Weekly data points |
month | Monthly data points |
quarter | Quarterly data points |