
Company News
Free Business Plan Upgrades for Open Source Maintainers
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.
trainingpeaks-sdk
Advanced tools
A comprehensive TypeScript SDK for TrainingPeaks API integration, built with Clean Architecture principles and designed for modern JavaScript/TypeScript applications.
📋 Product Context: For comprehensive business objectives, target market analysis, and feature roadmap, see PRODUCT.md.
npm install trainingpeaks-sdk
⚠️ Node.js Version: This SDK requires Node.js 20.0.0 or higher due to the use of modern APIs like
crypto.randomUUID(). Node.js 18 and earlier are not supported.
import { createTrainingPeaksSdk } from 'trainingpeaks-sdk';
// Initialize the SDK
const sdk = createTrainingPeaksSdk({
debug: false, // Optional: enable debug logging
timeout: 30000, // Optional: request timeout in ms
});
// Login with credentials
const loginResult = await sdk.login({
username: 'your-username',
password: 'your-password',
});
console.log('Login successful:', loginResult);
// Returns: { token: {...}, user: {...} }
// Get user's workouts list
const workouts = await sdk.getWorkoutsList({
startDate: '2024-01-01',
endDate: '2024-12-31',
// athleteId is optional - uses current user if not provided
});
console.log('Workouts:', workouts);
// Returns: WorkoutListItem[] with id, name, date, etc.
⚠️ Current Limitations: This SDK currently supports authentication and workout list retrieval. Additional features like workout creation, updates, and individual workout details are planned for future releases.
// Clear authentication and logout
await sdk.logout();
console.log('Logged out successfully');
try {
const result = await sdk.login({
username: 'invalid-user',
password: 'wrong-password',
});
} catch (error) {
console.error('Login failed:', error.message);
// Handle authentication errors
}
const sdk = createTrainingPeaksSdk(config?: TrainingPeaksClientConfig)
Config Options:
debug?: boolean - Enable debug loggingtimeout?: number - Request timeout in millisecondsbaseUrl?: string - Custom API base URLlogin(credentials: LoginCredentials)Authenticate with username and password.
type LoginCredentials = {
username: string;
password: string;
};
type LoginResponse = {
token: {
accessToken: string;
tokenType: string;
expiresAt: string;
refreshToken?: string;
};
user: {
id: string;
name: string;
username: string;
avatar?: string;
};
};
logout()Clear authentication and end the current session.
getWorkoutsList(command: GetWorkoutsListCommand)Get user's workouts list with date filtering.
type GetWorkoutsListCommand = {
athleteId?: string; // Optional - uses current user if not provided
startDate: string; // YYYY-MM-DD format
endDate: string; // YYYY-MM-DD format
};
type WorkoutListItem = {
id: string;
name: string;
date: string;
duration: number;
distance?: number;
activityType?: string;
// Additional workout metadata...
};
✅ Available Now:
🚧 Planned Features:
import {
createTrainingPeaksSdk,
type TrainingPeaksClientConfig,
} from 'trainingpeaks-sdk';
const config: TrainingPeaksClientConfig = {
baseUrl: 'https://tpapi.trainingpeaks.com', // Optional
timeout: 30000, // Optional: request timeout in ms
debug: true, // Optional: enable debug logging
headers: {
// Optional: custom headers
'User-Agent': 'MyApp/1.0.0',
},
};
const sdk = createTrainingPeaksSdk(config);
You can also configure the SDK using environment variables:
# API Base URL (optional)
TRAININGPEAKS_API_BASE_URL=https://tpapi.trainingpeaks.com
# Request timeout in milliseconds (optional)
TRAININGPEAKS_TIMEOUT=30000
# Enable debug logging (optional)
TRAININGPEAKS_DEBUG=true
The SDK provides structured error handling with HTTP-specific error information:
import { createTrainingPeaksSdk } from 'trainingpeaks-sdk';
const sdk = createTrainingPeaksSdk();
try {
await sdk.login({ username: 'user', password: 'pass' });
} catch (error) {
// HTTP errors include status, statusText, and response data
if (error.status) {
console.error(`HTTP ${error.status}: ${error.statusText}`);
console.error('Response:', error.data);
} else {
console.error('Network or other error:', error.message);
}
}
The SDK is written in TypeScript and provides comprehensive type definitions:
import { createTrainingPeaksSdk } from 'trainingpeaks-sdk';
import type {
TrainingPeaksClientConfig,
LoginCredentials,
GetWorkoutsListCommand,
WorkoutListItem,
} from 'trainingpeaks-sdk';
// All types are fully typed
const config: TrainingPeaksClientConfig = {
debug: true,
timeout: 30000,
};
const credentials: LoginCredentials = {
username: 'myuser',
password: 'mypass',
};
const workoutsQuery: GetWorkoutsListCommand = {
startDate: '2024-01-01',
endDate: '2024-12-31',
};
The SDK supports multiple import patterns for different use cases:
// Main SDK factory function
import { createTrainingPeaksSdk } from 'trainingpeaks-sdk';
// Type imports
import type {
TrainingPeaksClientConfig,
LoginCredentials,
GetWorkoutsListCommand,
WorkoutListItem,
} from 'trainingpeaks-sdk';
// ⚠️ UNSTABLE: Internal modules - No SemVer guarantees
// These imports may introduce breaking changes in any version
// Use at your own risk - prefer [public API documentation](./docs/clean-architecture.md#public-api) when possible
import { User } from 'trainingpeaks-sdk/domain';
import { Logger } from 'trainingpeaks-sdk/adapters';
import type { WorkoutType } from 'trainingpeaks-sdk/types';
GitHub CLI Authentication:
# Authenticate with GitHub using web browser (recommended for security)
gh auth login --web
# For GitHub Enterprise Server users, specify your hostname
# gh auth login --web --hostname your-enterprise-hostname.com
# Or set GH_HOST environment variable:
# Linux/macOS: export GH_HOST=your-enterprise-hostname.com
# Windows CMD: set GH_HOST=your-enterprise-hostname.com
# Windows PowerShell: $env:GH_HOST="your-enterprise-hostname.com"
# Verify authentication
gh auth status
This repository includes automated setup scripts for GitHub project management:
# Run the automated GitHub project setup
./scripts/github/setup/setup-github-project.sh
# Test the setup script functionality
./scripts/github/setup/test-setup.sh
# Get help and options
./scripts/github/setup/setup-github-project.sh --help
The setup script automatically creates:
For detailed setup instructions, see scripts/github/setup/README.md.
# Install dependencies
npm install
# Build the project
npm run build
# Build specific targets
npm run build:esm # ES modules
npm run build:cjs # CommonJS
# Run unit tests
npm test
# Run integration tests
npm run test:integration
# Run E2E tests
npm run test:e2e
# Run tests with coverage
npm run test:coverage
# Lint code
npm run lint
# Format code
npm run format
# Type check
npm run type-check
# Validate imports
npm run check-imports
This SDK follows Clean Architecture principles with a hexagonal architecture approach:
Key Benefits:
Documentation:
git checkout -b feature/amazing-feature)npm run pre-release)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
See CHANGELOG.md for a list of changes and version history.
Made with ❤️ for the TrainingPeaks community
FAQs
TypeScript SDK for TrainingPeaks API integration
The npm package trainingpeaks-sdk receives a total of 15 weekly downloads. As such, trainingpeaks-sdk popularity was classified as not popular.
We found that trainingpeaks-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.