> ## Documentation Index
> Fetch the complete documentation index at: https://api-docs.ollang.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Java Library

> Official Java client library for the Ollang API.

# Java Library

The official Java library wraps the Ollang integration API — projects, uploads, orders, revisions, and custom instructions — using the JDK's built-in HTTP client, with [Gson](https://github.com/google/gson) as the only runtime dependency.

Source code lives in the [`java/` directory of the SDK repository](https://github.com/ollang/sdk/tree/main/java). Requires Java 11+.

## Installation

Maven:

```xml theme={null}
<dependency>
  <groupId>com.ollang</groupId>
  <artifactId>ollang-sdk</artifactId>
  <version>0.1.0</version>
</dependency>
```

Gradle:

```groovy theme={null}
implementation 'com.ollang:ollang-sdk:0.1.0'
```

## Authentication

1. Sign up or log in at [Olabs](https://lab.ollang.com)
2. Create or select a project
3. Generate an API key from project settings

```java theme={null}
import com.ollang.sdk.Ollang;

Ollang ollang = Ollang.builder()
    .apiKey(System.getenv("OLLANG_API_KEY"))
    .build();
```

## Quick Start

```java theme={null}
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.ollang.sdk.Ollang;
import java.nio.file.Path;

Ollang ollang = Ollang.builder()
    .apiKey(System.getenv("OLLANG_API_KEY"))
    .build();

// Upload a file (creates a project)
JsonElement upload = ollang.uploads().direct(Path.of("video.mp4"), "My Video", "en");
String projectId = upload.getAsJsonObject().get("projectId").getAsString();

// Create an order
JsonObject params = new JsonObject();
params.addProperty("orderType", "cc");
params.addProperty("level", 1);
params.addProperty("projectId", projectId);
params.add("targetLanguageConfigs", JsonParser.parseString(
    "[{\"language\":\"fr\",\"isRush\":false},{\"language\":\"de\",\"isRush\":false}]"));
JsonElement orders = ollang.orders().create(params);

// Check order status
String orderId = orders.getAsJsonArray().get(0).getAsJsonObject().get("orderId").getAsString();
JsonElement status = ollang.orders().get(orderId);
System.out.println(status);
```

## Resources

| Resource                      | Description                            |
| ----------------------------- | -------------------------------------- |
| `ollang.projects()`           | Read and list projects                 |
| `ollang.uploads()`            | Upload files (video, audio, documents) |
| `ollang.orders()`             | Create and track translation orders    |
| `ollang.revisions()`          | Request revisions on completed orders  |
| `ollang.customInstructions()` | Set custom translation instructions    |

All methods return the parsed JSON response as a Gson `JsonElement`. Non-2xx responses throw `OllangApiException`, which carries the HTTP status code and the response body (raw and parsed).

## More Examples

```java theme={null}
import com.ollang.sdk.resources.Orders;

// List orders with pagination and filters
JsonElement page = ollang.orders().list(
    new Orders.ListOptions().page(1).take(20).status("completed"));

// Request a revision on an order
ollang.revisions().create("ORDER_ID", "wrongSubtitle", "00:01:23", "Fix the terminology here");

// Custom instructions
ollang.customInstructions().create("tone", "Formal, brand-safe tone", null);
```

<Note>
  For endpoints the library doesn't wrap yet, the underlying HTTP client is
  available: `ollang.client().get("/integration/supported-languages")`. See the
  full [API reference](/apis/ollang-api-reference/direct-file-upload) for all
  endpoints.
</Note>
