Ruby OCR SDK
Mindee API Helper Library for Ruby
Quickly and easily connect to Mindee's API services using Ruby.
Requirements
The following Ruby versions are tested and supported: 2.6, 2.7, 3.0, 3.1, 3.2
Quick Start
Here's the TL;DR of getting started.
First, get an API Key
Install by adding this line to your application's Gemfile:
gem 'mindee'
And then execute:
bundle install
Finally, Ruby away!
Loading a File and Parsing It
Global Documents
require 'mindee'
# Init a new client
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
# Load a file from disk
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
result = mindee_client.parse(
input_source,
Mindee::Product::Invoice::InvoiceV4
)
# Print a full summary of the parsed data in RST format
puts result.document
Note: Files can also be loaded from:
A URL (https
):
input_source = mindee_client.source_from_url("https://my-url")
A bytes input stream:
input_source = mindee_client.source_from_bytes('/path/to/the/file.ext', "name-of-my-file.ext")
A base64 encoded string:
input_source = mindee_client.source_from_b64string('/path/to/the/file.ext', "name-of-my-file.ext")
A ruby file
object:
input_source = mindee_client.source_from_file(input_file, "name-of-my-file.ext")
Region-Specific Documents
require 'mindee'
# Init a new client
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
# Load a file from disk
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
result = mindee_client.parse(
input_source,
Mindee::Product::EU::LicensePlate::LicensePlateV1
)
# Print a full summary of the parsed data in RST format
puts result.document
Custom Document (API Builder)
require 'mindee'
# Init a new client and configure your custom document
mindee_client = Mindee::Client.new(api_key: 'my-api-key')
endpoint = mindee_client.create_endpoint(
endpoint_name: 'my-endpoint',
account_name: 'my-account'
)
# Load a file from disk
input_source = mindee_client.source_from_path('/path/to/the/file.ext')
result = mindee_client.parse(
input_source,
Mindee::Product::Custom::CustomV1,
endpoint: endpoint
)
# Print a full summary of the parsed data in RST format
puts result.document
# Looping over all prediction values
result.document.inference.prediction.fields.each do |field_name, field_data|
puts field_name
puts field_data.values
puts field_data.to_s
end
CLI Tool
A command-line interface tool is available to quickly test documents:
ruby ./bin/mindee.rb invoice path/to/your/file.ext
Using the ruby bundler:
bundle exec ruby ./bin/mindee.rb invoice path/to/your/file.ext
Further Reading
There's more to it than that for those that need more features, or want to
customize the experience.
- Ruby Overview
- Custom OCR Ruby
- Invoice OCR Ruby
- Financial Document OCR Ruby
- Passport OCR Ruby
- Proof of Address OCR Ruby
- Receipt OCR Ruby
- EU License Plate OCR Ruby
- FR Bank Account Details OCR Ruby
- FR Carte Vitale OCR Ruby
- FR ID Card OCR Ruby
- US Bank Check OCR Ruby
- US Driver License OCR Ruby
- US W9 API Ruby
- Barcode Reader API Ruby
- Cropper API Ruby
- Invoice Splitter API Ruby
- Multi Receipts Detector API Ruby
You can also take a look at the
Reference Documentation.
License
Copyright © Mindee, SA
Available as open source under the terms of the MIT License.
Questions?
Updated 11 days ago