Retrieve Charts
Charts are generated as a side effect of Chat with Data completions. This guide covers how to list, fetch, and work with charts programmatically.
List Charts
curl -s "$LHC_ANALYTICS/api/v1/analytics/charts" \
-H "Authorization: Bearer $LHC_TOKEN"
charts = requests.get(
f"{ANALYTICS}/api/v1/analytics/charts",
headers=HEADERS,
).json()
for c in charts:
print(c["id"], c["title"], c["chart_type"])
The response is a list of chart objects. Each chart includes its title, chart type, the query that generated it, and a reference to the underlying data.
Get a Specific Chart
If you have a chart_id from a completion response, fetch it directly:
curl -s "$LHC_ANALYTICS/api/v1/analytics/charts/id/<chart-id>" \
-H "Authorization: Bearer $LHC_TOKEN"
chart_id = "<chart-id>"
chart = requests.get(
f"{ANALYTICS}/api/v1/analytics/charts/id/{chart_id}",
headers=HEADERS,
).json()
print(chart["title"])
print(chart["chart_type"]) # bar, line, pie, table, ...
print(chart["meta"]) # axis config, labels, color scheme
Filter Charts by Model
To retrieve only the charts associated with a specific Custom Model:
charts = requests.get(
f"{ANALYTICS}/api/v1/analytics/charts",
headers=HEADERS,
params={"model_id": "<model-id>"},
).json()
Search Charts
curl -s "$LHC_ANALYTICS/api/v1/analytics/charts?query=revenue" \
-H "Authorization: Bearer $LHC_TOKEN"
results = requests.get(
f"{ANALYTICS}/api/v1/analytics/charts",
headers=HEADERS,
params={"query": "revenue"},
).json()
Chart Object Structure
A chart response includes:
| Field | Description |
|---|---|
id | Unique chart identifier |
title | Human-readable title generated by the AI |
chart_type | Visualization type (bar, line, pie, scatter, table, etc.) |
meta | Axis configuration, labels, and display options |
model_id | The Custom Model that generated the chart |
created_at | Timestamp of creation |
is_approved | Whether the chart has been approved by a Builder or Admin |
Embed Charts
Charts can be shared and embedded. See the Sharing guide for share link and embed token workflows.