# Extract the data behind a chart in a PDF with an API

> Turn bar and line charts in PDFs into data tables with Reducto Parse and the advanced chart agent.

Canonical: https://reducto.ai/cookbooks/extract-chart-data-from-pdf

Call Reducto Parse with enhance.advanced_chart_agent set to true. Charts in the document come back as tables of the underlying values, inside the same Markdown and blocks as the rest of the page. It is slower and costs more than a plain parse, so turn it on for documents where chart values matter.

## What you'll build

Synthetic quarterly sales chart (or your own file)

- Upload the PDF or pass a public URL.
- Call /parse with enhance.advanced_chart_agent set to true.
- Read the chart values from the Figure block in result.chunks[].blocks.
- Spot-check a few values against the chart before using them.

## Setup

Grab an API key from <a href="https://studio.reducto.ai" rel="noopener noreferrer" target="_blank">studio.reducto.ai</a> -> API Keys -> Create new API key, then set it and install the SDK:

```bash
export REDUCTO_API_KEY="your-api-key-here"
pip install reductoai   # or: npm install reductoai
```

## Step 1: Call `/parse`

The options that matter for this job:

- `enhance.advanced_chart_agent`: Runs chart extraction on figures.
- `settings.model`: The parse model for the rest of the page.

```python
# pip install reductoai
from pathlib import Path
from reducto import Reducto

client = Reducto()  # reads REDUCTO_API_KEY

upload = client.upload(file=Path("chart.pdf"))
result = client.parse.run(
    input=upload.file_id,
    settings={
        "model": "r-1",
    },
    enhance={
        "advanced_chart_agent": True,
    },
)
print(result)
```

```javascript
// npm install reductoai

const client = new Reducto(); // reads REDUCTO_API_KEY

const upload = await client.upload({ file: fs.createReadStream("chart.pdf") });
const result = await client.parse.run({
  input: upload.file_id,
  settings: {
    model: "r-1",
  },
  enhance: {
    advanced_chart_agent: true,
  },
});
console.log(JSON.stringify(result, null, 2));
```

Or with curl:

```bash
# 1. Upload the file (or pass a public URL as "input" and skip this step)
curl -s https://platform.reducto.ai/upload \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -F file=@chart.pdf
# => {"file_id": "reducto://..."}

# 2. Run parse
curl -s https://platform.reducto.ai/parse \
  -H "Authorization: Bearer $REDUCTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "input": "reducto://FILE_ID",
  "settings": {"model": "r-1"},
  "enhance": {"advanced_chart_agent": true}
}'
```

## Step 2: Read the result

On the sample (a synthetic quarterly sales chart), the job-specific part of the response:

```markdown
## Data table

| Quarter | Industrial Sensors | Fluid Systems | Aftermarket Services |
|---|---:|---:|---:|
| Q1 FY26 | 412 | 288 | 151 |
| Q2 FY26 | 438 | 301 | 158 |
| Q3 FY26 | 471 | 296 | 166 |
| Q4 FY26 | 505 | 322 | 177 |
```

The values were not printed on the bars; the chart agent read them from the plot into a table.

[Full response format ->](https://docs.reducto.ai/parse/response-format)

## When to use something else

- **Chart agent**: when chart values must be searchable or analyzed.
- **Plain Parse**: when a figure caption or summary is enough.

## Where this goes next

- [Reducto chart extraction research](/blog/reducto-chart-extraction)
- [Parse docs](https://docs.reducto.ai/parse)
- [Reducto Parse](/parse)
