Skip to content

Installation

Get started with the iRacing Data Client SDK in your project.

Before installing the Data Client, ensure you have:

  • Node.js 18+ or a modern browser environment with fetch support
  • npm, yarn, or pnpm package manager
  • An active iRacing subscription with valid credentials
  • TypeScript 5.0+ (optional, but recommended for the best experience)
Terminal window
npm install iracing-data-client
Terminal window
yarn add iracing-data-client
Terminal window
pnpm add iracing-data-client
  1. Import the Data Client

    import { IRacingDataClient } from 'iracing-data-client';
  2. Initialize with OAuth credentials

    const iracing = new IRacingDataClient({
    auth: {
    type: 'password-limited',
    clientId: process.env.IRACING_CLIENT_ID,
    clientSecret: process.env.IRACING_CLIENT_SECRET,
    username: process.env.IRACING_USERNAME,
    password: process.env.IRACING_PASSWORD,
    },
    });
  3. Make your first API call

    const tracks = await iracing.track.get();
    console.log(`Found ${tracks.length} tracks`);

The SDK accepts these configuration options:

interface IRacingClientOptions {
auth: AuthConfig;
fetchFn?: FetchLike;
validateParams?: boolean;
validateSemanticParams?: boolean;
stores?: HttpClientStores;
}

See the Authentication guide for details on the AuthConfig types.

The recommended approach is to use environment variables:

const iracing = new IRacingDataClient({
auth: {
type: 'password-limited',
clientId: process.env.IRACING_CLIENT_ID,
clientSecret: process.env.IRACING_CLIENT_SECRET,
username: process.env.IRACING_USERNAME,
password: process.env.IRACING_PASSWORD,
},
});

Create a .env file (don’t commit to git):

IRACING_CLIENT_ID=your-client-id
IRACING_CLIENT_SECRET=your-client-secret
IRACING_USERNAME=your-iracing-email
IRACING_PASSWORD=your-iracing-password

The SDK includes TypeScript definitions out of the box. For the best experience:

  1. Ensure TypeScript is installed

    Terminal window
    npm install --save-dev typescript
    Terminal window
    npm install --save-dev @types/node
  2. Configure tsconfig.json

    {
    "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "lib": ["ES2022"],
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
    }
    }
  3. Enable type checking

    Your IDE should now provide full IntelliSense support and type checking for all SDK methods.

Works out of the box with native fetch support:

const iracing = new IRacingDataClient({
auth: { /* ... */ },
});

The SDK can be used in browser environments with some considerations:

// In a secure backend API route or serverless function
export async function getIRacingData() {
const iracing = new IRacingDataClient({
auth: {
type: 'password-limited',
clientId: process.env.IRACING_CLIENT_ID,
clientSecret: process.env.IRACING_CLIENT_SECRET,
username: process.env.IRACING_USERNAME,
password: process.env.IRACING_PASSWORD,
},
});
return await iracing.track.get();
}

The iRacing API does not support CORS for browser requests. You’ll need to:

  1. Use a backend proxy server
  2. Deploy serverless functions (Vercel, Netlify, AWS Lambda)
  3. Use a CORS proxy service (development only)
app/api/iracing/route.ts
import { IRacingDataClient } from 'iracing-data-client';
const iracing = new IRacingDataClient({
auth: {
type: 'password-limited',
clientId: process.env.IRACING_CLIENT_ID!,
clientSecret: process.env.IRACING_CLIENT_SECRET!,
username: process.env.IRACING_USERNAME!,
password: process.env.IRACING_PASSWORD!,
},
});
export async function GET() {
const data = await iracing.track.get();
return Response.json(data);
}

Test your setup with this simple script:

import { IRacingDataClient } from 'iracing-data-client';
async function testConnection() {
try {
const iracing = new IRacingDataClient({
auth: {
type: 'password-limited',
clientId: process.env.IRACING_CLIENT_ID!,
clientSecret: process.env.IRACING_CLIENT_SECRET!,
username: process.env.IRACING_USERNAME!,
password: process.env.IRACING_PASSWORD!,
},
});
const tracks = await iracing.track.get();
console.log('Connected successfully!');
console.log(`Found ${tracks.length} tracks`);
} catch (error) {
console.error('Connection failed:', error);
}
}
testConnection();

If you get authentication errors:

  • Verify your email and password are correct
  • Check if your iRacing subscription is active
  • Ensure you’re not hitting rate limits
  • Try logging into the iRacing website to verify credentials

Now that you have the Data Client installed, check out: