Documentation

YakCharts API reference

One endpoint renders a chart to a PNG image. Pass a chart type, your data as JSON, and optional styling, and you get back an image ready to embed.

New here? Start with Getting Started, follow a how-to guide, or skim the FAQ.

Endpoints

  • GET /api/chart.png — the authenticated endpoint. Requires a valid apiKey; counts against your monthly quota. With a correct hmac signature the watermark is removed.
  • GET /chart.png — the public demo endpoint. No key required; responses are watermarked. Handy for trying things out.
  • GET /gchart — Google Image Charts compatibility. Point an old chart.googleapis.com/chart?... URL here (same cht/chd/chs query string) and it renders again. Watermarked, no key required.

Parameters

  • type — one of the 28 chart types: line, sparkline, spline, area, bar, stacked, percentage_bar, horizontal_bar, horizontal_stacked, funnel, gauge, waterfall, bullet, scatter, pie, donut, bubble, box_whiskers, candlestick, polar_line, polar_spline, polar_area, polar_scatter, sankey, violin, wordcloud, choropleth, qrcode. See them rendered in the examples gallery.
  • data — URL-encoded JSON array of rows, e.g. [["Q1",10],["Q2",15]]. The first element of each row is the label/x value; remaining elements are series values.
  • title — chart title (URL-encoded text).
  • options — URL-encoded JSON object for styling. Supports theme and, for bar/series charts, a categories array naming each series. Email-ready extras: "showValues": true prints the numbers on bars and points (images have no hover tooltips), "labelFormat": "value" or "percent" adds numbers to pie slice labels, "centerLabel": "42%" draws a big label inside the donut hole, "transparent": true returns an alpha-channel image that blends with any background — including dark-mode email clients — and "localizeNumbers": true adds thousands separators (set "locale": "de-DE" etc. for other conventions).
  • width, height — image size in pixels, 64–2048 (public endpoints cap at 1024). Defaults to 800×600.
  • scale — retina multiplier 1–3: same layout, N× the pixels. Use scale=2 and display at the original size for crisp charts on phones and high-DPI screens.
  • format — png (default) or webp for smaller files at the same visual quality.
  • apiKey — your API key (required on /api/chart.png).
  • hmac — optional HMAC-SHA256 signature of the query string (without the &hmac= part) keyed by your secret. Supplying a valid signature removes the watermark.

Caching

Chart renders are deterministic, so responses carry a strong ETag and Cache-Control: public, max-age=86400. Send If-None-Match to revalidate: a 304 Not Modified answer is free and never counts against your monthly quota.

Themes

Set "theme" inside options to one of: default, dark, light, cerulean, icy, sand, NCS, contrast, jetbrains. You can also design your own in the Theme Editor and reference it by name.

Examples

# Line chart
GET /api/chart.png?apiKey=KEY&type=line&title=Line%20Chart&data=[[-1,1],[0,-5],[1,3],[2,10]]

# Pie chart with a theme
GET /api/chart.png?apiKey=KEY&type=pie&title=Pie&data=[[\"Chrome\",63],[\"Safari\",20],[\"Firefox\",5]]&options={\"theme\":\"dark\"}

# Multi-series bar chart with named categories
GET /api/chart.png?apiKey=KEY&type=bar&title=Bar&data=[[\"Q1\",12,8],[\"Q2\",19,5]]&options={\"theme\":\"cerulean\",\"categories\":[\"Plan\",\"Actual\"]}

Code samples

Because every chart is just a URL that returns a PNG, you can embed it directly or fetch and save it from any language.

JavaScript (build an <img> URL)

const params = new URLSearchParams({
  apiKey: "YOUR_API_KEY",
  type: "line",
  title: "Revenue",
  data: JSON.stringify([[-1, 1], [0, -5], [1, 3], [2, 10]]),
  options: JSON.stringify({ theme: "dark" }),
});
const url = "https://yakcharts.com/api/chart.png?" + params;
document.querySelector("#chart").src = url;

Python (save the PNG)

import json, requests

r = requests.get("https://yakcharts.com/api/chart.png", params={
    "apiKey": "YOUR_API_KEY",
    "type": "bar",
    "title": "Sales",
    "data": json.dumps([["Q1", 10, 8], ["Q2", 15, 12]]),
    "options": json.dumps({"theme": "cerulean", "categories": ["Plan", "Actual"]}),
})
open("sales.png", "wb").write(r.content)

PHP

<?php
$query = http_build_query([
    "apiKey"  => "YOUR_API_KEY",
    "type"    => "pie",
    "data"    => json_encode([["A", 30], ["B", 70]]),
    "options" => json_encode(["theme" => "dark"]),
]);
file_put_contents("chart.png", file_get_contents("https://yakcharts.com/api/chart.png?$query"));

Go

vals := url.Values{}
vals.Set("apiKey", "YOUR_API_KEY")
vals.Set("type", "line")
vals.Set("data", `[[-1,1],[0,-5],[1,3],[2,10]]`)

resp, _ := http.Get("https://yakcharts.com/api/chart.png?" + vals.Encode())
defer resp.Body.Close()
out, _ := os.Create("chart.png")
io.Copy(out, resp.Body)

Ruby

require "net/http"; require "json"; require "uri"

uri = URI("https://yakcharts.com/api/chart.png")
uri.query = URI.encode_www_form(
  apiKey: "YOUR_API_KEY", type: "bar",
  data: [["Q1", 10], ["Q2", 15]].to_json)
File.write("chart.png", Net::HTTP.get(uri))

Usage, plans & quotas

Each plan includes a monthly allowance of rendered charts; one /api/chart.png request counts as one. Your remaining allowance is shown on the API Keys page, and you can change plans on the Account & Billing page.

PlanCharts / monthPrice
Free1,000$0, watermarked — your first 30 days add custom themes, Slack and tracked embeds; no card required
Basic100,000$10 / month
Advanced1,500,000$50 / month
Business5,000,000$100 / month

When a key exhausts its monthly allowance the API responds with 402 until the cycle resets or you upgrade. See Pricing for full details. A machine-readable OpenAPI 3.1 spec is available at https://yakcharts.com/openapi.yaml.

Responses & errors

A successful request returns 200 OK with Content-Type: image/png. Error responses are returned as JSON:

{ "code": 401, "msg": "Invalid or missing API key." }
{ "code": 402, "msg": "Monthly request limit reached for this plan." }
{ "code": 429, "msg": "Rate limit exceeded; retry shortly." }

Chat & integrations

Beyond the REST API, YakCharts ships a Slack app. Install it from the Integrations page, then post charts with /yakchart line "Revenue" [[1,10],[2,15]]. Manage your keys, quotas, and per-key options on the API Keys page.