Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

terra-api

tryterra7.3kMIT1.4.8TypeScript support: included

Terra Javascript Package

Terra, Healthcare, Fitness

readme

Terra Javascript Package

A wrapper in javascript for the Terra endpoints and models.

Full API reference: https://tryterra.github.io/terra-client-js

Check the example server with a webhook in /example!

Usage

Install using

npm i terra-api

Then import the default Terra package from terra-api.

Initialise a new Terra instance with:

const terra = new Terra(process.env.DEV_ID, process.env.API_KEY);

Now you can call the following functions from the instance, for example:

  • generateWidgetSession
  • getProviders
  • getUsers
  • getUser
  • deauthUser
  • getAthlete
  • getActivity
  • getBody
  • getDaily
  • getSleep
  • getMenstruation

Check the full reference on https://tryterra.github.io/terra-client-js/

In addition, all the data models documented on https://docs.tryterra.co/data-models are available to import and use. For example

const terra = new Terra(process.env.DEV_ID, process.env.API_KEY);
terra
  .getAthlete("1234-user-id-5678", false)
  .then((res) => console.log(res.athlete.first_name))
  .catch((e) => console.log(e.status, e.message));

The models support autocompleting the types to manipulate data coming from Terra, which should accelerate your backend development:

typed_1

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

1.4.8 - 2024-11-13

1.4.7 - 2024-10-08

1.4.6 - 2024-10-08

1.4.5 - 2023-12-12

1.4.4 - 2023-12-11

1.4.2 - 2023-10-19

1.4.1 - 2023-10-12

1.4.0 - 2023-07-24

Changed

  • Add retry_if_rate_limited as a query parameter to the getter functions

1.3.3 - 2023-05-25

Changed

  • Updated data models
  • Add with_samples as a query parameter to the getter functions

1.3.2 - 2023-04-11

Changed

  • Updated data models
  • Allows userinfo to be queried by reference id

1.3.0 - 2023-01-12

Added

  • Changelog
  • CI for publishing

Changed

  • Function inputs to an interface where suitable to avoid inputting undefined parameters

Fixed

  • Error handling in the request handler