< 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 >
March '25 Updates by Terra

March '25 Updates by Terra

🚀 Terra enhances biomarker tracking, improves dashboard usability, and launches a dedicated support page for potential new users—boosting clarity and confidence! 📊✨

Alex VenetidisAlex Venetidis
April 1, 2025
Product Engineering at Terra API - Stalk your users

Product Engineering at Terra API - Stalk your users

In the latest podcast, our product engineer Vanessa breaks down how to get inside your users' heads to build products that people love.

Terra APITerra API
March 3, 2025
Co-Founder of Zoe - George Hadjigeorgiou

Co-Founder of Zoe - George Hadjigeorgiou

In this live podcast with Kyriakos the CEO of Terra, George Hadjigeorgiou shares his journey in building the world’s largest nutrition study.

Terra APITerra API
February 11, 2025
Co-Founder of GoCardless & Nested - Matt Robinson

Co-Founder of GoCardless & Nested - Matt Robinson

In this live podcast with Kyriakos the CEO of Terra, Matt Robinson, founder of GoCardless, discusses the challenges and lessons from building a billion-dollar business.

Terra APITerra API
February 11, 2025
February '25 Updates by Terra

February '25 Updates by Terra

🚀 Terra introduces Blood Report Automation, new insurer-focused use cases boosting loyalty through wearable data, and freshly revamped developer documentation! 📊✨

Alex VenetidisAlex Venetidis
February 1, 2025
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.