# 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`.
