1. Setting up

1. Setting up

Getting Started

Setting up

Authenticate Users

Getting Data

Parsing Data

API Settings



Mobile Setup


API


Widget


Request


Receive


Events


Data Models

Your Terra credentials

Head to the Terra dashboard. Under API > Customise, you will find your API Key, Dev ID and Signing Secret. They are used in virtually every interaction with the API - keep them safe!

Choose your language

You can interact with the API using one of the following options:

Installation

Install the package using npm or yarn:

npm i terra-api
yarn i terra-api

Initialise the Terra Object

You can now import the Terra class and initialise an instance using your developer credentials.

// Importing the API and instantiating the client using your keys
const { default: Terra } = require("terra-api");

const API_KEY = "<Your API Key>"
const DEV_ID = "<Your Dev Id>"
const SECRET = "<Your Signing secret>"


const terra = new Terra("DEV_ID", "API_KEY", "SECRET");

You will now be able access Terra's API endpoints through the Terra object.

Listing Providers and Users

To start off, let's view the most up-to-date list of all data providers through Terra. Use the getProvidersmethod on terra to get an API response, in the form of a JavaScript object.

terra
  .getProviders()
  .then((p) => {
  	console.log(p);
	})

You should see the following output:

{
  status: 'success',
  providers: [
    'BIOSTRAP',    'CARDIOMOOD',    'CONCEPT2',
    'COROS',       'CRONOMETER',    'DEXCOM',
    'EATTHISMUCH', 'EIGHT',         'FATSECRET',
    'FINALSURGE',  'FITBIT',        'FREESTYLELIBRE',
    'GARMIN',      'GOOGLE',        'HAMMERHEAD',
    'HUAWEI',      'IFIT',          'INBODY',
    'KOMOOT',      'LIVEROWING',    'LEZYNE',
    'MOXY',        'NUTRACHECK',    'OMRON',
    'OMRONUS',     'OURA',          'PELOTON',
    'POLAR',       'PUL',           'RENPHO',
    'RIDEWITHGPS', 'ROUVY',         'SUUNTO',
    'TECHNOGYM',   'TEMPO',         'TRIDOT',
    'TREDICT',     'TRAININGPEAKS', 'TRAINASONE',
    'TRAINERROAD', 'UNDERARMOUR',   'VIRTUAGYM',
    'WAHOO',       'WEAROS',        'WHOOP',
    'WITHINGS',    'XOSS',          'ZWIFT',
    'XERT',        'BRYTONSPORT',   'TODAYSPLAN',
    'WGER',        'VELOHERO',      'CYCLINGANALYTICS',
    'NOLIO',       'TRAINXHALE',    'KETOMOJOUS',
    'KETOMOJOEU',  'STRAVA',        'CLUE',
    'HEALTHGAUGE', 'MACROSFIRST'
  ],
  sdk_providers: [ 'GOOGLEFIT', 'FREESTYLELIBRESDK', 'APPLE', 'SAMSUNG', 'REALTIME' ]
}

Similarly, to view a list of users that you have currently authenticated through Terra, use the getUsers method.

terra
  .getUsers()
  .then((p) => {
  	console.log(p);
	})

If you haven't authenticated any users yet, you should receive an empty list in the returned object:

{
  status: 'success',
  users: []
}

For detailed documentation on any of the functions used, checkout the JavaScript Client Reference.

In the next step, let's get some users authenticated!