manujoz/iracing-api-sdk-php

Zero-dependency iRacing OAuth2 + Data API SDK for PHP (extractable).

Installs: 14

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/manujoz/iracing-api-sdk-php

v1.1.0 2026-01-27 00:39 UTC

This package is auto-updated.

Last update: 2026-01-27 10:26:58 UTC


README

๐Ÿ iRacing API SDK (PHP)

Zero-dependency PHP SDK for iRacing OAuth2 Authentication & Data API

PHP Composer License

โญ If you find this project useful, please give it a star! โญ

๐Ÿ“– Documentation โ€ข ๐Ÿš€ Examples โ€ข ๐Ÿ”’ Security โ€ข ๐Ÿค Contributing

๐ŸŽฏ What is this?

iracing-api-sdk-php is a zero-dependency PHP SDK that provides primitives for:

  • OAuth2 Authentication: Password Limited, Authorization Code + PKCE, token refresh
  • Data API Client: Access to iRacing's Data API (with typed generated services)
  • Session Management: List and revoke OAuth2 sessions
  • Security First: Credential masking, safe auth header forwarding, secure file caches

It is framework-agnostic by design: you bring your own logger and storage, while the library focuses on secure OAuth flows, token handling, and HTTP interactions.

โœจ Features

  • โœ… Zero runtime dependencies - Pure PHP at runtime
  • โœ… Security built-in - Never logs secrets, credential masking utilities
  • โœ… OAuth2 complete - Password Limited, Authorization Code + PKCE, token refresh
  • โœ… Typed services - Generated service wrappers under IracingApiSdk\Data\Services\*
  • โœ… Flexible storage - File-based storage + interfaces for custom implementations
  • โœ… Production friendly - Explicit error handling, rate limit utilities, and tests

๐Ÿ“ฆ Installation

composer require manujoz/iracing-api-sdk-php

๐Ÿš€ Quick Start

1. Configure Environment

Create a local .env from .env.example and set your iRacing OAuth credentials.

cp .env.example .env

2. Authenticate & Access Data

The repository ships runnable CLI examples. Recommended first run:

php examples/10-auth-password-limited.php
php examples/20-data-car-get.php

Minimal bootstrap (same classes used by the examples):

<?php

declare(strict_types=1);

use IracingApiSdk\Config\Config;
use IracingApiSdk\Http\HttpClient;
use IracingApiSdk\OAuth\OAuthClient;

$config = Config::fromEnv();
$http = new HttpClient();

$oauth = new OAuthClient($config, $http);

// Authenticate using Password Limited (credentials are loaded from env).
// Important: never print or log tokens/secrets.
// $tokenSet = $oauth->authenticatePasswordLimited(/* ... */);

๐Ÿ“š 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

๐Ÿ›ก๏ธ Security

This SDK follows strict security practices:

  • Never logs secrets - Client secrets, passwords, and tokens must never be logged
  • Credential masking - Helpers for iRacing's password masking requirements
  • Authorization header protection - Auth headers are forwarded only to trusted origins
  • Secure file storage - Token/session caches should be stored with restrictive permissions

See Security Documentation for details.

๐Ÿงช Development

Prerequisites

  • PHP โ‰ฅ 8.3
  • Composer

Commands

composer install
composer validate --no-check-all --strict
composer test
composer test:unit
composer test:integration
composer test:all

Integration tests are opt-in and only run when IRACING_RUN_INTEGRATION=1 is set (and valid credentials exist in .env).

Project Structure

src/
โ”œโ”€โ”€ Config/          # Configuration management
โ”œโ”€โ”€ Crypto/          # Credential masking
โ”œโ”€โ”€ Data/            # Data API client + generated services
โ”œโ”€โ”€ Errors/          # Exception handling
โ”œโ”€โ”€ Http/            # HTTP client abstraction
โ”œโ”€โ”€ Log/             # Logger interfaces and default error_log logger
โ”œโ”€โ”€ OAuth/           # OAuth2 flows (password_limited, auth code + PKCE) + sessions
โ”œโ”€โ”€ RateLimit/       # Rate limiting helpers
โ”œโ”€โ”€ Response/        # Response wrappers
โ”œโ”€โ”€ Token/           # Token storage and expiration handling
โ””โ”€โ”€ Utils/           # File/HTTP/token utilities

๐Ÿค Contributing

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.