Skip to main content
Glama

getLifetimeStats

Retrieve comprehensive lifetime health and fitness statistics from your Fitbit data, including total activity, sleep patterns, and long-term wellness metrics.

Input Schema

NameRequiredDescriptionDefault

No arguments

Input Schema (JSON Schema)

{ "properties": {}, "type": "object" }

Implementation Reference

  • src/server.ts:474-506 (registration)
    Registration of the 'getLifetimeStats' tool, including its inline handler function. The handler fetches lifetime and best activity stats from the Fitbit API endpoint '/user/-/activities.json' using the makeApiRequest helper, formats the response as text content, and handles errors.
    server.tool("getLifetimeStats", {}, async () => { try { const endpoint = "/user/-/activities.json"; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify( { lifetime: data.lifetime || {}, best: data.best || {}, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } });
  • Shared helper function used by the getLifetimeStats handler (and other tools) to make authenticated HTTP requests to the Fitbit API.
    async function makeApiRequest(endpoint: string): Promise<any> { try { const url = `${baseUrl}${endpoint}`; const response = await fetch(url, { headers: { Authorization: `Bearer ${accessToken}`, Accept: "application/json", }, }); if (!response.ok) { throw new Error( `Fitbit API error: ${response.status} ${response.statusText}` ); } return await response.json(); } catch (error) { console.error(`Error making request to ${endpoint}:`, error); throw error; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NitayRabi/fitbit-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server