< 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 Bioniq - Vadim Fedotov

CEO and Co-Founder of Bioniq - Vadim Fedotov

In this podcast with Kyriakos the CEO of Terra, Vadim Fedotov a former professional athlete turned entrepreneur, shares his journey in founding Bioniq.

Terra APITerra API
December 10, 2024
5 Lessons for Standing Out at HLTH

5 Lessons for Standing Out at HLTH

5 lessons from team Terra API for making a lasting impact at HLTH: from engaging senses to building real touch points, here’s what we learned from the HLTH event.

VanessaVanessa
December 5, 2024
November '24 Updates by Terra

November '24 Updates by Terra

Terra’s Latest Updates: Zepp Metrics, Support Revamp, and Teams API Enhancements 🚀✨

Alex VenetidisAlex Venetidis
December 1, 2024
Strava Pulls the Plug on their API: What This Means for Developers

Strava Pulls the Plug on their API: What This Means for Developers

Strava discontinued their API service, changing the ecosystem of third-party apps that have relied on their platform. How can developers react to this?

Terra APITerra API
November 21, 2024
Alternatives to the latest changes in the Strava API

Alternatives to the latest changes in the Strava API

Strava just introduced big changes to their API program. These changes will basically kill off a lot of apps. Use Terra API instead to avoid this

Kyriakos EleftheriouKyriakos Eleftheriou
November 19, 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.