In this tutorial, we will show you how to extract data from invoice in Python using PDF.co Web API.

  1. Install Request Module
  2. Save Files in Folder
  3. Add API Key
  4. Image and Output File Name
  5. Add Template File
  6. Run Program
  7. Parser Demo

Here are the sample image Source File, Template File, and JSON output for invoice data extraction using Python.

Source File, Template, and JSON Output
Source File, Template, and JSON Output

Step 1: Install Request Module

So, let’s start Python invoice extraction step by step.

  • First, install the requests module. Type the python -m pip install requests in your command line and press enter to install the pip requests.

Step 2: Save Files in Folder

  • Next, save the files in the Python program folder. You can copy the Python sample code at this link.

Step 3: Add API Key

  • In the Python sample code, go to line 6 and add your PDF.co API Key. You can get the API Key in your PDF.co dashboard here.

Add API Key

Step 4: Image and Output File Name

  • In lines 12 and 15, add the Image File name and type the JSON file name output. You can also use other output formats such as XML, CSV, and JSON (custom template code).

Image and Output File Name

Step 5: Add Template File

  • In line 20, add the template file name. Then, click this link to create a new template using the Document Parser Template Editor. Check out this tutorial on how to create a new template.

Add Template File

Step 6: Run Program

  • Once invoice data extraction using Python runs successfully. Check the Python program folder to view the output.

Run Program

Step 7: Parser Demo

  • Here’s the Document Parser Web API in action. It is extracting data from invoices using Python.
PDF.co Document Parser Demo
PDF.co Document Parser Demo

In this tutorial, you learned how to extract data from invoices in Python using the PDF.co Web API. You learned how to install the requests module. You learned how to use the PDF.co Document Parser Web API to parse invoice data. You also learned how to use the Document Parser Template Editor to create a new template.

Related Pages:

Related Samples: