Skip to main content
Glama

get_azm_timeseries

Retrieve Active Zone Minutes time series data from Fitbit, including total minutes and breakdown by fat burn, cardio, and peak zones for a specified date range.

Instructions

Get the raw JSON response for Active Zone Minutes (AZM) time series data from Fitbit over a date range (max 1095 days). Returns total AZM plus breakdown by fat burn, cardio, and peak zones.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateYesThe start date for which to retrieve data (YYYY-MM-DD)
endDateYesThe end date for which to retrieve data (YYYY-MM-DD)

Implementation Reference

  • Handler function that constructs the specific API endpoint for Active Zone Minutes (AZM) time series and invokes the shared handleFitbitApiCall utility to fetch data from Fitbit.
    handler: async ({ startDate, endDate }: AzmTimeSeriesParams) => { const endpoint = `activities/active-zone-minutes/date/${startDate}/${endDate}.json`; return handleFitbitApiCall<AzmTimeSeriesResponse, AzmTimeSeriesParams>( endpoint, { startDate, endDate }, getAccessTokenFn, { errorContext: `AZM data from ${startDate} to ${endDate}` } ); }
  • Parameter type definition (AzmTimeSeriesParams) and input schema using shared CommonSchemas for startDate and endDate validation.
    type AzmTimeSeriesParams = Pick<CommonParams, 'startDate' | 'endDate'>; registerTool(server, { name: 'get_azm_timeseries', description: "Get the raw JSON response for Active Zone Minutes (AZM) time series data from Fitbit over a date range (max 1095 days). Returns total AZM plus breakdown by fat burn, cardio, and peak zones.", parametersSchema: { startDate: CommonSchemas.startDate, endDate: CommonSchemas.endDate, },
  • Module-level registration function that configures and registers the get_azm_timeseries tool with the MCP server.
    export function registerAzmTimeSeriesTool( server: McpServer, getAccessTokenFn: () => Promise<string | null> ): void { type AzmTimeSeriesParams = Pick<CommonParams, 'startDate' | 'endDate'>; registerTool(server, { name: 'get_azm_timeseries', description: "Get the raw JSON response for Active Zone Minutes (AZM) time series data from Fitbit over a date range (max 1095 days). Returns total AZM plus breakdown by fat burn, cardio, and peak zones.", parametersSchema: { startDate: CommonSchemas.startDate, endDate: CommonSchemas.endDate, }, handler: async ({ startDate, endDate }: AzmTimeSeriesParams) => { const endpoint = `activities/active-zone-minutes/date/${startDate}/${endDate}.json`; return handleFitbitApiCall<AzmTimeSeriesResponse, AzmTimeSeriesParams>( endpoint, { startDate, endDate }, getAccessTokenFn, { errorContext: `AZM data from ${startDate} to ${endDate}` } ); } }); }
  • src/index.ts:86-86 (registration)
    Invocation of the tool registration during MCP server setup in the main entry point.
    registerAzmTimeSeriesTool(server, getAccessToken);
  • Core helper function used by the tool handler to perform the Fitbit API request, handle errors, and format the MCP tool response.
    export async function handleFitbitApiCall<TResponse, TParams>( endpoint: string, params: TParams, getAccessTokenFn: () => Promise<string | null>, options: { apiBase?: string; successDataExtractor?: (data: TResponse) => unknown[] | null; noDataMessage?: string; errorContext?: string; } = {} ): Promise<ToolResponseStructure> { const { apiBase = FITBIT_API_VERSIONS.V1, successDataExtractor, noDataMessage, errorContext = JSON.stringify(params) } = options; const responseData = await makeFitbitRequest<TResponse>( endpoint, getAccessTokenFn, apiBase ); if (!responseData) { return createErrorResponse( `${ERROR_MESSAGES.API_REQUEST_FAILED} for ${errorContext}. ${ERROR_MESSAGES.CHECK_TOKEN_PERMISSIONS}.` ); } // Check for empty data if extractor provided if (successDataExtractor) { const extractedData = successDataExtractor(responseData); if (!extractedData || extractedData.length === 0) { return createNoDataResponse(noDataMessage || errorContext); } } return createSuccessResponse(responseData); }

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/TheDigitalNinja/mcp-fitbit'

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