In this tutorial, we will show you how to extract data from invoice in Python using PDF.co Web API.
- Install Request Module
- Save Files in Folder
- Add API Key
- Image and Output File Name
- Add Template File
- Run Program
- Parser Demo
Here are the sample image Source File, Template File, and JSON output for invoice data extraction using Python.
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 requestsin 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.
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).
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.
Step 6: Run Program
- Once invoice data extraction using Python runs successfully. Check the Python program folder to view the output.
Step 7: Parser Demo
- Here’s the Document Parser Web API in action. It is extracting data from invoices using Python.
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.