< 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 >
April '25 Updates

April '25 Updates

4,200 + biomarkers now supported! 🧬 Terra opens Biomarkers API beta, bringing instant lab parsing and enum mapping to your app in a single request. 🚀📈

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