< Blogs
Elliott

Elliott

June 23, 2022

Realtime Data Streaming - Terra API

Terra has been near-real-time since the start. We send a complete payload about an activity or sleep session of a user in one Webhook URL. However, Terra's vision goes beyond this simplistic model. We want to provide real-time data and stream it to our developers as the user does their workout. Today, we make a huge step towards this goal with our new products: Websocket API along with Bluetooth Low Energy (BLE) connections to stream real-time data from wearables to you!

The BLE Connection

BLE connections are done through our Software Development Kits (SDKs). You can seamlessly integrate our SDKs into your app and allow your users to connect to any BLE devices they wish (we support both iOS and Android devices with our SDKs).

We even provide the widget for you and automatic connection of the user to our Websocket API so the only thing you need to do is control when to start or stop streaming.

Bluetooth Low Energy Widget

Streaming Heart Rate Data

After you have established a connection to a BLE device using our Widget above, you can immediately start streaming their data to our Websocket API! As an example, we will try streaming Heart Rate data.

In the widget screen above, TICKR FIT 75B1 is a Heart Rate monitor strap from Wahoo. We will stream the heart rate values from this strap to you through our Websocket API.

Let's say you have pressed "Connect" and it was successful. You can then simply run a function to start streaming (more info on the code in our repository (Android's SDK is used here as an example))

terraRT.startRealtime(type: Connections.BLE, dataTypes: setOf(DataTypes.HEART_RATE))

This function does:

  1. Establish that the device allows for "HEART_RATE" data streaming
  2. Enables the "HEART_RATE" streaming service from the device
  3. Opens and starts streaming the heart rate values to our Websocket API.

That's it on the user's end.

As a developer, you can then connect to our Websocket API to receive this user's data. Let's connect and see what we get:

22704: ↓ {"op":5,"d":{"ts":"2022-06-14T13:24:21.660Z","val":77.0},"uid":"7af41b43-ee18-4222-b4cf-8ab218cf7b6d","seq":14115,"t":"HEART_RATE"}
22704: ↓ {"op":5,"d":{"ts":"2022-06-14T13:24:22.694Z","val":76.0},"uid":"7af41b43-ee18-4222-b4cf-8ab218cf7b6d","seq":14116,"t":"HEART_RATE"}
22704: ↓ {"op":5,"d":{"ts":"2022-06-14T13:24:23.692Z","val":76.0},"uid":"7af41b43-ee18-4222-b4cf-8ab218cf7b6d","seq":14116,"t":"HEART_RATE"}
23510: ↓ {"op":5,"d":{"ts":"2022-06-14T13:24:24.674Z","val":77.0},"uid":"7af41b43-ee18-4222-b4cf-8ab218cf7b6d","seq":14117,"t":"HEART_RATE"}
26685: ↓ {"op":5,"d":{"ts":"2022-06-14T13:24:25.670Z","val":77.0},"uid":"7af41b43-ee18-4222-b4cf-8ab218cf7b6d","seq":14118,"t":"HEART_RATE"}

Incredible! Data from a user connecting their BLE device to your app straight to your backend.

Seems too easy? It's because we made it that way!

Time to stream

The example above shows a simple yet powerful tool that many developers can benefit from.

For example, you can:

  • Build a treadmill that can stream a user's heart rate from their chest strap and display it on the screen
  • Create a virtual reality fitness game where you can stream the player's heart rate, steps, calories burnt, or distance traveled from outside sources
  • Dynamically adapt your workout in an app depending on the user's live heart rate data
  • Recommend music based on the user's current heart rate

If you have any other ideas in mind, go and build it! We did all the heavy lifting in getting the data to you. Now it's time for you to show us what your vision is.

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.