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 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#

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:

{
  "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#

curl -X POST https://api.enconvert.com/v1/convert/json-to-xml \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "[email protected]" \
  --output output.xml

Response#

{
  "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:

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:

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, 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 "[email protected]" 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.