apyhub
Back
▣ IMAGE PROCESSING · SMART GENERATION

Generate Bar Graph API

Hosted on ApyHub

What it does

The Bar Chart API turns a title and a list of labeled values into a PNG bar graph. Send a title and a data array of { label, value } items, and get back the image as a file from /download or as a pre-signed URL in the data field from /link.

Each bar can take its own color as a 6-character hex code without the #. Set theme to light or dark, and use options to control width, height, bar_width, spacing, axis font size and color, title styling, background padding, and canvas color. Pre-signed links expire after 15 minutes, so download or store the image if you need it longer.

Use the bar chart API to render revenue by region, signups by plan, or usage by feature for weekly reports, email digests, PDF invoices, and admin dashboards. It works as a server-side bar graph generator, so every chart comes out with the same styling and needs no browser or frontend charting library.

For values split into segments, use the Stacked Bar Chart API, and for shares of a whole, the Pie Chart API. Place the chart in a report with the HTML to PDF API, or turn it into a PDF page with the Image to PDF API. AI agents can generate these charts through ApyHub MCP.

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

QUICKSTART

GUIDE

Quickstart

Generate a bar chart image from a minimal JSON payload.

curl -X POST "https://api.eu.apyhub.com/apyhub/generate-bar-graph/download?output=file" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Quarterly Sales by Region",
    "data": [
      { "label": "North America", "value": 42000 }
    ]
  }' \
  -o bar-chart.png

What you'll get back

Returns the generated bar chart image as a binary file response.

The example above saves the downloaded file locally as bar-chart.png.

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*
Canonical list of bar values.
data-1*
bars
Alias for data. Use either data or bars, not both.
Chart theme.
options
Chart width in pixels.
x_axis
y_axis
background
title_style

About this endpoint

What it does

Generates a bar chart image from the chart configuration in the request body and returns the image as binary data.

Request Body

ParameterTypeDescription
dataObject ArrayCanonical list of bar values. Each item supports label and value, and may include color. Requires at least 1 item.
data[].colorString6-character hex color without the leading # symbol.
data[].labelStringBar label.
data[].valueNumberBar value.
barsObject ArrayAlias for data. Deprecated. Use either data or bars, not both. Each item supports label and value, and may include color.
bars[].colorString6-character hex color without the leading # symbol.
bars[].labelStringBar label.
bars[].valueNumberBar value.
themeENUMChart theme. Allowed values: light, dark. Default: light.
titleStringChart title. Must be at least 1 character.
optionsObjectChart layout and styling options.
options.widthIntegerChart width in pixels. Minimum: 1.
options.heightIntegerChart height in pixels. Minimum: 1.
options.x_axisObjectX-axis styling options.
options.x_axis.font_sizeNumberFont size in pixels. Minimum: 1.
options.x_axis.font_colorString6-character hex color without the leading # symbol.
options.y_axisObjectY-axis styling options.
options.y_axis.font_sizeNumberFont size in pixels. Minimum: 1.
options.y_axis.font_colorString6-character hex color without the leading # symbol.
options.spacingIntegerSpacing in pixels. Minimum: 0.
options.bar_widthIntegerBar width in pixels. Minimum: 1.
options.backgroundObjectBackground styling options.
options.background.colorString6-character hex color without the leading # symbol.
options.background.paddingIntegerPadding in pixels. Minimum: 0.
options.title_styleObjectTitle styling options.
options.title_style.paddingIntegerPadding in pixels. Minimum: 0.
options.title_style.font_sizeNumberFont size in pixels. Minimum: 1.
options.title_style.font_colorString6-character hex color without the leading # symbol.
options.canvas_colorString6-character hex color without the leading # symbol.

Response

Returns a binary response body containing the generated chart image.

Notes

bars is a deprecated alias for data. Use one or the other, not both.

▣ 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.