< Blogs
Elliott

Elliott

November 23, 2022

WHOOP Integration series Part 3: Integrating with Terra API

Adding WHOOP as an integration to your app is fairly straightforward thanks to the standardized integration method. Following the documentation, you simply have to implement: auth flow, data gathering, and data processing.

However, if you are building an app utilizing fitness data, you most likely are not gonna want to stop at one data provider. This means you would need to build multiple auth flows, multiple data gathering methods, and data processing systems one for each integration. How about instead of doing this, you make one integration only, and this provides you access to all the wearable companies as well (including WHOOP)?

This is where Terra comes in.

Authentication

Like any data flow, authentication is first and foremost, the most important part. You need to be able to get the user's consent to retrieve their data. This can be done through our (customizable) widget:

curl --location --request POST 'https://api.tryterra.co/v2/auth/generateWidgetSession' \
--header 'dev-id: DEV-ID' \
--header 'X-API-Key: X-API-KEY'

Where DEV-ID and X-API-KEY are credentials you receive when you sign up with Terra.

This will provide you with a widget URL that you can display to your user to log in with whatever provider they want:

{
    "expires_in": 900,
    "session_id": "aece836a-7d69-4489-82cb-1c348e68097e",
    "status": "success",
    "url": "https://widget.tryterra.co/session/aece836a-7d69-4489-82cb-1c348e68097e"
}

The flow would look like this:

The user is uniquely identified by a user_id provided at the auth success page (last in the image above) URL's query parameters.

Data Gathering

That's it! When you have signed up with us, you can set up a webhook URL (under API -> Customise) for which we will continuously send you new events for the user that is authenticated.

Data Processing

The data sent to your webhooks are all of the same structure. They will always contain the same formatting, same field names, and same units. For example, a webhook event from any provider (for example WHOOP) for a workout your user completed will always look like this:

This makes processing events from Terra very simple and elegant as you simply need to pick off points you need from the payload for whatever your app requires.

Advanced

Now, what if you want historic data as well? Tera also has endpoints that allow you to retrieve historical data! You can make a simple HTTP request formatted as:

curl --location --request GET 'https://api.tryterra.co/v2/activity?end_date=2022-10-29&start_date=2022-10-28&user_id=USER_ID' \
--header 'dev-id: DEV-ID' \
--header 'X-API-Key: X-API-KEY'

Where again, DEV-ID and X-API-KEY are credentials you receive when you sign up for Terra. USER_ID on the other hand, is the unique identifier we provide to you after authentication completion to identify the user that has authenticated. The request above with the requested start_date and end_date will gather (and send) the workouts the user has completed over that period of time to your webhook.

Buy or Build

Terra API follows a very simple and easy-to-use structure that allows integrations to WHOOP, Garmin, Fitbit, and hundreds of fitness wearables in one single integration.

You may think that if you can do one, you can go over and do all the others as much as your app would want to support.

However, there are many things to consider, such as partnerships, parsing different data models from other companies, changing your auth system slightly for every company you want to integrate with, and at the same time building a frontend structure to display all of your integrations! These can make a huge difference between if you want to buy or build in-house.


In our Integration series on WHOOP, we are discussing the data available from our API when fetching data from WHOOP.

As a reminder, the WHOOP series contains:

  • Part 1: Getting started with Rest APIs
  • Part 2: Data available from the API
  • Part 3: Integrating with Terra API
  • Part 4: Data from TERRA API

More Topics

All Blogs
Team Spotlight
Startup Spotlight
How To
Blog
Podcast
Product Updates
Wearables
See All >
CEO and Co-Founder of Veri - Anttoni Aniebonam

CEO and Co-Founder of Veri - Anttoni Aniebonam

In this podcast with Kyriakos the CEO of Terra, Anttoni Aniebonam shares his journey founding Veri, and his decision in the acquisition by Oura to further his vision.

Terra APITerra API
September 27, 2024
CEO and Founder of Prenuvo - Andrew Lacy

CEO and Founder of Prenuvo - Andrew Lacy

In this podcast with Kyriakos the CEO of Terra, Andrew Lacy shares his journey with Prenuvo which began from a personal health crisis.

Terra APITerra API
August 28, 2024
MedHacks: Using Wearables To Predict Heart Attacks

MedHacks: Using Wearables To Predict Heart Attacks

A few weeks ago we met Vishal, a recent engineering graduate who wanted to use Terra API as part of his MedHacks hackathon project, Cardio Clarity.

Gursukh SembiGursukh Sembi
August 19, 2024
July 2024 updates

July 2024 updates

Teams API adds Kinexon integration & new webhooks. Terra Health Scores now include Respiratory & Stress metrics. Eight Sleep integration returns with enhanced data.

Alex VenetidisAlex Venetidis
August 2, 2024
Vice President of Teamworks - Sean Harrington

Vice President of Teamworks - Sean Harrington

In this podcast with Kyriakos the CEO of Terra, Sean Harrington shares his journey from founding NoteMeal to becoming the VP of Teamworks.

Terra APITerra API
August 2, 2024
next ventures
pioneer fund
samsung next
y combinator
general catalyst

Cookie Preferences

Essential CookiesAlways On
Advertisement Cookies
Analytics Cookies

Crunch Time: Embrace the Cookie Monster Within!

We use cookies to enhance your browsing experience and analyse our traffic. By clicking “Accept All”, you consent to our use of cookies according to our Cookie Policy. You can change your mind any time by visiting out cookie policy.