Ruby: OCR Invoices & Receipts in Seconds

3 min read
Ruby: OCR Invoices & Receipts in Seconds

Ruby (the programming language) is a fast and fluid web development language highly recommended if you have particular beef with Python. It was created in 1995 (four years after Python) by a man named Yukihiro “Matz” Matsumoto in Japan after the creator of Python presumably keyed his car. Ruby later rose in popularity between 2010 and 2016, going from a language only used in Japan to a language praised as the Python alternative.

Ruby still stands as the 17th most widely used language in the world, and considering we at Veryfi already made libraries for Go, Java, Python, Javascript, Swift, and C#, it was only a matter of time before we made a library for Ruby too.

Turn-Key 🗝️ Data Extraction

It’s simple. We streamline the process of extracting data from financial documents like receipts, bills, and invoices. We do it all automatically using machines-end-to-end (minus the human piece) and with minimal hassle in seconds.

If you are building an expense management app or a bill pay solution or even wanting to automate your company’s purchasing cycle then Veryfi is your best bet because you can get started in 1 minute without the hassles of setups or model training. How fast you deploy Veryfi is a function of how fast can you develop. Basically, Veryfi is read-to-go out of the box.

Turn a document into data in seconds

{
  "account_number": "1234987650",
  "bill_to": {
    "address": "1234 CUSTOMER AVE\nCLEVELAND OH 44114",
    "name": "JOHN DOE"
  },
  "category": "Job Supplies",
  "created_date": "2020-08-20 01:50:38",
  "currency_code": "USD",
  "date": "2020-08-04 00:00:00",
  "default_category": "Job Supplies",
  "discount": 0,
  "due_date": "2020-08-19",
  "external_id": "",
  "id": 29697870,
  "img_file_name": "92233902-c94a-491d-a4f9-0d61f9407cd2.pdf",
  "img_thumbnail_url": "https://cdn.veryfi.com/receipts/92233902-c94a-491d-a4f9-0d61f9407cd2_t.jpg",
  "img_url": "https://cdn.veryfi.com/receipts/92233902-c94a-491d-a4f9-0d61f9407cd2.pdf",
  "invoice_number": "0998811",
  "line_items": [
    {
      "date": "2020-08-01",
      "description": "2YD FL/MONTH-MSW",
      "discount": 0,
      "id": 25052118,
      "order": 0,
      "price": 116.32,
      "quantity": 1,
      "reference": "",
      "sku": "",
      "tax": 0,
      "tax_rate": 0,
      "total": 116.32,
      "type": "product",
      "unit_of_measure": ""
	...
	...
	...

We use advanced optical and intelligent character recognition in order to extract data fields from receipts and invoice–all in a matter of seconds. It doesn’t matter if it’s a nice, clean PDF or a blurry, shaky photo. With Veryfi, we can process a stack of thousands of invoices and receipts in minutes and save you time and money.
So let’s take a look at how we can process a document with Veryfi’s Ruby SDK

Superpowers in 3 Steps

Step 1

Import Veryfi into your project and create a client object by providing your ID, secret, username, and API key. You can find these all in your Veryfi Hub if you already have an account or you start a free trial.

require 'veryfi' 

veryfi_client = Veryfi::Client.new(
  client_id: 'your_client_id',
  client_secret: 'your_client_secret',
  username: 'your_username',
  api_key: 'your_password'
)

Step 2

Set your parameters for processing. Although you have a bunch of options for customization, we’ll just stick with a basic file path and some categories our invoice might fall under.

params = {
  file_path: './test/invoice.jpg',
  categories: [
    'Advertising & Marketing',
    'Automotive'
  ]
}

Step 3

Send a request through your client object and print out your response.

response = veryfi_client.document.process(params)

puts response

And that’s it!

In just three simple steps we just extracted that JSON object of your document without any hassle or interference on your part.

So don’t waste your time processing financial documents. Sign up for a free trial today!

API Portal Inbox

On hub.veryfi.com, you can also see all the documents that are captured.

Watch Ruby SDK Video

Here’s the video link for the tutorial if you want to see everything in action in a video format. We’re also sharing some tips on how to navigate the hub.veryfi.com to see more detailed results as well as other integrations.

Love ❤️ it?

Any feedback, positive or negative, keeps Veryfi growing and improving! While working with the SDK, you may encounter bugs or issues. If you do, please open an issue on the Veryfi Ruby SDK Github Repository.

Feedback

GitHub issues: if you want to leave public feedback, please open a GitHub issue in the Veryfi Ruby SDK Github 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 support@veryfi.com.

Contributing

You can always make pull requests for new fixes or features to the Veryfi Ruby 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.

Special Thanks!

Thank you Hoanh @ Veryfi for the stellar Ruby write-up.

Test Drive It Now

 
TRY VERYFI NOW FOR FREE
14 day free trial. No credit card required.