Giter Site home page Giter Site logo

mindee-api-dotnet's Introduction

License: MIT GitHub Workflow Status NuGet NuGet

Mindee API Helper Library for .NET

Quickly and easily connect to Mindee's API services using .NET.

Requirements

The following .NET versions are tested and officially supported:

  • Standard 2.0
  • 4.7.2, 4.8 (Windows only)
  • 6.0, 7.0, 8.0 (Linux, macOS x64, Windows)

Quick Start

Here's the TL;DR of getting started.

First, get an API Key

Then, install this library:

dotnet add package Mindee

Define the API Key

The API key is retrieved using IConfiguration.

So you could define it in multiple ways:

  • From an environment variable
Mindee__ApiKey
  • From an appsettings.json file
"Mindee": {
    "ApiKey":  "my-api-key"
},

Instantiate The Client

You can instantiate the client either manually or by using dependency injection.

Dependency Injection

In your Startup.cs or Program.cs file, configure the dependency injection (DI) as follows:

services.AddMindeeClient();

This call will configure the client entry point and the PDF library used internally.

Then, in your controller or service instance, pass as an argument the class MindeeClient.

Manually

Or, you could also simply instantiate a new instance of MindeeClient:

using Mindee;

MindeeClient mindeeClient = new MindeeClient("my-api-key");

Loading a File and Parsing It

Global Documents

using Mindee;
using Mindee.Input;
using Mindee.Product.Invoice;

string apiKey = "my-api-key";
string filePath = "/path/to/the/file.ext";

// Construct a new client
MindeeClient mindeeClient = new MindeeClient(apiKey);

// Load an input source as a path string
// Other input types can be used, as mentioned in the docs
var inputSource = new LocalInputSource(filePath);

// Call the API and parse the input
var response = await mindeeClient
    .ParseAsync<InvoiceV4>(inputSource);

// Print a summary of the predictions
System.Console.WriteLine(response.Document.ToString());

// Print the document-level predictions
// System.Console.WriteLine(response.Document.Inference.Prediction.ToString());

Region-Specific Documents

using Mindee;
using Mindee.Input;
using Mindee.Product.Us.BankCheck;

string apiKey = "my-api-key";
string filePath = "/path/to/the/file.ext";

MindeeClient mindeeClient = new MindeeClient(apiKey);

// Load an input source as a path string
// Other input types can be used, as mentioned in the docs
var inputSource = new LocalInputSource(filePath);

// Call the API and parse the input
var response = await mindeeClient
    .ParseAsync<BankCheckV1>(inputSource);

// Print a summary of the predictions
System.Console.WriteLine(response.Document.ToString());

// Print the document-level predictions
// System.Console.WriteLine(response.Document.Inference.Prediction.ToString());

Custom Document (API Builder)

using Mindee;
using Mindee.Http;
using Mindee.Parsing;

string apiKey = "my-api-key";
string filePath = "/path/to/the/file.ext";

MindeeClient mindeeClient = new MindeeClient(apiKey);

// Load an input source as a path string
// Other input types can be used, as mentioned in the docs
var inputSource = new LocalInputSource(filePath);

// Set the endpoint configuration 
CustomEndpoint myEndpoint = new CustomEndpoint(
    endpointName: "my-endpoint",
    accountName: "my-account"
    // optionally, lock the version
    //, version: "1.1"
);

// Call the API and parse the input
var response = await mindeeClient.ParseAsync(
    inputSource, myEndpoint);

// Print a summary of all the predictions
System.Console.WriteLine(response.Document.ToString());

// Print a summary of the predictions
System.Console.WriteLine(response.Document.ToString());

// Print the document-level predictions
// System.Console.WriteLine(response.Document.Inference.Prediction.ToString());

Further Reading

Complete details on the working of the library are available in the following guides:

You can view the source code on GitHub.

You can also take a look at the Reference Documentation.

License

Copyright © Mindee

Available as open source under the terms of the MIT License.

Questions?

Join our Slack

mindee-api-dotnet's People

Contributors

dependabot[bot] avatar ianardee avatar kjbtech avatar kvindee avatar sebastianmindee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mindee-api-dotnet's Issues

Add French ID card API support

Add support for French ID cards:

  • Based on documentation found here
  • Should be callable from the client.
  • Should be callable from CLI tool.
  • No extra verification / processing to be done (we can add mrz and fullName fields later if need be)

Add shipping container support

Add support for Shipping Container:

  • Based on documentation found here
  • Should be callable by passing ShippingContainerV1
  • Should be callable from CLI tool with the command shipping-container
  • No extra verification / processing to be done

Expose a parsing method which is generic for all prediction features from Mindee API

It should not expose a method for every "parse" possibility but only expected the class type of the response.

In that case, we should prevent the use of magic string in the call or in the method parameter.
So, we must define the version and the path of the Mindee API as a property of the class object to be use ext by the HTTP Client at least.

Add FR carte vitale support

Add support for French social security card:

  • Based on documentation found here
  • Should be callable from the client by passing CarteVitaleV1
  • Should be callable from CLI tool with the command fr-carte-vitale
  • No extra verification / processing to be done

Refacto

The architecture of the code must follow what was done on Node.JS, Python or JAVA SDK.

Get rid of the clean architecture.

Improve string output of objects

Can print at each level or node of the structure.

Output should be valid reStructuredText.

At highest level (.document):

####################
mindee/invoices v4.0
####################
:Filename: file.ext
:Rotation applied: Yes <== is_rotation_applied

==========
Prediction
==========
:Invoice date: 2020-02-17
:Invoice due date: 2020-02-17
:Supplier name: TURNPIKE DESIGNS CO.

================
Page Predictions
================

-------
Page 01
-------
:Orientation: 0 <== only on page level
:Invoice date: 2020-02-17
:Invoice due date: 2020-02-17
:Supplier name: TURNPIKE DESIGNS CO.

And, for example, at .document.inference.page[0]:

-------
Page 01
-------
:Orientation: 0 <== only on page level
:Invoice date: 2020-02-17
:Invoice due date: 2020-02-17
:Supplier name: TURNPIKE DESIGNS CO.

Add Cropper support

Add support for the 2 possible modes for cropper.

Parameter Mode

Add a cropper option passed to the ParseAsync method.

Use this example;
https://github.com/mindee/client-lib-test-data/blob/main/receipt/response_v4/complete_with_cropper.json

Results should be added to the Page base class as they apply to all endpoints.

Endpoint Mode

A dedicated endpoint / document for cropper.

Use this example:
https://github.com/mindee/client-lib-test-data/blob/main/cropper/response_v1/complete.json

Results should be stored in a new CropperV1Prediction class, but only at the page level.

Document-level prediction is always empty.

Documentation

  • On the code
  • On the repository
  • On readme
  • Generate MD documentation from XML doc in .NET

OTS API have to be versionned

As we see with the SDK teams, add the version in the namespace of the model.
Then used the EndpointAttribute to handle the different version number

Allow changing base URL using an envvar

Allow setting MINDEE_BASE_URL environment variable to change the base URL for all requests.

For example:

export MINDEE_BASE_URL=https://infergate.staging-xsdj4gia.mindee.net/v1

Add tests for string output of predictions

Add unit tests for all APIs that check the output of the ToString function against the corresponding doc_to_string.txt file.

Since all predictions have this function and associated file, it should be possible to create a generic or helper function for this.
At your discretion of course.

Add EU licence plate support

Add support for EU licence plate:

  • Based on documentation found here
  • Only available for EU
  • Should be callable by passing LicensePlateV1
  • Should be callable from CLI tool with command eu-license-plate
  • No extra verification / processing to be done

Configuration to publish on Nuget

We need a hotmail or live address to publish on Nuget.org.

We also could ask a prefix reservation on Mindee.* in order to prevent any user to publish package with this name and subname.
See https://learn.microsoft.com/en-us/nuget/nuget-org/id-prefix-reservation#id-prefix-reservation-application-process

Add Invoice v4

Add invoice V4 support as described in the test data.

Allow changing base URL using an envvar

Allow setting MINDEE_BASE_URL environment variable to change the base URL for all requests.

For example:

export MINDEE_BASE_URL=https://infergate.staging-xsdj4gia.mindee.net/v1

Add US bank check support

Add support for US bank checks:

  • Based on documentation found here
  • Should be callable from the client.
  • Should be callable from CLI tool.
  • No extra verification / processing to be done

Provide sample code for platform docs

Provide 3 complete sample codes for

  • OTS
  • custom
  • OTS not officially supported in lib

Should be cut-pastable and just work ;-)

Needs to be compatible with .NET 4.7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.