Get Chart JSON
Retrieve chart data in structured JSON format for use with charting libraries.
Query Structureβ
query GetChartJson($input: GetChartJsonInput!) {
getChartJson(input: $input) {
term_id
curve_id
graph_type
interval
count
data {
timestamp
value
}
}
}
Variablesβ
The query takes a single input object of type GetChartJsonInput:
| Field | Type | Required | Description |
|---|---|---|---|
term_id | String | Yes | Term ID to generate chart for |
curve_id | String | Yes | Curve ID (bonding curve) |
interval | String | Yes | Time interval (e.g. "1h", "1d", "1w") |
start_time | String | Yes | Start of time range (ISO 8601) |
end_time | String | Yes | End of time range (ISO 8601) |
graph_type | String | No | Type of graph data |
{
"input": {
"term_id": "0x57d94c116a33bb460428eced262b7ae2ec6f865e7aceef6357cec3d034e8ea21",
"curve_id": "1",
"interval": "1d",
"start_time": "2024-01-01T00:00:00Z",
"end_time": "2024-01-31T23:59:59Z"
}
}
Response Fields (ChartDataOutput)β
| Field | Type | Description |
|---|---|---|
term_id | String! | Term ID for this chart |
curve_id | String | Curve ID used |
graph_type | String! | Type of graph |
interval | String! | Interval used for aggregation |
count | Int! | Number of data points |
data | [ChartDataPoint!]! | Array of chart data points |
data[].timestamp | String! | ISO 8601 timestamp for this data point |
data[].value | String! | Value at this timestamp |
Interactive Exampleβ
Query
query GetChartJson($input: GetChartJsonInput!) {
getChartJson(input: $input) {
term_id
curve_id
graph_type
interval
count
data {
timestamp
value
}
}
}Variables
Click "Run Query" to execute the GraphQL query and see results
Use Casesβ
Recharts Integrationβ
import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'
const client = new GraphQLClient(API_URL_PROD)
async function getChartData(termId: string, curveId: string, days: number = 30) {
const endTime = new Date()
const startTime = new Date()
startTime.setDate(startTime.getDate() - days)
const query = `
query GetChartJson($input: GetChartJsonInput!) {
getChartJson(input: $input) {
count
data
interval
}
}
`
const result = await client.request(query, {
input: {
term_id: termId,
curve_id: curveId,
interval: '1d',
start_time: startTime.toISOString(),
end_time: endTime.toISOString()
}
})
return result.getChartJson
}
Relatedβ
- Chart Raw JSON - Raw JSON format (same input/output types)
- Chart SVG - Pre-rendered SVG charts