tryterra / terra-client-java

Java wrapper for the Terra (tryterra.co) REST API
https://tryterra.github.io/terra-client-java/
Apache License 2.0
7 stars 2 forks source link
api-wrapper java java-library terra tryterra

GitHub license test docs Maven Central

Terra Java Client Library

The official Terra Java client library.

Installation

Requirements

Gradle users

Add this dependency to your project's build file:

implementation "co.tryterra:terra-client:<version>"

Maven users

Add this dependency to your project's POM:

<dependency>
    <groupId>co.tryterra</groupId>
    <artifactId>terra-client</artifactId>
    <version>${terra-client.version}</version>
</dependency>

Usage

TerraExample.java

import co.tryterra.terraclient.TerraClientFactory;
import co.tryterra.terraclient.api.TerraApiResponse;
import co.tryterra.terraclient.api.TerraClientV2;
import co.tryterra.terraclient.api.User;
import co.tryterra.terraclient.exceptions.TerraRuntimeException;
import co.tryterra.terraclient.models.Athlete;

public class TerraExample {
    public static void main(String[] args) {
        TerraClientV2 client = TerraClientFactory.getClientV2("YOUR_API_KEY", "YOUR_DEV_ID");

        try {
            User user = client.getUser("YOUR_USER_ID");
            TerraApiResponse<Athlete> response = client.getActivityForUser(user);
            System.out.println(response.getParsedData());
        } catch (TerraRuntimeException ex) {
            ex.printStackTrace();
        }
    }
}