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
Requires
- php: >=8.3
- ext-curl: *
- ext-hash: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpunit/phpunit: ^10
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
โญ 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.