Example Applications
Learn from example applications built with the Healix platform
Code Snippets
Useful code snippets for common tasks with the Healix platform
Connect a Wearable Device
Generate an authorization URL and handle the callback to connect a wearable device.
// Generate an authorization URL
const authUrl = await client.devices.getAuthorizationUrl({
provider: 'fitbit',
redirectUri: 'https://your-app.com/callback'
});
// Redirect the user to authUrl to authorize your app
// Handle the callback
app.get('/callback', async (req, res) => {
const { code } = req.query;
// Exchange the code for an access token
const user = await client.devices.completeAuthorization({
code,
redirectUri: 'https://your-app.com/callback'
});
// User is now connected
console.log('Connected user:', user.id);
});Fetch Health Data
Retrieve health data for a connected user.
// Fetch activity data
const activityData = await client.users.getHealthData({
userId: 'user_123',
dataType: 'activity',
startDate: '2023-01-01',
endDate: '2023-01-31'
});
console.log('Activity data:', activityData);
// Fetch heart rate data
const heartRateData = await client.users.getHealthData({
userId: 'user_123',
dataType: 'heartRate',
startDate: '2023-01-01',
endDate: '2023-01-31'
});
console.log('Heart rate data:', heartRateData);Analyze Health Data with AI
Use the Healix AI Platform to analyze health data.
// Analyze sleep patterns
const sleepAnalysis = await client.ai.analyze({
userId: 'user_123',
dataType: 'sleep',
startDate: '2023-01-01',
endDate: '2023-01-31',
analysisType: 'pattern'
});
console.log('Sleep analysis:', sleepAnalysis);
// Generate health predictions
const predictions = await client.ai.predict({
userId: 'user_123',
predictionType: 'diabetesRisk',
timeframe: '6months'
});
console.log('Diabetes risk prediction:', predictions);