C# SDK: OCR Invoices & Receipts in Seconds

4 min read
Code with Matt C# SDK

As many of you know, the process of programming can be both very rewarding and very painful, and it’s no secret the same applies to automation. It seems like for every person who shouts “Eureka! I’ve got it,” there are thousands more shouting “I swear, if I spend another six hours performing gradient descent, my computer’s gonna be performing a gradient descent into the office parking lot.”

Luckily for you, Veryfi did that work for you. After plenty of blood, sweat, and complaints from parking management, we have automated the arduous task of financial document processing.

If you’ve ever had the misfortune of working in data entry (my condolences), rest assured you can relax and take a deep breath. Now it’s time for the future. Veryfi allows you to process financial documents in the blink of an eye with our easily integrated toolkit.

The Problem

Before we begin, I’d like to start with a brief exercise. Imagine a huge stack of documents, invoices, and receipts sitting on your desk, waiting for you to record them for bookkeeping. Imagine picking up the top invoice, skimming it, and entering the vendor information, line items, total amount, and so on and so forth. Now imagine yourself doing this again for a thousand more files.

Imagine yourself coming home, too tired to interact with your family (who are growing increasingly distant) because your job entails twelve hours of logging documents, and your last fun memory was seeing Prince perform live.

But let’s forget that because we have a solution!

Instead of suffering through a lifetime of soul-crushing work and the ensuing messy divorce afterward, we have something you could use to prevent all that. Forget about reading and entering files one by one! Now you can just upload them to Veryfi, and let our machines process that stack of documents in the blink of an eye.

Thanks to Veryfi, your data can be extracted from financial documents in literal seconds. Plus, you don’t have to worry about sitting there, keeping it going like an overly complex Heath Robinson machine. You can just let Veryfi run and take a long lunch because it will automatically upload, process, and return all that data for every document you feed it. Another bonus is that you don’t have to manually specify what fields mean what in each file. Veryfi takes care of all that work for you and returns a JSON object you can use however you’d like.

A Sample Project

Below, we’ll be showing you a basic C# project you can test out right now using Veryfi’s document parsing and upload system.

Of course, if C# isn’t your cup of tea, we have plenty of integrations for other languages. Here’s a short list with many more to come!

Step One:

Install and import Veryfi into your project and create a new HttpClient.

using Veryfi;
using var client = new HttpClient();

Step Two:

Next, you’ll need some Veryfi API credentials. Go to the Veryfi website and either register for an account or begin a free trial. Once you log in, go to Settings, then Keys. Then copy-paste your API parameters into your project like so:

var username = "YOUR_VERYFI_USERNAME";
var apiKey = "YOUR_API_KEY";
var clientId = "YOUR_CLIENT_ID";

Step Three:

Import the Veryfi SDK into your project, and create something called a Client object with those parameters and an HTTP client. This object is how your program will send and receive requests to and from Veryfi.

var api = new VeryfiApi("username", "apiKey", "clientId", client);

Step Four:

Next, call the process document function below and include the name of the file you’re processing, along with its data as a Base64 encoded string.

var document = await api.ProcessDocumentAsync(
   new DocumentUploadOptions {
       File_name = "fileName.jpg",
       File_data = Convert.ToBase64String(bytes),
   });

Now you’re done!

From here, you can access your document info as you would any regular JSON object. If you’re looking for specific field names, you can always view your document in the Veryfi inbox. There’s a list of fields and values included, along with a JSON representation of the data.

Plus, if you want more customizability, you can modify the function to loop through a folder containing all your files instead of just choosing one, upload documents using their URLs, and do much more.


In just four steps, we’ve saved you time, energy, and a happy relationship with your family that would’ve been ruined had you spent your life copying numbers into Excel spreadsheets.

You’re very welcome.

 

Feedback and Contributing

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 Go SDK Github Repository.

Feedback

GitHub issues: if you want to leave public feedback, please open a GitHub issue in the Veryfi C# 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 Go 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 Matt Eng @ Veryfi for the stellar C# write-up.

TRY VERYFI FOR FREE

Try It Now

Drop an invoice or receipt into the form below and watch how in seconds Veryfi extracts a goldmine of data.

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