tracker.gg-api
v1.0.0
Published
An npm package enabling integration with the Tracker.gg API
Maintainers
Readme
Tracker.gg API
A TypeScript/JavaScript client library for interacting with the Tracker.gg API. This package provides a comprehensive interface for accessing game statistics and player data from Tracker.gg.
Features
- 🎮 Multiple Games Support - Apex Legends, CS:GO, Overwatch, Splitgate and more
- 🔄 Automatic Retries - Built-in retry logic for rate-limited and failed requests
- 🚀 Modern ESM & CJS - Supports both ES modules and CommonJS
- 🔑 API Key Management - Easy authentication with TRN-Api-Key
Installation
npm install tracker.gg-apior
yarn add tracker.gg-apior
pnpm add tracker.gg-apiQuick Start
import { TrackerGGAPI } from "tracker.gg-api";
// Create an API client instance with your API key
const api = new TrackerGGAPI({
apiKey: "your-trn-api-key-here"
});
// Get Apex Legends player stats
const apexStats = await api.tracker.getApexPlayerStats(
"origin",
"player-username"
);
console.log(`Player: ${apexStats.data.platformInfo.platformUserHandle}`);
console.log(`Stats:`, apexStats.data.segments);Package Exports
The package supports sub-path imports for tree-shaking. Import from the main entry or specific modules:
| Import Path | Description |
| ------------------------ | -------------------------------------------------------------- |
| tracker.gg-api | Main package – TrackerGGAPI and all API modules |
| tracker.gg-api/client | Base client (TrackerGGClient) for custom API implementations |
| tracker.gg-api/tracker | Tracker.gg Game Stats API |
| tracker.gg-api/types | Shared types and enums |
// Full import (recommended for most use cases)
import { TrackerGGAPI } from "tracker.gg-api";
// Tree-shaken imports – only include what you need
import { TrackerGGClient } from "tracker.gg-api/client";
import { TrackerAPI } from "tracker.gg-api/tracker";
import type { ApexPlayerStatsResponse } from "tracker.gg-api/types";Configuration
You can configure the API client with custom options:
import { TrackerGGAPI } from "tracker.gg-api";
const api = new TrackerGGAPI({
apiKey: "your-trn-api-key-here", // Your Tracker.gg API key
baseURL: "https://public-api.tracker.gg/v2/", // Default API URL
timeout: 10000, // Request timeout in ms (default: 10000)
retries: 3, // Number of retry attempts (default: 3)
retryDelay: 1000, // Delay between retries in ms (default: 1000)
headers: {
// Additional HTTP headers
"Custom-Header": "value"
}
});Tracker.gg Game Stats API
The package provides comprehensive access to Tracker.gg game statistics:
Apex Legends
import { TrackerGGAPI } from "tracker.gg-api";
const api = new TrackerGGAPI({ apiKey: "your-api-key" });
// Get Apex Legends player stats
const stats = await api.tracker.getApexPlayerStats("origin", "username");
// Platforms: 'origin', 'psn', 'xbl'
console.log(stats.data.platformInfo);
console.log(stats.data.segments); // Game statisticsAPI Key
To use the Tracker.gg API, you need an API key from Tracker.gg Developers. The key should be passed in the apiKey option when creating the client.
Requirements
- Node.js >= 16.0.0
- npm, yarn, or pnpm
- A valid Tracker.gg API key
Dependencies
- axios ^1.6.0 – HTTP client
License
MIT
Links
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
Tazhys
