Extracting invoices using AI in a few lines of code

Extracting information from invoices is hard since no invoice is like each other. People mostly spend time doing it by hand. In big companies they try to set up software with templates and struggle to handle so many corner cases.

At Rossum we train state-of-the-art neural networks to extract data successfully from previously unseen invoices. So far we’ve offered Elis, a web application product suitable for big companies. Now it’s time to democratize this powerful technology and give it to hands of developers.

No matter if you build a mobile app for tracking finances and want to import invoices via phone camera, or you’re a student helping your mom accountant avoid typing a stack of invoices on weekends, you can save a lot of tedious work with Elis Extraction API.

The first step is to obtain an API key. You can sign-up (using Google/GitHub account or by email) at https://rossum.ai/developers. It’s free for up to 300 invoices per month (with no billing details required).

The easiest way to use it is with Python package rossum. You can just invoke it from command line or from your Python scripts. There are examples for several other popular languages (JavaScript, PHP, Java, C#, etc.).

Thanks to Asciinema you can watch a screencast (shown at above) of example how it works on a real invoice I found in my mailbox (btw: Soma FM is a good independent radio I’ve been listening to for years). Also shown in the gist below:

Basically you just install the package, set your own API key (you don’t want to share your submissions), submit your invoice (PDF or scan in PNG/JPEG) and wait for it being processed by the Elis Extraction API on Rossum’s servers (usually less than a minute). The extracted fields are saved to a JSON file and you can quickly check the results in the output table and a web preview. Details of the API, the data format and the field types are available in the documentation. The percentages in the parentheses represent how certain the prediction is.

Each extracted field contains a lot of useful information.

You can easily integrate it with your own code. The basic Python API is straightforward. You can extract and invoice and store the JSON file:

Also you can take the extracted data (JSON parsed to a dict, see an example) and process it right away. What about computing a table of the extracted fields and their values (for a simple invoice with not nested fields)? Just a few lines with pandas:

Fortunately there’s an easy way to print the extracted fields already included in the package. Below is an example with more complex invoice with tax breakdown. Note that the service detects the language and currency, even though it has never seen this document before.

Now it’s only up to our imagination what we can do with that. Let’s allow people spend time better than typing numbers from paper to computer. Enjoy!

Resources:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade