Categories We Write About

Track daily steps using APIs

Tracking daily steps using APIs involves integrating with health and fitness platforms that provide step count data from devices like smartphones, smartwatches, and fitness trackers. These APIs allow developers to build applications that fetch, store, and analyze users’ physical activity. The most widely used APIs come from major platforms like Apple HealthKit, Google Fit, Fitbit, and Garmin.


1. Google Fit API

Google Fit is a health-tracking platform developed by Google for Android devices. It provides access to aggregated data from sensors on devices and wearables.

  • Key Features:

    • Step count (daily, hourly, session-based)

    • Calories burned, heart rate, distance

    • Integration with other fitness apps

  • How to Use:

    • Authentication: Uses OAuth 2.0 for secure access.

    • Data Source: com.google.step_count.delta (raw step counts)

    • Aggregated Data: Use com.google.step_count.delta with aggregation.

http
POST https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate Authorization: Bearer {access_token}
  • Sample Payload:

json
{ "aggregateBy": [{ "dataTypeName": "com.google.step_count.delta", "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_steps" }], "bucketByTime": { "durationMillis": 86400000 }, "startTimeMillis": 1684108800000, "endTimeMillis": 1684195199999 }
  • Platform Support: Android, Wear OS

  • SDK: Google Fit SDK for Android


2. Apple HealthKit

HealthKit is Apple’s API for managing health and fitness data on iOS devices and Apple Watch.

  • Key Features:

    • Step count, flights climbed, distance

    • Real-time updates and background delivery

    • Secure and private by design

  • How to Use:

    • Requires user consent

    • Access step data using HKQuantityTypeIdentifier.stepCount

    • Works with Swift and Objective-C via HealthKit framework

swift
let stepType = HKQuantityType.quantityType(forIdentifier: .stepCount)! let predicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate) let query = HKStatisticsQuery(quantityType: stepType, quantitySamplePredicate: predicate, options: .cumulativeSum)
  • Platform Support: iOS, watchOS

  • SDK: HealthKit Framework


3. Fitbit Web API

Fitbit offers a comprehensive Web API that provides access to step count and other activity data from its devices.

  • Key Features:

    • Steps, heart rate, calories, sleep

    • Sync data from wearable devices

    • Personal and social metrics

  • How to Use:

    • Uses OAuth 2.0

    • Daily step data is available via:

http
GET https://api.fitbit.com/1/user/-/activities/steps/date/today/1d.json Authorization: Bearer {access_token}
  • Response:

json
{ "activities-steps": [ { "dateTime": "2025-05-18", "value": "10450" } ] }
  • Platform Support: Web, iOS, Android

  • SDKs: Fitbit SDK for devices, Web API for external applications


4. Garmin Health API

Garmin provides access to health data through its Health API for registered partners.

  • Key Features:

    • Steps, heart rate, body battery, sleep

    • Secure and enterprise-grade

    • Historical and real-time data sync

  • How to Use:

    • Must be an approved Garmin Health Partner

    • Data sent via webhook (JSON payload)

    • Secure OAuth 1.0a authorization

  • Webhook Payload Sample:

json
{ "userId": "abc123", "summaryId": "xyz789", "calendarDate": "2025-05-18", "steps": 10678 }
  • Platform Support: Web services, enterprise integrations


5. Withings API

Withings provides smart health devices and APIs to access physical activity and health metrics.

  • Key Features:

    • Steps, heart rate, sleep, weight

    • Daily summaries and historical data

  • API Endpoint:

http
GET https://wbsapi.withings.net/v2/measure?action=getactivity Authorization: Bearer {access_token}
  • Response:

json
{ "status": 0, "body": { "activities": [ { "date": "2025-05-18", "steps": 9480 } ] } }
  • Platform Support: iOS, Android, Web


6. Samsung Health SDK

Samsung Health SDK allows apps to access step data collected on Samsung smartphones and Galaxy Watches.

  • Key Features:

    • Steps, calories, distance, heart rate

    • Compatible with Samsung wearables

  • How to Use:

    • Use DataResolver to query step data

    • Requires Samsung Health app installed

java
HealthDataResolver resolver = new HealthDataResolver(mStore, null); HealthDataResolver.ReadRequest request = new HealthDataResolver.ReadRequest.Builder() .setDataType("com.samsung.shealth.step_daily_trend") .build();
  • Platform Support: Android (Samsung devices only)


7. Manual Integration Strategy

For platforms without direct support:

  • Allow users to export their step data via CSV or API

  • Implement daily polling with user authentication

  • Store data in a secure cloud database

  • Create dashboards or reports using step trends


Security and Privacy Considerations

  • Always request only the necessary scopes or permissions.

  • Use secure storage for tokens and user data (e.g., OAuth tokens).

  • Ensure compliance with privacy laws such as GDPR, HIPAA, and CCPA.

  • Clearly inform users how their data is being used and stored.


Common Use Cases

  • Step tracking apps for wellness programs

  • Gamification of daily activity goals

  • Employee wellness incentive platforms

  • Health insurance rewards apps

  • Personalized fitness and coaching apps


Conclusion

APIs like Google Fit, Apple HealthKit, Fitbit, and Garmin enable powerful capabilities to track daily step counts in real time or as historical summaries. By integrating these APIs with user consent and secure authentication, developers can build engaging, health-focused applications that promote physical activity, healthy habits, and user insights.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About