apyhub
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
http://localhost:8080/apyhub/generate-pie-chart/download
QUICKSTARTGUIDE

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 "http://localhost:8080/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 a binary file response (string with format: "binary"), which you can save directly to disk.

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*
6-character hex color without the leading # symbol.
pies
Alias for data. Use either data or pies, not both.
Chart theme.
options
title_style
Padding in pixels.
Font size in pixels.
6-character hex color without the leading # symbol.
6-character hex color without the leading # symbol.

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

ParameterTypeMandatoryDescription
dataObject ArrayYesPie chart slices. Each item must include label and value; color is optional.
data[].colorStringNo6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
data[].labelStringYesSlice label.
data[].valueNumberYesSlice value. Must be greater than or equal to 0.
piesObject ArrayNoDeprecated alias for data. Use either data or pies, not both. Each item must include label and value; color is optional.
pies[].colorStringNo6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
pies[].labelStringYesSlice label.
pies[].valueNumberYesSlice value. Must be greater than or equal to 0.
themeENUMNoChart theme. Allowed values: light, dark. Default: light.
titleStringYesChart title. Minimum length: 1.
optionsObjectNoOptional rendering options. Includes width, height, title_style, and canvas_color.
options.widthIntegerNoChart width in pixels. Must be greater than or equal to 1.
options.heightIntegerNoChart height in pixels. Must be greater than or equal to 1.
options.title_styleObjectNoTitle styling options. Includes padding, font_size, and font_color.
options.title_style.paddingIntegerNoPadding in pixels. Must be greater than or equal to 0.
options.title_style.font_sizeNumberNoFont size in pixels. Must be greater than or equal to 1.
options.title_style.font_colorStringNo6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.
options.canvas_colorStringNo6-character hex color without the leading # symbol. Pattern: ^[A-Fa-f0-9]{6}$.

Response

Returns a binary file response containing the generated pie chart image.

ParameterTypeMandatoryDescription
binary outputStringYesRendered pie chart image returned as binary data.

Query parameters

Name
Type
Description
outputOPTIONAL
string

Body

Name
Type
Description
bodyREQUIRED
object
▣ 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.