---
seo_title: File Conversion API Quickstart Tutorial | EnConvert
meta_desc: Convert your first file in 3 steps: get an API key, then call POST /v1/convert/url-to-pdf with cURL or Python. Node.js and JSON to XML upload examples included.
keywords: file conversion api quickstart, convert files api tutorial, url to pdf api curl example, convert url to pdf python, json to xml api example, file conversion api key, upload file conversion api, convert file rest api node.js
---

# File Conversion API Quickstart

This quickstart tutorial walks you through your first file conversion request with the EnConvert API, using `/v1/convert/url-to-pdf` to capture a web page as a PDF. In three steps you sign up, generate a private API key, and send a request with cURL, Python, or JavaScript. That includes a `multipart/form-data` file upload example for JSON to XML. Successful conversions return a `presigned_url` for downloading the converted file, along with storage and timing metadata.

## Getting Started in 3 Steps

1. **Sign up.** Create an account at [enconvert.com](https://enconvert.com) to get your API key.
2. **Get your API key.** Navigate to the dashboard and generate a private key (`sk_...`). Copy it and keep it secure.
3. **Make your first request.** Use the examples below to convert a file or URL.

## Example: Convert a URL to PDF

Use the `/v1/convert/url-to-pdf` endpoint to capture any web page as a PDF document.

### cURL

```bash
curl -X POST https://api.enconvert.com/v1/convert/url-to-pdf \
  -H "X-API-Key: YOUR_PRIVATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "direct_download": false}'
```

### Response

A successful conversion returns the download URL, storage path, and metadata:

```json
{
  "presigned_url": "https://econverter.nyc3.cdn.digitaloceanspaces.com/...",
  "object_key": "live/files/12345/url-to-pdf/example_20250202_120530123.pdf",
  "filename": "example_20250202_120530123.pdf",
  "file_size": 45678,
  "conversion_time_seconds": 3.21
}
```

- `presigned_url`: a temporary, downloadable URL for the converted file.
- `object_key`: the storage path of the file (e.g., `live/files/12345/url-to-pdf/...`).
- `filename`: the generated filename.
- `file_size`: the size of the converted file in bytes.
- `conversion_time_seconds`: how long the conversion took.

## Example: Convert a File (JSON to XML)

Upload a file for conversion using `multipart/form-data`.

### cURL

```bash
curl -X POST https://api.enconvert.com/v1/convert/json-to-xml \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@data.json" \
  -F "direct_download=false"
```

### Response

```json
{
  "presigned_url": "https://econverter.nyc3.cdn.digitaloceanspaces.com/...",
  "object_key": "live/files/12345/json-to-xml/data_20250202_120530123.xml",
  "filename": "data_20250202_120530123.xml",
  "file_size": 1024,
  "conversion_time_seconds": 0.45
}
```

## Python Example

Use the `requests` library to convert a URL to PDF:

```python
import requests

response = requests.post(
    "https://api.enconvert.com/v1/convert/url-to-pdf",
    headers={"X-API-Key": "YOUR_API_KEY"},
    json={"url": "https://example.com"}
)

result = response.json()
pdf = requests.get(result["presigned_url"]).content

with open("output.pdf", "wb") as f:
    f.write(pdf)

```

## JavaScript (Node.js) Example

Use the built-in `fetch` API (Node.js 18+) or any HTTP client:


```javascript
const fs = require("fs");

const formData = new FormData();
formData.append("file", new Blob([fs.readFileSync("input.json")]), "input.json");
formData.append("direct_download", "true");

const response = await fetch("https://api.enconvert.com/v1/convert/json-to-xml", {
  method: "POST",
  headers: { "X-API-Key": "YOUR_API_KEY" },
  body: formData,
});

const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("output.xml", buffer);
```

## Frequently asked questions

### How do I get an API key for the EnConvert file conversion API?

Create an account at [enconvert.com](https://enconvert.com), then navigate to the dashboard and generate a private key (`sk_...`). Copy it and keep it secure, because you send it on every request in the `X-API-Key` header.

### How do I convert a URL to PDF with cURL?

Send a `POST` request to `https://api.enconvert.com/v1/convert/url-to-pdf` with your key in the `X-API-Key` header and a JSON body such as `{"url": "https://example.com", "direct_download": false}`. The response is JSON; fetch the `presigned_url` it contains to download the PDF. Set `direct_download` to `true` instead and the PDF bytes come back in the response body, so `--output output.pdf` saves the file directly.

### How do I upload a file for conversion with the REST API?

Upload the file as `multipart/form-data`, e.g. `-F "file=@data.json"` in cURL against `/v1/convert/json-to-xml`. The Node.js example does the same with `FormData` and the built-in `fetch` API (Node.js 18+).

### What does a successful conversion response contain?

The JSON response includes `presigned_url` (a temporary, downloadable URL for the converted file), `object_key` (the storage path), `filename`, `file_size` in bytes, and `conversion_time_seconds`.

### Can I convert a URL to PDF in Python?

Yes. Use the `requests` library to `POST` to `https://api.enconvert.com/v1/convert/url-to-pdf` with the `X-API-Key` header and a JSON body containing the `url`, then read `presigned_url` from the JSON response and download it.

## Next steps

- [Authentication](/docs/authentication.md) covers private keys, public keys with JWT, and how to verify the credentials you just created.
- [Endpoints](/docs/endpoints.md) lists every route you can call and the parameters they share.
- [Sync and Async Jobs](/docs/concepts/sync-and-async.md) explains when a request returns the result inline and when it hands you a job to poll.
