npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

iracing-api-sdk-node

v1.0.0

Published

iRacing OAuth2 + Data API SDK for Node.js (TypeScript).

Downloads

8

Readme

🏁 iRacing API SDK

TypeScript SDK for iRacing OAuth2 Authentication & Data API

Node.js TypeScript License pnpm Vitest

⭐ If you find this project useful, please give it a star! ⭐

📖 Documentation🚀 Examples🔒 Security🤝 Contributing


🎯 What is this?

iracing-api-sdk is a zero-dependency TypeScript SDK that provides type-safe primitives for:

  • OAuth2 Authentication: Password Limited, Authorization Code + PKCE, automatic token refresh
  • Data API Client: Type-safe access to iRacing's Data API with automatic rate limiting
  • Session Management: List, audit, and revoke OAuth2 sessions
  • Security First: Automatic credential masking, secure token storage, authorization header protection

Built for Node.js ≥ 20 with strict TypeScript and ESM-only.


✨ Features

  • Zero runtime dependencies - Minimal footprint, maximum control
  • Type-safe - Full TypeScript support with strict mode
  • Security built-in - Never logs secrets, automatic credential masking
  • Rate limit aware - Built-in rate limiting with automatic retry/backoff
  • OAuth2 complete - Password Limited, Authorization Code + PKCE, token refresh
  • Flexible storage - File-based storage with interfaces for custom implementations
  • Production ready - Comprehensive tests, error handling, and logging

📦 Installation

npm i iracing-api-sdk-node
pnpm add iracing-api-sdk-node
yarn add iracing-api-sdk-node

🚀 Quick Start

1. Configure Environment

# .env
IRACING_OAUTH_CLIENT_ID=your-client-id
IRACING_OAUTH_CLIENT_SECRET=your-client-secret
IRACING_OAUTH_CLIENT_USER=your-username
IRACING_OAUTH_CLIENT_PASS=your-password

2. Authenticate & Access Data

import { Config } from "iracing-api-sdk-node/config";
import { OAuthClient } from "iracing-api-sdk-node/oauth";
import { DataApiClient } from "iracing-api-sdk-node/data";
import { HttpClient } from "iracing-api-sdk-node/http";

// Configure SDK
const config = Config.fromEnv();
const http = new HttpClient();
const oauth = new OAuthClient(config, http);

// Authenticate
const tokenSet = await oauth.authenticatePasswordLimited(
    process.env.IRACING_OAUTH_CLIENT_ID!,
    process.env.IRACING_OAUTH_CLIENT_SECRET!,
    process.env.IRACING_OAUTH_CLIENT_USER!,
    process.env.IRACING_OAUTH_CLIENT_PASS!,
    "iracing.data.read",
);

// Access Data API
const data = new DataApiClient(config, http, tokenSet);
const result = await data.car().get();

if (result.isOk()) {
    console.log("Cars:", result.getData());
}

📚 Documentation

Core Guides

| Guide | Description | | ------------------------------------------- | ---------------------------------------------- | | 📖 Documentation Index | Complete documentation overview | | ⚙️ Configuration | Environment variables and config setup | | 🔐 OAuth Flows | Authentication methods and token management | | 📡 Data API | Accessing iRacing Data API with typed services | | 🔒 Security | Security features and best practices |

Advanced Topics

| Guide | Description | | ------------------------------------------- | ---------------------------------------- | | 📋 Sessions | OAuth2 session management and revocation | | 🎯 Data Services | Generated typed service wrappers | | 🔧 Integration | Production application patterns | | 🧪 Testing | Unit and integration testing guide |

Examples

See examples/ for runnable code samples:

  • OAuth2 authentication flows
  • Token refresh patterns
  • Data API calls
  • Session management
  • Custom storage implementations

🎯 Use Cases

Racing Teams & Analytics

Track performance, analyze telemetry data, and monitor race results using iRacing's official data.

const data = new DataApiClient(config, http, tokenSet);

// Get driver stats
const stats = await data.stats().memberCareer({ custId: 123456 });

// Get race results
const results = await data.results().searchSeries({ seasonYear: 2026 });

League Management

Automate league operations, track member activity, and manage rosters.

// Get league data
const league = await data.league().get({ leagueId: 789 });

// Track member sessions
const sessions = await data.stats().memberRecentRaces({ custId: 123456 });

Development Tools & Bots

Build Discord bots, dashboards, or custom tools integrating with iRacing.

// Custom rate limiting
const rateLimitStore = new FileRateLimitStore(cacheDir);
const rateLimitedHttp = new RateLimitedHttpClient(http, rateLimitGuard, rateLimitStore);

// Automatic token refresh
const storage = new FileTokenStorage(cacheDir, logger);
await storage.save("my-app", tokenSet);

🛡️ Security

This SDK follows strict security practices:

  • Never logs secrets - Client secrets, passwords, and tokens are never logged
  • Automatic credential masking - Passwords masked with SHA-256 before transmission
  • Authorization header protection - Auth headers only forwarded to trusted origins
  • Secure file storage - Tokens stored with 0600 permissions (user read/write only)

See Security Documentation for details.


🧪 Development

Prerequisites

  • Node.js ≥ 20
  • pnpm ≥ 8

Commands

# Install dependencies
pnpm install

# Run tests (unit tests, no credentials needed)
pnpm test

# Run integration tests (requires valid .env)
pnpm test:integration

# Type checking
pnpm typecheck

# Linting
pnpm lint

# Build
pnpm build

# Format code
pnpm format

Project Structure

src/
├── config/          # Configuration management
├── crypto/          # Credential masking (SHA-256)
├── data/            # Data API client + generated services
├── errors/          # Exception handling
├── fs/              # Atomic file operations
├── http/            # HTTP client abstraction
├── log/             # Logger interfaces
├── oauth/           # OAuth2 flows (password_limited, auth code + PKCE)
├── rate-limit/      # Rate limiting with guards and stores
├── response/        # Response wrappers
├── sessions/        # OAuth2 session management
├── token/           # Token storage and expiration handling
└── types/           # TypeScript type definitions

🤝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for:

  • Development workflow
  • Code standards
  • Testing requirements
  • Commit message format
  • Pull request process

📄 License

MIT © Manu Overa

See LICENSE for details.


🔗 Related Projects


Author Manu Overa

Report BugRequest FeatureDiscussions