Getting Started#

Introducing the general concepts for using the PDF.co API, authentication methods, response codes and sample code.

API Reference#

The PDF.co Web API is REST-based, making it intuitive and easy to use. To prioritize your data’s security and privacy, all requests are securely transmitted using HTTPS. Kindly note, unsecured HTTP connections are not supported.

All requests contain the following base URL:

https://api.pdf.co/v1

Authenticating Your API Request#

To authenticate you need to add a header named x-api-key using your API Key as the value.

"x-api-key": "sample@sample.com_123a4b567c890d123e456f789g01"

Note

The key provided above is just a sample and won’t work for actual API calls. Don’t forget to replace it with your real API Key, which you can find in your PDF.co Dashboard, when making requests.

Response codes#

Status

Description

200

The request has succeeded

400

Bad input parameters

401

Unauthorized

403

Not enough credits

405

Timeout error. To process large documents or files please use asynchronous mode (set the async parameter to true) and then check status using the /job/check endpoint. If a file contains many pages then specify a page range using the pages parameter. The number of pages of the document can be obtained using the /pdf/info endpoint.

Sample Code#

Here is some sample code which would convert a PDF to a CSV file.

var data = {
              "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-csv/sample.pdf",
              "lang": "eng",
              "inline": true,
              "pages": "0-",
              "async": false,
              "name": "result.csv"
            }

fetch('https://api.pdf.co/v1/pdf/convert/to/csv', {
    method: 'POST',
    headers: {
        'Accept': 'application/json',
        'Content-Type': 'application/json',
        'x-api-key': 'sample@sample.com_123a4b567c890d123e456f789g01'
    },
    body: JSON.stringify(data)
})
   .then(response => response.json())
   .then(response => console.log(JSON.stringify(response)))
curl --location --request POST 'https://api.pdf.co/v1/pdf/convert/to/csv' \
--header 'Content-Type: application/json' \
--header 'x-api-key: sample@sample.com_123a4b567c890d123e456f789g01' \
--data-raw '{
    "url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-to-csv/sample.pdf",
    "lang": "eng",
    "inline": true,
    "pages": "0-",
    "async": false,
    "name": "result.csv"
}'