Quickstart
Learn how to use the Document AI API to process a document.
In this example, we’ll learn how to apply optical character recognition (OCR) to an invoice document.
Prerequisites
You will need:
- An ABBYY developer account
- An API key
- If using Python SDK: Python v3.8+
- If using TypeScript SDK: ES2018+, Node.js active and maintenance LTS releases (currently, v18 and v20), Bun v1+, Deno v1.39+
- An invoice document to process (or use one of ours!)
Create a developer account to get access to the API. It’s free to get started. After signing up, navigate to the API Keys page and create an API key.
Document to process
If you have an invoice handy, feel free to try it out with this Quickstart. Otherwise, we’ll use this Canadian invoice hosted on GitHub.
Install the SDK
While you can call the API directly, the Document AI API provides SDKs for several popular programming languages. If you don’t have a project already, create one:
Next, install the Document AI API SDK:
Call the API
Call the API using the documents/invoice
endpoint. Provide the path to the invoice file to process (or use the one we’ve provided) and insert your API key into the Authorization
header.
Run the code using python3 docai.py
or node docai.ts
. The API will respond with a document id
that we’ll need in the next step.
Retrieve the Results
The Document AI API begins processing the invoice immediately on submission. To retrieve the results, we make one more API call to /documents/invoice/[document-id]
. Fill in the document-id
using the id
from the previous API call. The API’s processing time varies based on a variety of factors including number of document pages, so we’ll keep attempting to retrieve the extracted fields every few seconds until the API’s status returns Processed
.
Success! We now have all the fields from the invoice document:
Complete Code
Here’s the complete code for reference.
Next Steps
Now that you’ve made your first Document AI API request, it’s time to explore what else is possible.
Explore the Models
Review all document models and their capabilities for extracting data
Try our API
Learn how to use the Document AI API to process documents programmatically
Join the Community
Exchange ideas, get expert guidance, and enhance your OCR, IDP, and AI implementations
Was this page helpful?