Skip to content

Latest commit

 

History

History
126 lines (93 loc) · 3.25 KB

README.md

File metadata and controls

126 lines (93 loc) · 3.25 KB

iRacing Web SDK

Web SDK for interacting with the iRacing API. This will allow users to easily create their projects without the hassle of having to set up authentication, cookies, and API calls.

Table of Contents

Installation

To install and use in your project run the following command:

npm install iracing-client

or

pnpm install iracing-client

Usage

Note: You must have an active iRacing account to use the SDK.

Authentication

First, you must authenticate with the iRacing API to be able to use the functions in the SDK.

import IRacingSDK from "iracing-web-sdk"

async function login() {
  const sdk = new IRacingSDK("email", "password")
  await sdk.authenticate()
  return sdk.authen
}

Example Authentication Flow

import IRacingSDK from "iracing-web-sdk"

async function login() {
  const sdk = new IRacingSDK("email", "password")
  await sdk.authenticate()
  return sdk.authenticated
}

async function main() {
  const authenticated = await login()
  if (!authenticated) {
    console.error("Failed to authenticate")
    return
  }
  console.log("Authenticated Successfully!")
}

main()

Example Function Usage

Once authenticated, you can then use any functions in the SDK.

import IRacingSDK from "iracing-web-sdk"

async function login() {
  const sdk = new IRacingSDK("email", "password")
  await sdk.authenticate()
  return sdk
}

async function fetchAllCars({ sdk }: { sdk: IRacingSDK }) {
  const cars = await sdk.getAllCars()
  return cars
}

async function main() {
  const authenicatedSDKClient = await login()
  const cars = await fetchAllCars({ sdk: authenicatedSDKClient })
}

main()

License

MIT License

Copyright (c) 2024 Juan Saldana

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.