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
Header | Required | Description |
---|---|---|
Authorization | Yes | Bearer token obtained through OAuth 2.0 |
Content-Type | Yes | Must be application/json |
Body Parameters
Parameter | Type | Required | Description |
---|---|---|---|
templateId | string | Yes | Unique identifier of the chart template |
chartType | string | No | Type of chart (default: “stackedBar”). Chart Types |
x | array | Yes | X-axis data object Ex: [“Mobile”, “Desktop”, “Tablet”] |
y | array | Yes | Y-axis data object Ex: [100, 200, 400] |
z | array | Yes (if the chart type has a group axis) | Group axis data object Ex: [“Site A”, “Site A”, “Site B”] |
title | string | No | Main chart title |
subtitle | string | No | Secondary chart title |
xTitle | string | No | X-Axis title |
yTitle | string | No | Y-Axis title |
zTitle | string | No | Group Axis title |
dLabel | string | No | Show Data Labels near the chart pieces Ex: dLabel=true |
overrides | string | No | Any 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 OKContent-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"}