API Documentation

Introduction

PDF to JSON is not just another PDF parser API, it parser based on your JSON Schema. You provide your JSON Schema and our API parse it based on your schema. We use AI under the hood to give you sort of an assistant who parse based on your schema. It never gets tired, never complaints, and never ask for leaves.

Base Endpoint

http://api.pdftojson.dev

PDF to JSON

PDF to JSON parser endpoint. Provide your PDF file url with JSON schema in which you want to parse the file.

Convert to JSON

POST /pdftojson

Headers

Headerx-api-key *
Content-Typeapplication/json *

Paramters

KeyTypeRequiredDesc
pdf_urlstryesPublic PDF url that you want to parse, it must be a public accessible url and must end with .pdf Example PDF
json_schemaobjectyesYour JSON Schema in which you want to parse the given PDF file. View Example Schema, Also checkout json-schema.org doc for more details.

API limits

TypeLimitDuration
Rate Limit5per second

Account Info

Account info endpoint to check account related details.

Convert to JSON

GET /accountinfo

Headers

Headerx-api-key *
Content-Typeapplication/json *

API limits

TypeLimitDuration
Rate Limit5per second

Sample Code

Sample code for some popular languages.

curl --location 'https://api.pdftojson.dev/pdftojson' --header 'x-api-key: YOUR_API_KEY' --header 'Content-Type: application/json' --data '{
    "pdf_url": "https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf",
    "json_schema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "invoice_number": {
            "type": "string",
            "description": "the invoice number or serial no."
        },
        "invoice_currency": {
            "type": "string",
            "description": "the invoice currency, in which currency the invoice is. e.g. INR, EUR, $ etc.",
            "default": "not available"
        },
        "invoice_to": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "name of the person or company invoice raised to"
                },
                "address": {
                    "type": "string",
                    "description": "address of the person or company invoice raised to"
                },
                "email": {
                    "type": "string",
                    "description": "email of the person or company invoice raised to"
                },
                "phone": {
                    "type": "string",
                    "description": "phone number of the person or company invoice raised to",
                    "default": "not available"
                }
            },
            "description": "detail of the customer invoice raised to."
        },
        "invoice_date": {
            "type": "string",
            "description": "the invoice date raised on in MM-DD-YY format"
        },
        "invoice_items": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "description": "item name"
                    },
                    "quantity": {
                        "type": "number",
                        "description": "item quantity"
                    },
                    "price": {
                        "type": "number",
                        "description": "item price"
                    }
                },
                "required": [
                    "name",
                    "quantity",
                    "price"
                ]
            },
            "description": "all invoice items"
        },
        "invoice_sub_total": {
            "type": "number",
            "description": "the subtotal amount without currency symbol"
        },
        "invoice_tax": {
            "type": "number",
            "description": "tax amount the invoice without currency symbol"
        },
        "invoice_total": {
            "type": "number",
            "description": "the total invoice amount without currency symbol"
        }
    },
    "required": [
        "invoice_number",
        "invoice_currency",
        "invoice_to",
        "invoice_date",
        "invoice_items",
        "invoice_sub_total",
        "invoice_tax",
        "invoice_total"
    ]
}
}'
  
import requests
import json

url = "https://api.pdftojson.dev/pdftojson"

payload = json.dumps({
  "pdf_url": "https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf",
  "json_schema": {
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
      "invoice_number": {
        "type": "string",
        "description": "the invoice number or serial no."
      },
      "invoice_currency": {
        "type": "string",
        "description": "the invoice currency, in which currency the invoice is. e.g. INR, EUR, $ etc.",
        "default": "not available"
      },
      "invoice_to": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "name of the person or company invoice raised to"
          },
          "address": {
            "type": "string",
            "description": "address of the person or company invoice raised to"
          },
          "email": {
            "type": "string",
            "description": "email of the person or company invoice raised to"
          },
          "phone": {
            "type": "string",
            "description": "phone number of the person or company invoice raised to",
            "default": "not available"
          }
        },
        "description": "detail of the customer invoice raised to."
      },
      "invoice_date": {
        "type": "string",
        "description": "the invoice date raised on in MM-DD-YY format"
      },
      "invoice_items": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "item name"
            },
            "quantity": {
              "type": "number",
              "description": "item quantity"
            },
            "price": {
              "type": "number",
              "description": "item price"
            }
          },
          "required": [
            "name",
            "quantity",
            "price"
          ]
        },
        "description": "all invoice items"
      },
      "invoice_sub_total": {
        "type": "number",
        "description": "the subtotal amount without currency symbol"
      },
      "invoice_tax": {
        "type": "number",
        "description": "tax amount the invoice without currency symbol"
      },
      "invoice_total": {
        "type": "number",
        "description": "the total invoice amount without currency symbol"
      }
    },
    "required": [
      "invoice_number",
      "invoice_currency",
      "invoice_to",
      "invoice_date",
      "invoice_items",
      "invoice_sub_total",
      "invoice_tax",
      "invoice_total"
    ]
  }
})
headers = {
  'x-api-key': 'YOUR_API_KEY',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

  
const axios = require('axios');
  let data = JSON.stringify({
    "pdf_url": "https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf",
    "json_schema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
        "invoice_number": {
          "type": "string",
          "description": "the invoice number or serial no."
        },
        "invoice_currency": {
          "type": "string",
          "description": "the invoice currency, in which currency the invoice is. e.g. INR, EUR, $ etc.",
          "default": "not available"
        },
        "invoice_to": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "name of the person or company invoice raised to"
            },
            "address": {
              "type": "string",
              "description": "address of the person or company invoice raised to"
            },
            "email": {
              "type": "string",
              "description": "email of the person or company invoice raised to"
            },
            "phone": {
              "type": "string",
              "description": "phone number of the person or company invoice raised to",
              "default": "not available"
            }
          },
          "description": "detail of the customer invoice raised to."
        },
        "invoice_date": {
          "type": "string",
          "description": "the invoice date raised on in MM-DD-YY format"
        },
        "invoice_items": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "item name"
              },
              "quantity": {
                "type": "number",
                "description": "item quantity"
              },
              "price": {
                "type": "number",
                "description": "item price"
              }
            },
            "required": [
              "name",
              "quantity",
              "price"
            ]
          },
          "description": "all invoice items"
        },
        "invoice_sub_total": {
          "type": "number",
          "description": "the subtotal amount without currency symbol"
        },
        "invoice_tax": {
          "type": "number",
          "description": "tax amount the invoice without currency symbol"
        },
        "invoice_total": {
          "type": "number",
          "description": "the total invoice amount without currency symbol"
        }
      },
      "required": [
        "invoice_number",
        "invoice_currency",
        "invoice_to",
        "invoice_date",
        "invoice_items",
        "invoice_sub_total",
        "invoice_tax",
        "invoice_total"
      ]
    }
  });
  
  let config = {
    method: 'post',
    maxBodyLength: Infinity,
    url: 'https://api.pdftojson.dev/pdftojson',
    headers: { 
      'x-api-key': 'YOUR_API_KEY', 
      'Content-Type': 'application/json'
    },
    data : data
  };
  
  axios.request(config)
  .then((response) => {
    console.log(JSON.stringify(response.data));
  })
  .catch((error) => {
    console.log(error);
  });
  
<?php

  $curl = curl_init();
  
  curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://api.pdftojson.dev/pdftojson',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS =>'{
      "pdf_url": "https://slicedinvoices.com/pdf/wordpress-pdf-invoice-plugin-sample.pdf",
      "json_schema": {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "properties": {
          "invoice_number": {
              "type": "string",
              "description": "the invoice number or serial no."
          },
          "invoice_currency": {
              "type": "string",
              "description": "the invoice currency, in which currency the invoice is. e.g. INR, EUR, $ etc.",
              "default": "not available"
          },
          "invoice_to": {
              "type": "object",
              "properties": {
                  "name": {
                      "type": "string",
                      "description": "name of the person or company invoice raised to"
                  },
                  "address": {
                      "type": "string",
                      "description": "address of the person or company invoice raised to"
                  },
                  "email": {
                      "type": "string",
                      "description": "email of the person or company invoice raised to"
                  },
                  "phone": {
                      "type": "string",
                      "description": "phone number of the person or company invoice raised to",
                      "default": "not available"
                  }
              },
              "description": "detail of the customer invoice raised to."
          },
          "invoice_date": {
              "type": "string",
              "description": "the invoice date raised on in MM-DD-YY format"
          },
          "invoice_items": {
              "type": "array",
              "items": {
                  "type": "object",
                  "properties": {
                      "name": {
                          "type": "string",
                          "description": "item name"
                      },
                      "quantity": {
                          "type": "number",
                          "description": "item quantity"
                      },
                      "price": {
                          "type": "number",
                          "description": "item price"
                      }
                  },
                  "required": [
                      "name",
                      "quantity",
                      "price"
                  ]
              },
              "description": "all invoice items"
          },
          "invoice_sub_total": {
              "type": "number",
              "description": "the subtotal amount without currency symbol"
          },
          "invoice_tax": {
              "type": "number",
              "description": "tax amount the invoice without currency symbol"
          },
          "invoice_total": {
              "type": "number",
              "description": "the total invoice amount without currency symbol"
          }
      },
      "required": [
          "invoice_number",
          "invoice_currency",
          "invoice_to",
          "invoice_date",
          "invoice_items",
          "invoice_sub_total",
          "invoice_tax",
          "invoice_total"
      ]
  }
  }',
    CURLOPT_HTTPHEADER => array(
      'x-api-key: YOUR_API_KEY',
      'Content-Type: application/json'
    ),
  ));
  
  $response = curl_exec($curl);
  
  curl_close($curl);
  echo $response;