apyhub
Back
▣ SMART GENERATION

Generate Pie Chart API

Hosted on ApyHub

What it does

Pie Chart Generator turns your labeled values into a pie chart image. Send a title, a data array, and optional styling options, and get back a pre-signed URL for the rendered chart or a binary image download.

Each data item can include a label, value, and optional hex color. The request also supports a light or dark theme, plus chart options for width, height, title styling, and canvas color. Use the deprecated pies alias only if you need to match an older integration; data is the primary field.

Use Pie Chart Generator when you need a shareable visual for product mix, budget allocation, survey results, or any other part-to-whole breakdown. It is a good fit for dashboards, reports, admin panels, and automated content pipelines where the chart needs to be generated from API data instead of drawn in the browser.

The response is simple to work with: one endpoint returns a URL in data, and the other returns the image as binary output. That keeps the integration lightweight whether you want to store the image, embed it, or hand it off to another service.

▣ ENDPOINT 02 / 02
POST
Generate pie chart image
https://api.eu.apyhub.com/apyhub/generate-pie-chart/download

QUICKSTART

GUIDE

Quickstart

Generate a pie chart file from a simple title and slice data, and name the output with the output query parameter.

curl -X POST "https://api.eu.apyhub.com/apyhub/generate-pie-chart/download?output=product-market-share-pie-chart" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title":"Product Market Share","data":[{"color":"3B82F6","label":"Product A","value":45},{"color":"10B981","label":"Product B","value":30},{"color":"F59E0B","label":"Product C","value":25}]}'

What you'll get back

Returns the raw PNG bytes (image/png), which you can save directly to disk — add -o chart.png to the curl command above.

TRY ITLIVE · 60 ATOMS
Loading your default key…
The full key is used to call the gateway and stays in this tab — never sent to orbit or saved.
body*
data*
data-1*
pies
Alias for data. Use either data or pies, not both.
Chart theme.
options
title_style

About this endpoint

What it does

Generates a pie chart image from the chart configuration in the request body and returns the rendered image as binary output. The request must include the chart title and data, and can also include optional styling and sizing options.

Request Body

ParameterTypeDescription
dataObject ArrayPie chart slices. Each item must include label and value; color is optional.
data[].colorString6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
data[].labelStringSlice label.
data[].valueNumberSlice value. Must be greater than or equal to 0.
piesObject ArrayDeprecated alias for data. Use either data or pies, not both. Each item must include label and value; color is optional.
pies[].colorString6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
pies[].labelStringSlice label.
pies[].valueNumberSlice value. Must be greater than or equal to 0.
themeENUMChart theme. Allowed values: light, dark. Default: light.
titleStringChart title. Minimum length: 1.
optionsObjectOptional rendering options. Includes width, height, title_style, and canvas_color.
options.widthIntegerChart width in pixels. Must be greater than or equal to 1.
options.heightIntegerChart height in pixels. Must be greater than or equal to 1.
options.title_styleObjectTitle styling options. Includes padding, font_size, and font_color.
options.title_style.paddingIntegerPadding in pixels. Must be greater than or equal to 0.
options.title_style.font_sizeNumberFont size in pixels. Must be greater than or equal to 1.
options.title_style.font_colorString6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
options.canvas_colorString6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.

Response

Returns the rendered chart as a binary PNG image (image/png). Use the output query parameter to name the file; the .png extension is added for you.

▣ COMMON ERRORS

Errors any endpoint can return

400bad_request

Required parameter missing or malformed body.

401unauthorized

API key missing, revoked, or not authorized for this service.

429rate_limited

Your plan's per-second rate exceeded. Retry with exponential backoff.

503upstream_busy

Backend temporarily unavailable. Try again in a few seconds.