Skip to content

Generate Image

Generate chart images using customizable templates and data parameters.

Endpoint

POST https://api.instacharts.io/v1/generate/image

Authorization

This endpoint requires OAuth 2.0 authentication. Include your access token in the Authorization header:

Authorization: Bearer your_access_token

Request Parameters

Headers

HeaderRequiredDescription
AuthorizationYesBearer token obtained through OAuth 2.0
Content-TypeYesMust be application/json

Body Parameters

ParameterTypeRequiredDescription
templateIdstringYesUnique identifier of the chart template
chartTypestringNoType of chart (default: “stackedBar”). Chart Types
xarrayYesX-axis data object Ex: ["Mobile", "Desktop", "Tablet"]
yarrayYesY-axis data object Ex: [100, 200, 400]
zarrayYes (if unaggregated data is chosen and the chart type has a breakdown)Breakdown axis data object Ex: ["Site A", "Site A", "Site B"]
seriesarrayYes (if series data is chosen)Series data. An array of objects each with a label and data array Ex:[{label:"Site A",data:[1,2,3]},{label:"Site B",data:[4,5,6]}]
titlestringNoMain chart title
subtitlestringNoSecondary chart title
xTitlestringNoX-Axis title
yTitlestringNoY-Axis title
zTitlestringNoLegend title
dLabelstringNoShow Data Labels near the chart pieces Ex: dLabel=true
overridesstringNoAny query params not defined above. Join parameters with & Ex: color=cccccc&width=500

Example Requests

Basic Line Chart

{
"templateId": "basic-line",
"chartType": "line",
"title": "Monthly Sales 2024",
"subtitle": "Revenue by Product Category",
"x": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
"xTitle": "Month",
"yTitle": "Revenue ($)",
"y": [1200, 1900, 2100, 2400, 2800, 3100]
}

Responses

Success Response

HTTP/1.1 200 OK
Content-Type: image/png

The response body will contain the binary image data in the requested format.

Error Responses

Error responses are plain text in the response body, not a JSON object.

Invalid Request or Render Error (400)

HTTP/1.1 400 Bad Request
Content-Type: text/plain
Error serving image

The body text varies with the underlying problem (for example an invalid or missing templateId).

Out of Tasks (400)

HTTP/1.1 400 Bad Request
Content-Type: text/plain
Out of tasks

Returned when your account has used its full monthly task allowance. Each successful image generation counts as one task.

Authentication Error (401)

{
"error": "invalid_token"
}