Skip to main content

Authentication

Every protected SDK operation sends:

Authorization: Bearer <token>

The token can be either:

  • a personal API token beginning with analog-wakatime_live_
  • a session JWT issued by login or device authorization

Personal API tokens are recommended for scripts and integrations because they can be disabled or deleted independently.

Keep the token outside source code

Expose the token through the process environment or a deployment secret store:

import * as AnalogWakaTime from '@analog-code-monitor/analog-wakatime-ts-sdk';

const configuration = new AnalogWakaTime.Configuration({
accessToken: process.env.ANALOG_WAKATIME_API_TOKEN,
});

Do not include the literal Bearer prefix. The generated client adds it.

Client lifecycle

Create one Configuration and share it across API class instances:

import * as AnalogWakaTime from '@analog-code-monitor/analog-wakatime-ts-sdk';

const configuration = new AnalogWakaTime.Configuration({
accessToken: process.env.ANALOG_WAKATIME_API_TOKEN,
});

const profileApi = new AnalogWakaTime.ProfileApi(configuration);
const statisticsApi = new AnalogWakaTime.StatisticsApi(configuration);
const activitiesApi = new AnalogWakaTime.ActivitiesApi(configuration);

Reuse one configuration for related requests instead of creating a new one for every operation.

Concurrent requests

Independent reads can run concurrently:

const [profile, dashboard] = await Promise.all([
profileApi.mainApiV1GetMyProfileInfoGet(),
statisticsApi.mainApiV1GetMyDashboardStatsGet(),
]);