👟Fitness Data
Accessing and Syncing Fitness Data with the VitalEarth SDK
The VitalEarth SDK empowers you to access and synchronize fitness data for users across your ecosystem of applications. This ensures that fitness-related information, such as steps and activities, is seamlessly shared and accessible among all applications utilizing the SDK.

Prerequisites
Before you can work with fitness data, ensure you have completed the installation and initialization of the VitalEarth SDK, as explained in the previous steps.
Fetching Fitness Activity
To retrieve a user's fitness activity based on their address, use the following code:
import { fitnessClient } from "vitalearth-sdk";
// Initialize the fitness client
const client = new fitnessClient();
// Specify the user's address
const userAddress = "0x123456789abcdef"; // Replace with the actual user's address
// Fetch the user's fitness activity
const fitnessData = await client.getFitnessActivity(userAddress);
// Check if fitness data exists
if (fitnessData) {
console.log("Fitness Activity Data:", fitnessData);
} else {
console.log("Fitness activity data not found.");
}
Explanation of the code:
Import the
fitnessClient
module from the VitalEarth SDK.Initialize the
client
object for fitness data management.Specify the user's address in the
userAddress
variable. Replace"0x123456789abcdef"
with the actual user's Ethereum address.Use
await client.getFitnessActivity(userAddress);
to fetch the user's fitness activity based on their address.Check if fitness data exists, and if it does, you can access and utilize the user's fitness activity information.
Synchronizing Fitness Activity
To sync fitness activity for a user, use the following code:
import { fitnessClient } from "vitalearth-sdk";
// Initialize the fitness client
const client = new fitnessClient();
// Specify the user's address
const userAddress = "0x123456789abcdef"; // Replace with the actual user's address
// Synchronize fitness activity
await client.syncFitnessActivity(userAddress);
console.log("Fitness activity synchronized successfully.");
Explanation of the code:
Import the
fitnessClient
module from the VitalEarth SDK.Initialize the
client
object for fitness data management.Specify the user's address in the
userAddress
variable. Replace"0x123456789abcdef"
with the actual user's Ethereum address.Use
await client.syncFitnessActivity(userAddress);
to synchronize the user's fitness activity. This ensures that the most up-to-date fitness data is available for all applications using the VitalEarth SDK.
By implementing these fitness data management functions in your application, you can provide users with a unified and consistent fitness experience across your ecosystem of sustainability-focused apps. This allows users to track their progress and engage in eco-conscious activities seamlessly.
Last updated