Skip to main content
Renders the indicator’s data as a chart and returns a binary PNG image. All chart configuration — type, theme, colors, granularity, and size — is provided in the request body.
Chart rendering uses Plotly with Kaleido and runs synchronously. For large datasets or complex charts, the request may take several seconds to complete. File cleanup is handled in a background task after the response is sent.

Path parameters

indicator_id
string
required
The indicator’s unique identifier. Must be a valid MongoDB ObjectId (24-character hex string).

Request body

Data parameters

granularity
string
default:"0"
Aggregation time window for the chart data. Same values as the data points endpoint: "0" (no aggregation), "1s", "5m", "1h", "1d", "1w", "1M", "1y".
start_date
string
Start of the date range to display. ISO 8601 format (e.g., "2024-01-01T00:00:00Z").
end_date
string
End of the date range to display. ISO 8601 format (e.g., "2024-12-31T23:59:59Z").
series
array
Optional pre-fetched series data. When omitted, data is fetched directly from the database.

Chart configuration

chart_type
string
default:"line"
Chart rendering style. Accepted values:
ValueDescription
lineLine chart
areaArea chart (filled)
barBar chart
columnColumn chart
scatterScatter plot
xaxis_type
string
default:"datetime"
Determines how x-axis values are interpreted and formatted.
ValueDescription
datetimeParse x values as ISO 8601 datetimes
categoryTreat x values as discrete categories
numericTreat x values as continuous numbers
title
string
default:""
Title text displayed above the chart.
show_legend
boolean
default:"true"
Whether to render the chart legend.
logarithmic
integer
When set, applies a logarithmic scale to the y-axis. Pass an integer representing the log base.

Visual styling

theme
string
default:"light"
Chart color theme. "light" or "dark".
colors
string[]
Custom color palette as an array of CSS hex strings (e.g., ["#E74C3C", "#3498DB"]). When omitted, the theme’s default palette is used.
transparent_background
boolean
default:"true"
When true, the exported PNG has a transparent background. Set to false to fill the background with the theme’s background color.

Annotations

show_annotations
boolean
default:"true"
Whether to overlay annotation lines from the indicator’s stored annotations.
annotations
object
Custom annotations configuration object passed directly to the chart renderer. Use this to provide annotations outside of those stored in the database.

Export dimensions

width
integer
default:"800"
Output image width in pixels.
height
integer
default:"400"
Output image height in pixels.

Response

Returns the chart as a binary PNG image.
HeaderValue
Content-Typeimage/png
Content-Dispositionattachment; filename=indicator_{indicator_id}.png

Examples

curl -X POST \
  "https://api.example.com/indicators/64b1f2c3d4e5f6a7b8c9d0e1/export/image" \
  -H "Content-Type: application/json" \
  -d '{
    "chart_type": "line",
    "xaxis_type": "datetime",
    "theme": "light",
    "title": "Annual visitor arrivals",
    "granularity": "1M",
    "start_date": "2019-01-01T00:00:00Z",
    "end_date": "2023-12-31T23:59:59Z",
    "width": 1200,
    "height": 600,
    "transparent_background": false
  }' \
  --output indicator_chart.png
import httpx

client = httpx.AsyncClient(base_url="https://api.example.com")
response = await client.post(
    "/indicators/64b1f2c3d4e5f6a7b8c9d0e1/export/image",
    json={
        "chart_type": "line",
        "xaxis_type": "datetime",
        "theme": "light",
        "title": "Annual visitor arrivals",
        "granularity": "1M",
        "start_date": "2019-01-01T00:00:00Z",
        "end_date": "2023-12-31T23:59:59Z",
        "width": 1200,
        "height": 600,
        "transparent_background": False,
    },
)
response.raise_for_status()
with open("indicator_chart.png", "wb") as f:
    f.write(response.content)
To embed the exported image directly in a web page without saving to disk, read response.content into a BytesIO object or encode it as base64.

Build docs developers (and LLMs) love