< 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 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
Chief Digital Product Officer of Les Mills - Amber Taylor

Chief Digital Product Officer of Les Mills - Amber Taylor

In this podcast with Kyriakos the CEO of Terra, Amber Taylor shares her journey from childhood running to her leadership role at Nike and navigating cultural differences.

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.