---
title: "Pretty Charts"
method: POST
path: "/v1/pretty-charts"
tags: ["documents"]
---

# Pretty Charts

`POST /v1/pretty-charts`

## Request

- Base URL: `https://agent.pocket.network`
- URL: `https://agent.pocket.network/v1/pretty-charts`
- Auth: none required

Renders a chart from inline data (CSV, TSV, JSON or row values) and returns it as static SVG, or a complete HTML document, inside a JSON object. POST /v1/chart with either a full Vega-Lite v6 spec or the shorthand form (type, x, y, color, ranges, colors, theme). Every data mark carries a native tooltip, so nothing is scripted. Pay per request in USDC; no account, no API key.

## Request body

- object: Exactly one of `spec` or `chart` is required. `data` is required with `chart` and optional with `spec` (a spec may carry inline data.values). Remote data URLs are refused; every input lives in the body.
  - `data` object: Inline data; exactly one of csv, tsv, json or values.
    - `csv` string: CSV text with a header row. Numbers and ISO dates are parsed.
    - `tsv` string: Tab-separated text with a header row.
    - `json` string: A JSON array of row objects, as a string.
    - `values` object[]: Row objects.
  - `spec` object: A Vega-Lite v6 spec. Any `url` anywhere in it is refused.
  - `chart` object: Shorthand that compiles to a single-view Vega-Lite spec. `type` is one of bar, line, area, point, scatter, circle, square, tick, rect, heatmap, arc, pie, donut, boxplot, errorbar, errorband, rule, text, trail; channels (x, y, color, size, shape, theta, ...) take a column name or a field definition; plus xRange, yRange, colors, colorScheme, stack, title, width, height, tooltip.
    - `type` string, required
    - `x` unknown
    - `y` unknown
    - `color` unknown
    - `title` unknown
    - `tooltip` unknown
    - `xRange` unknown[]
      - unknown
    - `yRange` unknown[]
      - unknown
    - `colors` string[]
    - `width` number
    - `height` number
  - `options` object: Render options.
    - `format` 'svg' | 'html'
    - `tooltips` boolean
    - `theme` string: A vega-themes preset
    - `width` number
    - `height` number
    - `background` string
    - `title` string

## Response `200`

The upstream response, served after payment settles.

- object: For POST /v1/chart, the rendered chart as JSON: `service` ("pretty-charts"), `format` (svg or html), `content_type` (image/svg+xml or text/html), `width` and `height` in pixels, `rows` (inline data rows received), `marks` (data marks drawn), `tooltips`, `render_ms`, `warnings` (Vega and Vega-Lite warnings, if any) and `html` — the SVG element, or a complete HTML document for format html; always the last field. Errors return `{ error: { code, message, details? } }` with a code such as invalid_spec, too_many_rows or render_failed. The other routes (healthz, version, capabilities, openapi.json) return their own small JSON documents.

## Other responses

- `400`: Malformed request.
- `402`: Payment required. The x402 v2 terms are in the PAYMENT-REQUIRED header and, identically, in this body; sign the chosen option and retry with the PAYMENT-SIGNATURE header. The receipt arrives in PAYMENT-RESPONSE.
- `503`: This service is not currently available to serve.

---

[API](https://skmtc.dev/pocket/apis/pocket-agentic-portal.md) · [All operations](https://skmtc.dev/pocket/apis/pocket-agentic-portal/llms.txt) · [OpenAPI document](https://skmtc.dev/pocket/apis/pocket-agentic-portal/revisions/96d2176db014?raw)
