---
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 — including 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}' \
  --output output.pdf
```

### 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" \
  --output output.xml
```

### 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"}
)

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

```

## 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 — 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}`. Use `--output output.pdf` to save the result locally.

### 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 write the response content to a file.
