Node.js SDK: OCR Invoices & Receipts in Seconds

July 13, 2021
5 mins read
Node.js SDK: OCR Invoices & Receipts in Seconds

    When it comes to real-time data extraction, Veryfi has you covered. Just upload a photo or file through the Veryfi Node.js SDK, and you can extract the data in real-time.

    Let’s take a look at what Veryfi offers you.

    Real-Time Processing

    Veryfi offers you a real-time solution to capture data from invoices and receipts. That means there’s no need to sit there twiddling your thumbs for however long it takes to get your data back using traditional methods.

    Veryfi offers you a near-instant response when you want a file parsed using Veryfi Node.js SDK. You just need to upload a file, and you’ll receive your data within seconds. Not minutes, not hours, and definitely not days (prehistoric times).

    OCR, ICR, and Interpretation

    OCR stands for Optical Character Recognition. When you run a document through an OCR program, it gives you raw, unstructured text. Today, there are plenty of OCR options like Tesseract or Google Vision. When it comes to printed text, OCR may shine, but it’s still incomplete.

    ICR, or Intelligent Character Recognition is an advanced OCR that incorporates machine learning and understands not only printed text, but also everything from handwriting, to different languages, fonts, and styles. ICR is so advanced that in many cases, it’s more accurate than even manual data entry by humans.

    Indeed, when it comes to AI, reading the text is the least of your worries when parsing a receipt or invoice using the Veryfi Node.js SDK. The true difficulty comes when an AI needs to understand what each field represents on a document.

    Fortunately, we have a solution to that.

    It’s Not Templates…

    Many applications use template-based data extraction in order to automatically process data. This solution works well for standardized forms which reliably have the same format and layout every single time; passports and driver licenses fall into this category.

    However, the issue with receipts and invoices is that there is absolutely no standardization whatsoever. Just look up “invoice template” online, and you’re sure to see thousands–or even millions–of results from that single search. If you decided to sit down and make templates for every single layout of every possible invoice or receipt out there, well–not even Sisyphus would envy you. So what’s the solution?

    Thankfully, Veryfi has you covered by pushing your unstructured ICR text through another model to interpret it. As a result, Veryfi can deliver a set of correctly categorized items along with their positions on a document.

    Real-time API for Data Extraction, without Templates!

    Veryfi offers you real-time data extraction in your Node.js application. When it comes to invoices and receipts, Veryfi can extract up to 50 different fields of data and has embedded ICR, meaning language and handwritten text poses no challenge.

    Let’s walk through setting up a project with Veryfi, and then process an invoice. This tutorial uses npm as an example, so we’ll assume you have Node.js and npm installed.

    First, you’ll want to install the Veryfi Node.js SDK into your working environment. Run this inside your console/shell:

    npm install @veryfi/veryfi-sdk

    Second, register on the Veryfi website in order to get your access tokens. You will be given a client-id, client-secret, username, and API-key to access the API.

    Once you have those credentials, instantiate your Veryfi client and add them in like so:

    let Client  = require(‘@veryfi/veryfi-sdk’);
    # get your keys here:
    const client_id = 'your_client_id';
    const client_secret = 'your_client_secret';
    const username = 'your_username';
    const api_key = 'your_password';
    let my_client = Client(client_id, client_secret, username, api_key);

    Third and finally, add these three lines to your Node.js project. This code will parse an invoice or receipt and print the returned JSON object with all the extracted information:

    let file_path = ‘document.pdf’;
    let response = async() => await my_client.process_document(file_path);

    process_document() is an asynchronous call that will return your data in 3-5 seconds for a single-page document. Additional pages may take 1-2 seconds per extra page.

    Of note:

    1. Veryfi can process various document formats, including: jpg, png, pdf, tiff, html, docx.

    2. Veryfi can categorize your document. Include a list of categories, and Veryfi will pick the one best suited for the file. For example, if you send a plane ticket receipt and your list of categories is [“Travel”, “Meals”, “Maintenance”], Veryfi will categorize the receipt as “Travel.”

    3. Is your application written in something other than Javascript? No matter! Veryfi has SDKs for Python and Go. Additionally, you can see other code examples written in Java, PHP, and cURL. You will also find a PostMan collection.

    Included below is the response once your document has been processed:

      "abn_number": "",
      "account_number": "",
      "bill_to_address": "130 INTERSTATE BLVD, SUIT 21\nNASHEVILLE, NC 28806",
      "bill_to_name": "FAST ROOFING COMPANY, LLC",
      "card_number": "",
      "category": "Hardware Supplies",
      "currency_code": "USD",
      "date": "2019-08-01 00:00:00",
      "due_date": "2019-09-01",
      "discount": 0,
      "external_id": "",
      "id": 28933541012,
      "img_thumbnail_url": "",
      "img_url": "",
      "invoice_number": "1234568",
      "line_items": [
          "date": "",
          "description": "SFTY TAGS LCKED OUT 250BX 426NS",
          "discount": 0,
          "order": 1,
          "price": 200.0,
          "quantity": 1,
          "reference": "",
          "sku": "PTW-901444",
          "tax": 0,
          "tax_rate": 0,
          "total": 200.00,
          "type": "purchase",
          "unit_of_measure": "pc"
          "date": "",
          "description": "WEDGE ANCHOR. PLATED",
          "discount": 0,
          "order": 2,
          "price": 3.75,
          "quantity": 100,
          "reference": "",
          "sku": "WA-12-414",
          "tax": 0,
          "tax_rate": 0,
          "total": 375.00,
          "unit_of_measure": "pc"
          "date": "",
          "description": "SYP #2 KD-HT UNTREATED",
          "discount": 0,
          "order": 9,
          "price": 11.49,
          "quantity": 1,
          "reference": "",
          "sku": "WE-27517",
          "tax": 0,
          "tax_rate": 0,
          "total": 11.49,
          "unit_of_measure": "pc"
      "ocr_text": "\nACE\nThe helpful place.\nAce Hardware\t\t\t\t\t\tINVOICE\n5726.....",
      "payment_display_name": "",
      "payment_terms": "",
      "payment_type": "",
      "purchase_order_number": "",
      "reference_number": "VBAJD-32541",
      "shipping": 0,
      "subtotal": 586.49,
      "tax": 41.05,
      "tax_lines": [{
        "name": "state tax",
        "rate": 7.0,
        "total": 41.05
      "tip": 0,
      "total": 627.54,
      "vat_number": "",
      "vendor": {
        "address": "5726 Memorial Blvd, Saint George, SC 29477",
        "name": "Hutto Ace Hardware",
        "raw_name": "Ace Hardware",
        "phone_number": "(843) 563-4012",
        "vendor_logo": "",
        "vendor_type": "hardware stores"
      "vendor_vat_number":  "",
      "vendor_iban":  "",
      "vendor_bank_number":  "", 
      "vendor_bank_name": ""


    GitHub issues: if you want to leave public feedback, please open a GitHub issue in the Veryfi Node.JS Repository. Doing so may also help any other users experiencing the same problem and grow the conversation. We make sure to evaluate issues on our end too, so we can address them in future releases.

    Contact us: If you want to speak with our team privately to ask questions, give feedback, or make a feature request, please email us at


    You can always make pull requests for new fixes or features to the Veryfi Node.js SDK. Please ensure your requests are made under the MIT license. Our team also reviews any requests before they’re merged, so unit tests are gladly accepted.