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 the chart type has a group axis)Group axis data object Ex: [“Site A”, “Site A”, “Site B”]
titlestringNoMain chart title
subtitlestringNoSecondary chart title
xTitlestringNoX-Axis title
yTitlestringNoY-Axis title
zTitlestringNoGroup Axis 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

Invalid Request (400)

{
"error": "invalid_request",
"message": "Required parameter 'templateId' is missing",
"code": "MISSING_PARAM"
}

Authentication Error (401)

{
"error": "unauthorized",
"message": "Invalid or expired access token",
"code": "INVALID_TOKEN"
}

Template Not Found (404)

{
"error": "not_found",
"message": "Template with ID 'basic-line' not found",
"code": "TEMPLATE_NOT_FOUND"
}