> For the complete documentation index, see [llms.txt](https://docs.mindee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mindee.com/v1/integration/dotnet-ocr-sdk.md).

# .NET OCR SDK

## 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](/v1/get-started/create-api-key.md)

Then, install this library:

```shell
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:

```csharp
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`:

```csharp
using Mindee;

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

#### Loading a File and Parsing It

**Global Documents**

```csharp
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**

```csharp
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)**

```csharp
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

You can view the source code on [GitHub](https://github.com/mindee/mindee-api-dotnet).

You can also take a look at the [**Reference Documentation**](https://mindee.github.io/mindee-api-dotnet/).

### License

Copyright © Mindee

Available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mindee.com/v1/integration/dotnet-ocr-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
