# Interactions with the Oz API Server

## Retrofit API

SDK contains IOzForensicsAPI interface describing APO net calls that can be used to create a Retrofit instance.

This interface uses a gson-converter and operates classes from the `com.ozforensics.liveness.sdk.api.model` pack.

Apart from this, the interface specifies a static method for creating a default Retrofit instance (without logging, interceptors and with 15-second timeouts). This instance will look for the server at the specified address:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
val apiService = OzForensicsAPI.create(BASE_URL)
```

{% endtab %}

{% tab title="Java" %}

```java
OzForensicsAPI apiService = OzForensicsAPI.Factory.create(BASE_URL);
```

{% endtab %}
{% endtabs %}

## OzForensicsService Class

SDK includes the `OzForensicsService` class that uses a Retrofit instance from `OzForensicsAPI.create()`. This class wraps in net calls from the Retrofit interface and checks the presence of a token. When an auth request is performed, the token is stored automatically for internal goals. Also, the required metadata is added where necessary when performing the net requests (creating a folder, uploading media data to be analyzed). The method calls of this class are asynchronous (the `StatusListener<>` interface is used). You can obtain an instance of this class as follows:

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
val service = OzForensicsService(BASE_URL, ACCESS_TOKEN)
```

{% endtab %}

{% tab title="Java" %}

```java
OzForensicsService service = OzForensicsService(BASE_URL, ACCESS_TOKEN);
```

{% endtab %}
{% endtabs %}

If the `TOKEN` parameter value is set to `null`, authorization is required before performing any API call (except auth):

{% tabs %}
{% tab title="Kotlin" %}

```kotlin
service.auth(EMAIL, PASSWORD, listener)
```

{% endtab %}

{% tab title="Java" %}

```java
service.auth(EMAIL, PASSWORD, listener);
```

{% endtab %}
{% endtabs %}

After a successful request, `onSuccessCallback` is performed so that the access token can be transferred with `AuthResponse`.


---

# Agent Instructions: 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:

```
GET https://doc.ozforensics.com/oz-knowledge/other/old-docs/mobile-sdk/android/interactions-with-the-oz-api-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
