> 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/java-ocr-sdk/java-api-builder.md).

# Custom API (Deprecated)

{% hint style="warning" %}
**The API Builder product is deprecated.**

We recommend using [Mindee V2](/getting-started/defining-a-model.md), which is much more performant for custom documents.
{% endhint %}

### Quick Start

```java
String path = "/path/to/the/file.ext";
LocalInputSource inputSource = new LocalInputSource(path);
CustomEndpoint myEndpoint = new CustomEndpoint(
    "wnine",
    "john",
    // "1.1" // optional
);

MindeeClient mindeeClient = new MindeeClient(apiKey);
  
PredictResponse<CustomV1> response = mindeeClient
    .parse(inputSource, myEndpoint);

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

If the `version` argument is set, you'll be required to update it every time a new model is trained. This is probably not needed for development but essential for production use.

### The `CustomV1` Object

The `CustomV1` object contains the results of document-level and page-level predictions.

All the fields which are present in the API builder are available.

The fields are defined when creating your custom API.

#### Document-Level Predictions

The document-level predictions are ultimately contained in the `CustomV1Document` object.

The predictions are stored in two properties: `classificationFields` and `fields`.

Both are a Map where the key is a `String` of the name of the field.

For the values:

* `classificationFields` have a `ClassificationField` object as value, each containing a single `String` value.
* `fields` have a `ListField` object as value, each containing a list of all `String` values extracted for this field.

Here are some example usages:

```java
String path = "/path/to/the/file.ext";
LocalInputSource inputSource = new LocalInputSource(path);

PredictResponse<CustomV1> response = mindeeClient
    .parse(CustomV1.class, inputSource);

CustomV1 inference = response.getDocument().getInference();
  
// === Getting a single field === \\

ListField employerName = inference.getPrediction().getFields().get("employer_name");

// get the field as a string
System.out.println(employerName.toString());

// get the field as a string with a custom separator
System.out.println(employerName.getContentsString("_"));

// get the list of string values in the field
System.out.println(employerName.getContentsList());

// == Getting all fields === \\

for (Map.Entry<String, ListField> entry : inference.getPrediction().getFields().entrySet()) {
  ListField field = entry.getValue();

  // Not really needed, just showing that the method exists ;-)
  if (field.isEmpty()) {
      continue;
  }

  // We can print directly as in the single field example above ...
  System.out.println(field.toString());

  // ... or go through each value
  for (ListFieldValue value : field.getValues()) {

    // The actual value (word)
    System.out.println(value.getContent());

    // The page on which the value was found
    System.out.println(value.getPageId());
  }
}
```

#### Page-Level Predictions

The page-level predictions are ultimately contained in the `CustomV1Page` object.

In the response, there is a list of these objects, each one representing a single page.

The prediction results are stored as a key-value `HashMap<String, ListField>`.

Here are some example usages:

```java
String path = "/path/to/the/file.ext";
LocalInputSource inputSource = new LocalInputSource(path);

PredictResponse<CustomV1> response = mindeeClient
    .parse(CustomV1.class, inputSource);

CustomV1 inference = response.getDocument().getInference();
  
for (Page<CustomV1Page> page : inference.getPages()) {
  CustomV1Page pagePrediction = page.getPrediction();

  for (Map.Entry<String, ListField> entry : pagePrediction.entrySet()) {
    ListField field = entry.getValue();
    
    // get the field as a string
    System.out.println(field.toString());

    // get the field as a string with a custom separator
    System.out.println(field.getContentsString("_"));

    // get the list of strings in the field
    System.out.println(field.getContentsList());
  }
}
```

##


---

# 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/java-ocr-sdk/java-api-builder.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.
