# Quick Start

## Installation Instructions

{% tabs %}
{% tab title="Python" %}
Requires Python ≥ 3.9.\
Python ≥ 3.11 is highly recommended.

Simply install the [PyPi package](https://pypi.org/project/mindee/) using pip:

```sh
pip install -U mindee~=4.35
```

{% endtab %}

{% tab title="Node.js" %}
Requires Node.js ≥ 20.\
Node.js ≥ 22 is recommended.

Simply install the [NPM package](https://www.npmjs.com/package/mindee):

```sh
npm install mindee@^5.1.1
```

{% endtab %}

{% tab title="PHP" %}
Requires PHP ≥ 8.1.\
PHP ≥ 8.3 is recommended.

Simply install the [Packagist package](https://packagist.org/packages/mindee/mindee) using [composer](https://getcomposer.org/):

```sh
php composer.phar require "mindee/mindee:>=2.7"
```

{% endtab %}

{% tab title="Ruby" %}
Requires Ruby ≥ 3.0.\
Simply install the [gem](https://rubygems.org/gems/mindee) using:

```shell
gem install mindee -v '~> 4.13'
```

{% endtab %}

{% tab title="Java" %}
Requires Java ≥ 11.\
Java ≥ 17 is recommended.

Group ID: `com.mindee.sdk`\
Artifact ID: `mindee-api-java`\
Version: ![](https://img.shields.io/maven-central/v/com.mindee.sdk/mindee-api-java?style=flat-square\&label=%20)

There are various installation methods, Maven, Gradle, etc:

[Installation Details](https://central.sonatype.com/artifact/com.mindee.sdk/mindee-api-java)
{% endtab %}

{% tab title=".NET" %}
.NET ≥ 8.0 is recommended.

Simply install the [NuGet package](https://www.nuget.org/packages/Mindee) using .NET CLI:

```sh
dotnet add package Mindee --version 4.0
```

{% endtab %}
{% endtabs %}

Don't see support for your favorite language or framework? [Make a feature request!](https://feedback.mindee.com/?b=682f69c9e2404756e7e68d1c)

## Send a File and Poll

Make a note of your model's ID for use in the API.

When getting started, we recommend using the polling method which will be quickest (unless you happen to already have access to a public-facing Web server).

Here are basic code examples, these are self-contained and can be run as-is:

{% tabs %}
{% tab title="Python" %}
Requires Python ≥ 3.9. Python ≥ 3.10 is highly recommended.\
Requires the [Mindee Python client library](https://pypi.org/project/mindee/) version **4.35.1** or greater.

{% code lineNumbers="true" %}

```python
from mindee import (
    ClientV2,
    InferenceParameters,
    InferenceResponse,
    PathInput,
)

input_path = "/path/to/the/file.ext"
api_key = "MY_API_KEY"
model_id = "MY_MODEL_ID"

# Init a new client
mindee_client = ClientV2(api_key)

# Set inference parameters
params = InferenceParameters(
    # ID of the model, required.
    model_id=model_id,

    # Options: set to `True` or `False` to override defaults

    # Enhance extraction accuracy with Retrieval-Augmented Generation.
    rag=None,
    # Extract the full text content from the document as strings.
    raw_text=None,
    # Calculate bounding box polygons for all fields.
    polygon=None,
    # Boost the precision and accuracy of all extractions.
    # Calculate confidence scores for all fields.
    confidence=None,
)

# Load a file from disk
input_source = PathInput(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
    InferenceResponse,
    input_source,
    params,
)

# Print a brief summary of the parsed data
print(response.inference)

# Access the result fields
fields: dict = response.inference.result.fields
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}

{% tab title="Node.js" %}
Requires Node.js ≥ 20. Node.js ≥ 22 is recommended.\
Requires the [Mindee Node.js client library](https://www.npmjs.com/package/mindee/) version **5.1.0** or greater.

{% code lineNumbers="true" %}

```javascript
import * as mindee from "mindee";
// If you're on CommonJS:
// const mindee = require("mindee");

const apiKey = "MY_API_KEY";
const filePath = "/path/to/the/file.ext";
const modelId = "MY_MODEL_ID";

// Init a new client
const mindeeClient = new mindee.Client(
  { apiKey: apiKey }
);

// Set product parameters
const productParams = {
  modelId: modelId,

  // Options: set to `true` or `false` to override defaults

  // Enhance extraction accuracy with Retrieval-Augmented Generation.
  rag: undefined,
  // Extract the full text content from the document as strings.
  rawText: undefined,
  // Calculate bounding box polygons for all fields.
  polygon: undefined,
  // Boost the precision and accuracy of all extractions.
  // Calculate confidence scores for all fields.
  confidence: undefined,
};

// Load a file from disk
const inputSource = new mindee.PathInput({ inputPath: filePath });

// Send for processing
const response = await mindeeClient.enqueueAndGetResult(
  mindee.product.Extraction,
  inputSource,
  productParams,
);

// print a string summary
console.log(response.inference.toString());

// Access the result fields
const fields = response.inference.result.fields;
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}

{% tab title="PHP" %}
Requires PHP ≥ 8.1\
Requires the [Mindee PHP client library](https://packagist.org/packages/mindee/mindee) version **2.7.1** or greater.

{% code lineNumbers="true" %}

```php
<?php

use Mindee\ClientV2;
use Mindee\Input\InferenceParameters;
use Mindee\Input\PathInput;

$apiKey = "MY_API_KEY";
$filePath = "/path/to/the/file.ext";
$modelId = "MY_MODEL_ID";

// Init a new client
$mindeeClient = new ClientV2($apiKey);

// Set inference parameters
$inferenceParams = new InferenceParameters(
    // ID of the model, required.
    $modelId,

    // Options: set to `true` or `false` to override defaults

    // Enhance extraction accuracy with Retrieval-Augmented Generation.
    rag: null,
    // Extract the full text content from the document as strings.
    rawText: null,
    // Calculate bounding box polygons for all fields.
    polygon: null,
    // Boost the precision and accuracy of all extractions.
    // Calculate confidence scores for all fields.
    confidence: null
);

// Load a file from disk
$inputSource = new PathInput($filePath);

// Send for processing using polling
$response = $mindeeClient->enqueueAndGetResult(
    $inputSource,
    $inferenceParams
);

// Print a summary of the response
echo strval($response->inference);

// Access the result fields
$fields = $response->inference->result->fields;
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}

{% tab title="Ruby" %}
Requires Ruby ≥ 3.0.\
Requires the [Mindee Ruby client library](https://rubygems.org/gems/mindee) version **4.13.0** or greater.

{% code lineNumbers="true" %}

```ruby
require 'mindee'
require 'mindee/v2/product'

input_path = '/path/to/the/file.ext'
api_key = 'MY_API_KEY'
model_id = 'MY_MODEL_ID'

# Init a new client
mindee_client = Mindee::ClientV2.new(api_key: api_key)

# Set inference parameters
inference_params = {
    # ID of the model, required.
    model_id: model_id,

    # Options: set to `true` or `false` to override defaults

    # Enhance extraction accuracy with Retrieval-Augmented Generation.
    rag: nil,
    # Extract the full text content from the document as strings.
    raw_text: nil,
    # Calculate bounding box polygons for all fields.
    polygon: nil,
    # Boost the precision and accuracy of all extractions.
    # Calculate confidence scores for all fields.
    confidence: nil
}

# Load a file from disk
input_source = Mindee::Input::Source::PathInputSource.new(input_path)

# Send for processing
response = mindee_client.enqueue_and_get_result(
    Mindee::V2::Product::Extraction::Extraction,
    input_source,
    inference_params
)

# Print a brief summary of the parsed data
puts response.inference

# fields.get_simple_field('my_field')
# fields.get_list_field('my_field')
# fields.get_object_field('my_field')
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}

{% tab title="Java" %}
Requires Java ≥ 8. Java ≥ 11 recommended.\
Requires the [Mindee Java client library](https://central.sonatype.com/artifact/com.mindee.sdk/mindee-api-java) version **4.43.0** or greater.

{% code lineNumbers="true" %}

```java
import com.mindee.MindeeClientV2;
import com.mindee.InferenceParameters;
import com.mindee.input.LocalInputSource;
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;
import java.io.IOException;

public class SimpleMindeeClientV2 {

  public static void main(String[] args)
      throws IOException, InterruptedException
  {
    String apiKey = "MY_API_KEY";
    String filePath = "/path/to/the/file.ext";
    String modelId = "MY_MODEL_ID";

    // Init a new client
    MindeeClientV2 mindeeClient = new MindeeClientV2(apiKey);

    // Set inference parameters
    InferenceParameters extractionParams = InferenceParameters
        // ID of the model, required.
        .builder(modelId)

        // Options: set to `true` or `false` to override defaults

        // Enhance extraction accuracy with Retrieval-Augmented Generation.
        .rag(null)
        // Extract the full text content from the document as strings.
        .rawText(null)
        // Calculate bounding box polygons for all fields.
        .polygon(null)
        // Boost the precision and accuracy of all extractions.
        // Calculate confidence scores for all fields.
        .confidence(null)

        .build();

    // Load a file from disk
    LocalInputSource inputSource = new LocalInputSource(filePath);

    // Send for processing using polling
    InferenceResponse response = mindeeClient.enqueueAndGetResult(
        InferenceResponse.class,
        inputSource,
        extractionParams
    );

    // Print a summary of the response
    System.out.println(response.getInference().toString());

    // Access the result fields
    InferenceFields fields = response.getInference().getResult().getFields();
  }
}
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}

{% tab title=".NET" %}
.NET ≥ 8.0 is recommended.\
Requires the [Mindee .NET client library](https://www.nuget.org/packages/Mindee) version **4.0.0** or greater.

{% code lineNumbers="true" %}

```csharp
using Mindee;
using Mindee.Input;
using Mindee.V2;
using Mindee.V2.Product.Extraction;
using Mindee.V2.Product.Extraction.Params;

string filePath = "/path/to/the/file.ext";
string apiKey = "MY_API_KEY";
string modelId = "MY_MODEL_ID";

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

// Set parameters
var productParams = new ExtractionParameters(
    modelId: modelId

    // Options: set to `true` or `false` to override defaults

    // Enhance extraction accuracy with Retrieval-Augmented Generation.
    , rag: null
    // Extract the full text content from the document as strings.
    , rawText: null
    // Calculate bounding box polygons for all fields.
    , polygon: null
    // Boost the precision and accuracy of all extractions.
    // Calculate confidence scores for all fields.
    , confidence: null
);

// Load a file from disk
var inputSource = new LocalInputSource(filePath);

// Upload the file
var response = await mindeeClient.EnqueueAndGetResultAsync<ExtractionResponse>(
    inputSource, productParams);

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

// Access the extracted fields
var fields = response.Inference.Result.Fields;
```

{% endcode %}

Also take a look at the [Processing Results](https://docs.mindee.com/integrations/client-libraries-sdk/quick-start#processing-the-results) documentation.
{% endtab %}
{% endtabs %}

### Details on Sending

For details on available options and advanced usage, check the following sections:

* [configure-the-client](https://docs.mindee.com/integrations/client-libraries-sdk/configure-the-client "mention")
* [load-and-adjust-a-file](https://docs.mindee.com/integrations/client-libraries-sdk/load-and-adjust-a-file "mention")
* [send-a-file-or-url](https://docs.mindee.com/integrations/client-libraries-sdk/send-a-file-or-url "mention")

## Processing the Results

Once you've sent the file and retrieved the results, you can start extracting the JSON payload.

The model's fields will be in the `fields` object in the returned JSON, in the `response` variable returned from the above step.

Each key in the `fields` object corresponds to the field's `name` in your model configuration.

You'll want to adapt your processing depending on the [type of field](https://docs.mindee.com/extraction-models/data-schema#field-types), for example when looping over lists or accessing sub-fields.

{% tabs %}
{% tab title="Python" %}
Accessing simple values, using the name of the field in the Data Schema.

You can (should!) specify the type of value, the possible types are `str` , `bool` , `float` .\
Note that all types may be `None`.

```python
from mindee import InferenceResponse

def handle_response(response: InferenceResponse):
  fields: dict = response.inference.result.fields

  # texts, dates, classifications ...
  string_field_value: str | None = fields["string_field"].value

  # a JSON float will be a float
  float_field_value: float | None = fields["float_field"].value

  # even if the API always returns an integer, the type will be float
  int_field_value: float | None = fields["int_field"].value

  # booleans
  bool_field_value: bool | None = fields["bool_field"].value
```

Accessing a list of simple values, where `my_list_field` is the name of the field in the Model.

```python
from mindee import InferenceResponse

def handle_response(response: InferenceResponse):
    fields: dict = response.inference.result.fields

    simple_list_field = fields["my_simple_list_field"]

    # Loop over the list of Simple fields
    for list_item in simple_list_field.items:
        item_value = list_item.value
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```python
from mindee import InferenceResponse

def handle_response(response: InferenceResponse):
    fields: dict = response.inference.result.fields

    object_field = fields["my_object_field"]

    sub_fields: dict = object_field.fields

    # grab a single sub-field
    subfield_1 = sub_fields["subfield_1"]

    # loop over sub-fields
    for field_name, sub_field in sub_fields.items():
        sub_field.value
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

```python
from mindee import InferenceResponse

def handle_response(response: InferenceResponse):
    fields: dict = response.inference.result.fields

    object_list_field = fields["my_object_list_field"]

    # Loop over the list of Object fields
    for object_item in object_list_field.items:
        # grab a single sub-field
        sub_field_value = object_item.fields["sub_field"].value
        
        # loop over sub-fields
        for field_name, sub_field in object_item.fields.items():
            sub_field.value
```

{% endtab %}

{% tab title="Node.js" %}
Accessing simple values, using the name of the field in the Data Schema.

Access fields as `SimpleField` instances when retrieving their value.

```typescript
handleResponse(response) {
  const fields = response.inference.result.fields;
  
  // texts, dates, classifications ...
  const stringFieldValue = fields.getSimpleField("string_field").stringValue;
  
  // no distinction between floats and integers
  const floatFieldValue = fields.getSimpleField("float_field").numberValue;
  const intFieldValue = fields.getSimpleField("int_field").numberValue;
  
  // booleans
  const boolFieldValue = fields.getSimpleField("bool_field").booleanValue;
}
```

Accessing a list of values, where `my_simple_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its items.

```javascript
handleResponse(response) {
  const fields = response.inference.result.fields;

  const simpleListField = fields.getListField("my_simple_list_field");

  const simpleItems = simpleListField.simpleItems;

  // Loop over the list of Simple fields
  for (const itemField of simpleItems) {
    // Choose the appropriate accessor:
    // stringValue, doubleValue, booleanValue
    const fieldValue = itemField.stringValue;
  }
}
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```javascript
handleResponse(response) {
  const fields = response.inference.result.fields;

  const objectField = fields.getObjectField("my_object_field");

  const simpleSubFields = objectField.simpleFields;

  // grab a single sub-field
  const subfield1 = subFields.get("subfield_1");

  // loop over simple sub-fields
  subFields.forEach((simpleSubFields, fieldName) => {
    // Choose the appropriate accessor:
    // stringValue, doubleValue, booleanValue
    const fieldValue = subField.stringValue;
  });

  // Object fields can also have lists:
  const listSubFields = objectField.listFields;
}
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its items.

```javascript
handleResponse(response) {
  const fields = response.inference.result.fields;

  const fieldObjectList = fields.getListField("my_object_list_field");

  const objectItems = fieldSimpleList.objectItems;

  // Loop over the list of Object fields
  for (const itemField of objectItems) {
    const simpleSubFields = itemField.simpleFields;

    // grab a single sub-field
    const subField1 = subFields.get("subfield_1");

    // Choose the appropriate accessor:
    // stringValue, doubleValue, booleanValue
    const subFieldValue = subField1.stringValue;

    // loop over simple sub-fields
    simpleSubFields.forEach((subField, fieldName) => {
      // Choose the appropriate accessor:
      // stringValue, doubleValue, booleanValue
      const fieldValue = subField.stringValue;
    });

    // Object fields can also have lists:
    const listSubFields = itemField.listFields;
  }
}
```

{% endtab %}

{% tab title="PHP" %}
Accessing simple values, using the name of the field in the Data Schema.

Access fields as `SimpleField` instances when retrieving their value.

```php
use Mindee\Parsing\V2\InferenceResponse;

public function handleResponse(InferenceResponse $response)
{
    $fields = $response->inference->result->fields;

    // texts, dates, classifications ...
    $stringFieldValue = $fields->getSimpleField('string_field')->value;

    // a JSON float will be a float
    $floatFieldValue = $fields->getSimpleField('float_field')->value;

    // even if the API always returns an integer, the type will be float
    $intFieldValue = $fields->getSimpleField('int_field')->value;

    // booleans
    $boolFieldValue = $fields->getSimpleField('bool_field')->value;
}
```

Accessing a list of values, where `my_simple_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its items.

```php
use Mindee\Parsing\V2\InferenceResponse;

public function handleResponse(InferenceResponse $response)
{
    $fields = $response->inference->result->fields;

    $simpleListField = $fields->getListField('my_simple_list_field');

    // access a value at a given position
    $fieldFirstValue = $simpleListField->items[0]->value;

    // Loop over the list of Simple fields
    foreach ($simpleListField->items as $listItem) {
        $itemValue = $listItem->value;
    }
}
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```php
use Mindee\Parsing\V2\InferenceResponse;

public function handleResponse(InferenceResponse $response)
{
    $fields = $response->inference->result->fields;

    $objectField = $fields->getObjectField('my_object_field');
    $subFields = $objectField->fields;

    // grab a single sub-field
    $subfield1 = $subFields->getSimpleField('subfield_1');

    // loop over sub-fields
    foreach ($subFields as $fieldName => $subField) {
        $fieldValue = $subField->value;
    }
}
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its items.

```php
use Mindee\Parsing\V2\InferenceResponse;

public function handleResponse(InferenceResponse $response)
{
    $fields = $response->inference->result->fields;
    $fieldObjectList = $fields->getObjectField('my_object_list_field');

    // access an object at a given position
    $objectItem0 = $fieldObjectList->items[0];
    $subField0Value = $objectItem0->fields->get('sub_field')->value;

    // Loop over the list of Object fields
    foreach ($myObjectListField->items as $objectItem) {
        $subFieldValue = $objectItem->fields->get('sub_field')->value;
    }
}
```

{% endtab %}

{% tab title="Ruby" %}
Accessing simple values, using the name of the field in the Data Schema.

Access fields as `SimpleField` instances when retrieving their value.

```ruby
def handle_response(response)
  fields = response.inference.result.fields

  # texts, dates, classifications ...
  string_field_value = fields.get_simple_field('string_field').value

  # a JSON float will be a float
  float_field_value = fields.get_simple_field('float_field').value

  # even if the API always returns an integer, the type will be float
  int_field_value = fields.get_simple_field('int_field').value

  # booleans
  bool_field_value = fields.get_simple_field('bool_field').value
end
```

Accessing a list of values, where `my_simple_list_field` is the name of the field in the Model.

Access the list as a `ListField` instance, and the items as `SimpleField` instances.

```ruby
def handle_response(response)
  fields = response.inference.result.fields
  
  my_list_field = fields.get_list_field('my_simple_list_field')

  # access a value at a given position
  simple_list_field = my_list_field.simple_items[0].value

  # Loop over the list of Simple fields
  simple_list_field.simple_items.each do |list_item|
    item_value = list_item.value
  end
end
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```ruby
def handle_response(response)
  fields = response.inference.result.fields

  object_field = fields.get_object_field('my_object_field')
  sub_fields = object_field.fields
  
  # grab a single sub-field
  sub_field_value = sub_fields.get_simple_field('sub_field').value
  
  # loop over sub-fields
  sub_fields.each_value do |sub_field|
    field_value = sub_field.value
  end
end
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

Access the list as a `ListField` instance, and the items as `ObjectField` instances.

```ruby
def handle_response(response)
  fields = response.inference.result.fields
  
  object_list_field = fields.get_list_field('my_object_list_field')

  # access an object at a given position
  object_item_0 = object_list_field.items[0]
  sub_field_0_value = object_item_0.fields.get('sub_field').value

  # Loop over the list of Object fields
  object_list_field.fields.each do |object_item|
    sub_field_value = object_item.fields.get('sub_field').value
  end
end
```

{% hint style="info" %}
You can technically access all field types by their index: `fields['field_name']`

This is heavily discouraged and **unsupported**.
{% endhint %}
{% endtab %}

{% tab title="Java" %}
Accessing simple values, using the name of the field in the Data Schema.

Access fields as `SimpleField` instances when retrieving their value.

We also need to specify the type of value, the possible types are `String` , `Boolean` , `Double` .\
Note that all types may be `null`.

```java
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;

public void handleResponse(InferenceResponse response) {
  InferenceFields fields = response.inference.getResult().getFields();

  // texts, dates, classifications ...
  String stringFieldValue = fields.getSimpleField("string_field")
        .getStringValue();

  // a JSON float will be a Double
  Double floatFieldValue = fields.getSimpleField("float_field")
      .getDoubleValue();

  // even if the API always returns an integer, the type will be Double
  Double intFieldValue = fields.getSimpleField("int_field")
      .getDoubleValue();

  // booleans
  Boolean boolFieldValue = fields.getSimpleField("bool_field")
      .getBooleanValue();
}
```

Accessing a list of simple values, where `my_simple_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its `SimpleItems`.

For each item in the list, we also need to specify the correct field and value type, as described above.

```java
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;
import com.mindee.parsing.v2.field.ListField;
import com.mindee.parsing.v2.field.SimpleField;

public void handleResponse(InferenceResponse response) {
  InferenceFields fields = response.inference.getResult().getFields();

  ListField simpleListField = fields.getListField("my_simple_list_field");

  List<SimpleField> simpleItems = simpleListField.getSimpleItems();

  // Loop over the list of Simple fields
  for (SimpleField itemField : simpleItems) {
    // Choose the appropriate value type accessor method:
    // String, Double, Boolean
    String fieldValue = itemField.getStringValue();
  }
}
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```java
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;
import com.mindee.parsing.v2.field.ListField;
import com.mindee.parsing.v2.field.ObjectField;
import com.mindee.parsing.v2.field.SimpleField;

public void handleResponse(InferenceResponse response) {
  InferenceFields fields = response.inference.getResult().getFields();

  ObjectField objectField = fields.getObjectField("my_object_field");

  HashMap<String, SimpleField> subFields = objectField.getSimpleFields();

  // grab a single sub-field
  SimpleField subfield1 = subFields.get("subfield_1");

  // loop over sub-fields
  for (Map.Entry<String, SimpleField> entry : subFields.entrySet()) {
    String fieldName = entry.getKey();
    SimpleField subField = entry.getValue();
    
    // Choose the appropriate value type accessor method:
    // String, Double, Boolean
    String fieldValue = subField.getStringValue();
  }
}
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

```java
import com.mindee.parsing.v2.InferenceResponse;
import com.mindee.parsing.v2.field.InferenceFields;
import com.mindee.parsing.v2.field.ListField;
import com.mindee.parsing.v2.field.ObjectField;
import com.mindee.parsing.v2.field.SimpleField;

public void handleResponse(InferenceResponse response) {
  InferenceFields fields = response.inference.getResult().getFields();

  ListField fieldObjectList = fields.getListField("my_object_list_field");

  List<ObjectField> objectItems = listField.getObjectItems();

  // Loop over the list of Object fields
  for (ObjectField itemField : objectItems) {

    // Object sub-fields will always be Simple fields
    HashMap<String, SimpleField> subFields = itemField.getSimpleFields();

    // grab a single sub-field
    SimpleField subfield1 = subFields.get("subfield_1");
    
    // Choose the appropriate value type accessor method:
    // String, Double, Boolean
    String subFieldValue = subfield1.getStringValue();

    // loop over sub-fields
    for (Map.Entry<String, SimpleField> entry : subFields.entrySet()) {
      String fieldName = entry.getKey();
      SimpleField subField = entry.getValue();
    }
  }
}
```

Depending on your requirements, this can be simplified using various custom methods.
{% endtab %}

{% tab title=".NET" %}
Accessing simple values, using the name of the field in the Data Schema.

Access fields as `SimpleField` instances when retrieving their value.

We also need to specify the type of value, the possible types are `string` , `Boolean` , `Double` .\
Note that all types may be `null`.

```csharp
using Mindee.V2.Parsing.Inference.Field;

public void HandleResponse(ExtractionResponse response)
{
    // texts, dates, classifications ...
    string stringFieldValue = fields["string_field"].SimpleField.Value;

    // a JSON float will be a Double
    Double floatFieldValue = fields["float_field"].SimpleField.Value;

    // even if the API always returns an integer, the type will be Double
    Double intFieldValue = fields["int_field"].SimpleField.Value;

    // booleans
    Boolean boolFieldValue = fields["bool_field"].SimpleField.Value;
}
```

Accessing a list of simple values, where `my_list_field` is the name of the field in the Model.

We need to specify that the field is a `ListField` in order to access its `SimpleItems`.

```csharp
using Mindee.V2.Parsing.Inference.Field;

public void HandleResponse(ExtractionResponse response)
{
    InferenceFields fields = response.Inference.Result.Fields;

    ListField simpleListField = fields["my_simple_list_field"].ListField;

    List<SimpleField> simpleItems = simpleListField.SimpleItems;

    // Loop over the list of Simple fields
    foreach (SimpleField itemField in simpleItems)
    {
        // Choose the appropriate value type:
        // string, Double, Boolean
        string fieldValue = itemField.Value;
    }
}
```

Accessing an object field and its sub-fields, where `my_object_field` is the name of the field in the Model. In this hypothetical case, the object has a sub-field named `subfield_1` .

```csharp
using Mindee.V2.Parsing.Inference.Field;

public void HandleResponse(ExtractionResponse response)
{
    InferenceFields fields = response.Inference.Result.Fields;

    ObjectField objectField = fields["my_object_field"].ObjectField;

    Dictionary<string, SimpleField> subFields = objectField.SimpleFields;

    // grab a single sub-field
    SimpleField subField1 = subFields["subfield_1"];

    // loop over sub-fields
    // Note: in C#14, 'field' is a reserved keyword, hence use of 'entry'.
    foreach (KeyValuePair<string, SimpleField> entry in subFields)
    {
        string fieldName = entry.Key;
        SimpleField subField = entry.Value;
        
        // process the SimpleField ...
    }
}
```

Accessing a list of objects, where `my_object_list_field` is the name of the field in the Model.

```csharp
using Mindee.V2.Parsing.Inference.Field;

public void HandleResponse(ExtractionResponse response)
{
    InferenceFields fields = response.Inference.Result.Fields;

    ListField fieldObjectList = fields["my_simple_list_field"].ListField;

    List<ObjectField> objectItems = fieldObjectList.ObjectItems;

    // Loop over the list of Object fields
    foreach (ObjectField itemField in objectItems)
    {
        Dictionary<string, SimpleField> subFields = objectField.SimpleFields;
    
        // grab a single sub-field
        SimpleField subField1 = subFields["subfield_1"];
        
        // Choose the appropriate value type:
        // string, Double, Boolean
        string subFieldValue = subField1.Value;
    
        // loop over sub-fields
        // Note: in C#14, 'field' is a reserved keyword, hence use of 'entry'.
        foreach (KeyValuePair<string, SimpleField> entry in subFields)
        {
            string fieldName = entry.Key;
            SimpleField subField = entry.Value;
        }
    }
}
```

{% endtab %}
{% endtabs %}

### Details on Processing

For details on available options and advanced usage, check the following sections:

* [process-the-response](https://docs.mindee.com/integrations/client-libraries-sdk/process-the-response "mention")
