# Quickstart

Compress your first PDF with the FynePDF API in five minutes, with curl, Node or Python.

## 1. Get a key

Sign in on fynepdf.com, open [Developers](https://fynepdf.com/developers/dashboard?section=keys) and create a key. Start with a **test key**: it's free, and every PDF it makes says "FynePDF test key" across the page. Keep the key on your server, then:

```bash
export FYNEPDF_API_KEY="fyne_test_…"
```

Using Node or Python? Install the SDK; curl needs nothing:

```bash title="Node"
npm install fynepdf
```

```bash title="Python"
pip install fynepdf
```

## 2. Add a file

Point the API at a PDF on the web (or [upload one](https://fynepdf.com/developers/docs/files)):

```bash title="curl"
curl https://api.fynepdf.com/v1/files \
  -H "Authorization: Bearer $FYNEPDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/report.pdf"}'
```

```js title="Node"
import FynePDF from "fynepdf";

const fyne = new FynePDF(); // reads FYNEPDF_API_KEY
const file = await fyne.files.fromUrl("https://example.com/report.pdf");
console.log(file.id); // file_…
```

```python title="Python"
from fynepdf import FynePDF

fyne = FynePDF()  # reads FYNEPDF_API_KEY
file = fyne.files.from_url("https://example.com/report.pdf")
print(file["id"])  # file_…
```

A file on your computer? `fyne.files.upload("./report.pdf")` sends it, through an upload link when it's over 25 MB.

The answer is the file, with an `id` like `file_01jc8x4m2k9q7r3t5vwy6z`.

## 3. Compress it

Ask for a target size; the API picks the settings:

```bash title="curl"
curl https://api.fynepdf.com/v1/pdf/compress \
  -H "Authorization: Bearer $FYNEPDF_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_id":"file_01jc8x4m2k9q7r3t5vwy6z","target_size_bytes":5000000}'
```

```js title="Node"
const job = await fyne.pdf.compress({ file_id: file.id, target_size_bytes: 5_000_000 });
```

```python title="Python"
job = fyne.pdf.compress(file_id=file["id"], target_size_bytes=5_000_000)
```

## 4. Download the result

The call waits up to 30 seconds and answers with the finished **job**. Its receipt says what happened, and `outputs` holds the result:

```json
{
  "status": "succeeded",
  "receipt": {
    "steps": [
      { "action": "compress", "status": "succeeded", "bytes_before": 8700000, "bytes_after": 4600000, "target_met": true, "credits": 1 }
    ],
    "credits": 1
  },
  "outputs": [
    { "id": "file_01jc9b7c8d9e0f1g2h3j4k", "filename": "report.pdf", "bytes": 4600000, "download_url": "https://files.fynepdf.com/…" }
  ]
}
```

```bash title="curl"
curl -o report-small.pdf "https://files.fynepdf.com/…"
```

```js title="Node"
await fyne.files.downloadTo(job.outputs[0], "./report-small.pdf");
```

```python title="Python"
fyne.files.download_to(job["outputs"][0], "report-small.pdf")
```

`download_url` works for an hour; the file is kept for 24 hours, and its `id` can go straight into another job. A job that's still running answers `202`: [poll it or use a webhook](https://fynepdf.com/developers/docs/jobs). The SDKs retry safely and wait for you: `fyne.jobs.wait(job)`.

## Next

- Chain steps in one [job](https://fynepdf.com/developers/docs/jobs): compress, then add page numbers, then PDF/A.
- Switch to a **live key** when you're ready: 250 free credits every month, then [credit packs](https://fynepdf.com/developers/docs/limits).
- Browse every action in the menu, from [OCR](https://fynepdf.com/developers/docs/api/ocr) to [generating invoices](https://fynepdf.com/developers/docs/api/create-pdf).


---

Open this page in a browser: https://fynepdf.com/developers/docs/quickstart

More: [All tools](https://fynepdf.com/tools) · [AI agents](https://fynepdf.com/ai/agents) · [llms.txt](https://fynepdf.com/llms.txt) · [Sitemap](https://fynepdf.com/sitemap.xml)
