---
title: "Data to chart image (bar, line, pie, doughnut, radar)"
method: POST
path: "/chart"
tags: ["Images"]
---

# Data to chart image (bar, line, pie, doughnut, radar)

`POST /chart`

## Request

- Base URL: `https://api.cofferdock.com`
- URL: `https://api.cofferdock.com/chart`
- Auth: API key in header `x-api-key`

Turns labels and numeric series into a chart image, without a browser. Pie and doughnut accept 1 series only.

Costs 1 credit per call.

## Request body

- object
  - `type` 'bar' | 'line' | 'pie' | 'doughnut' | 'radar', required: Chart type: "bar", "line", "pie", "doughnut" or "radar".
  - `labels` string[], required: Category names, 1 to 50 strings of up to 100 characters each: the x axis for bar and line charts, the slices for pie and doughnut, the axes for radar.
  - `series` object[], required: Data series, 1 to 10. Each item is {"name": "Series name", "data": [numbers]} with one number per label. Pie and doughnut charts use only the first series.
    - `name` string
    - `data` number[], required: Same length as labels.
  - `title` string: Optional title shown above the chart.
  - `width` integer: Chart width in pixels (200-2000). Default 800.
  - `height` integer: Chart height in pixels (200-2000). Default 500.
  - `format` 'png' | 'svg': Image format: "png" (default) or "svg".
  - `output` 'json' | 'binary' | 'url' | 'image': How to return the image: "json" (base64 in the JSON response), "binary" (the image itself, ready for n8n/Make/Zapier) or "url" (a temporary download link, valid 15 minutes). Default: json when the request is JSON, binary when the input was sent raw.

## Response `200`

The resulting image (shape depends on `output`).

- union
  - object
    - `success` boolean
    - `image` string, byte
    - `mime_type` 'image/png' | 'image/svg+xml'
    - `meta` object
      - `size_bytes` integer
      - `format` string
      - `width` integer
      - `height` integer
      - `used` integer: Credits used this month, after this call.
      - `remaining` integer, nullable: Credits left this month (null = unlimited).
      - `unlimited` boolean
  - object: Returned when output=url: a temporary download link (valid 15 minutes).
    - `success` boolean
    - `url` string, uri: Temporary download link. Expires in 15 minutes.
    - `expires_at` string, date-time
    - `mime_type` string
    - `size_bytes` integer
    - `meta` object
      - `used` integer: Credits used this month, after this call.
      - `remaining` integer, nullable: Credits left this month (null = unlimited).
      - `unlimited` boolean

## Other responses

- `400`: Invalid input (nothing is charged).
- `401`: Missing or invalid API key.
- `403`: Email not verified.
- `429`: Monthly credit limit reached, or too many requests per minute for this key (see Retry-After).
- `503`: Server busy (queue full). Retry after the seconds in the Retry-After header.

---

[API](https://skmtc.dev/cofferdock/apis/cofferdock-api.md) · [All operations](https://skmtc.dev/cofferdock/apis/cofferdock-api/llms.txt) · [OpenAPI document](https://skmtc.dev/cofferdock/apis/cofferdock-api/revisions/b57aa000d33a?raw)
