Unofficial iRacing SDK implementation for Node.js.
node-irsdk provides data access (live telemetry and session info) and most of available commands. You can find some usage examples from utils directory, and there is some data samples too.
Other iRSDK implementations:
Make sure you have Node.js v6 x64 or later.
npm install --save node-irsdk
irsdk.init([opts]) ⇒ iracing
Initialize JsIrSdk, can be done once before using getInstance first time.
Kind: static method of irsdk
Returns: iracing
- Running instance of JsIrSdk
Param | Type | Default | Description |
---|---|---|---|
[opts] | Object |
Options | |
[opts.telemetryUpdateInterval] | Integer |
0 |
Telemetry update interval, milliseconds |
[opts.sessionInfoUpdateInterval] | Integer |
0 |
SessionInfo update interval, milliseconds |
[opts.sessionInfoParser] | sessionInfoParser |
Custom parser for session info |
var irsdk = require('node-irsdk')
// look for telemetry updates only once per 100 ms
var iracing = irsdk.init({telemetryUpdateInterval: 100})
irsdk.getInstance() ⇒ iracing
Get initialized instance of JsIrSdk
Kind: static method of irsdk
Returns: iracing
- Running instance of JsIrSdk
var irsdk = require('node-irsdk')
var iracing = irsdk.getInstance()
Kind: global class
Extends: events.EventEmitter
Emits: Connected
, Disconnected
, Telemetry
, TelemetryDescription
, SessionInfo
See: EventEmitter API
- iracing ⇐
events.EventEmitter
- new JsIrSdk()
- instance
- .Consts :
IrSdkConsts
- .camControls :
Object
- .playbackControls :
Object
- .telemetry
- .telemetryDescription
- .sessionInfo
- .execCmd(msgId, [arg1], [arg2], [arg3])
- .reloadTextures()
- .reloadTexture(carIdx)
- .execChatCmd(cmd, [arg])
- .execChatMacro(num)
- .execPitCmd(cmd, [arg])
- .execTelemetryCmd(cmd)
- "Connected"
- "Disconnected"
- "TelemetryDescription"
- "Telemetry"
- "SessionInfo"
- "update"
- .Consts :
- inner
- ~sessionInfoParser ⇒
Object
- ~sessionInfoParser ⇒
JsIrSdk is javascript implementation of iRacing SDK.
Don't use constructor directly, use getInstance.
var iracing = require('node-irsdk').getInstance()
iracing.Consts : IrSdkConsts
iRacing SDK related constants
Kind: instance property of iracing
Camera controls
Kind: instance property of iracing
- .camControls :
Object
Change camera tool state
Kind: static method of camControls
Param | Type | Description |
---|---|---|
state | CameraState |
new state |
// hide UI and enable mouse aim
var States = iracing.Consts.CameraState
var state = States.CamToolActive | States.UIHidden | States.UseMouseAimMode
iracing.camControls.setState(state)
Switch camera, focus on car
Kind: static method of camControls
Param | Type | Description |
---|---|---|
carNum | Integer | String | CamFocusAt |
Car to focus on |
[camGroupNum] | Integer |
Select camera group |
[camNum] | Integer |
Select camera |
// show car #2
iracing.camControls.switchToCar(2)
// show car #02
iracing.camControls.switchToCar('02')
// show leader
iracing.camControls.switchToCar('leader')
// show car #2 using cam group 3
iracing.camControls.switchToCar(2, 3)
Switch camera, focus on position
Kind: static method of camControls
Param | Type | Description |
---|---|---|
position | Integer | CamFocusAt |
Position to focus on |
[camGroupNum] | Integer |
Select camera group |
[camNum] | Integer |
Select camera |
iracing.camControls.switchToPos(2) // show P2
Replay and playback controls
Kind: instance property of iracing
- .playbackControls :
Object
Play replay
Kind: static method of playbackControls
iracing.playbackControls.play()
Pause replay
Kind: static method of playbackControls
iracing.playbackControls.pause()
fast-forward replay
Kind: static method of playbackControls
Param | Type | Default | Description |
---|---|---|---|
[speed] | Integer |
2 |
FF speed, something between 2-16 works |
iracing.playbackControls.fastForward() // double speed FF
rewind replay
Kind: static method of playbackControls
Param | Type | Default | Description |
---|---|---|---|
[speed] | Integer |
2 |
RW speed, something between 2-16 works |
iracing.playbackControls.rewind() // double speed RW
slow-forward replay, slow motion
Kind: static method of playbackControls
Param | Type | Default | Description |
---|---|---|---|
[divider] | Integer |
2 |
divider of speed, something between 2-17 works |
iracing.playbackControls.slowForward(2) // half speed
slow-backward replay, reverse slow motion
Kind: static method of playbackControls
Param | Type | Default | Description |
---|---|---|---|
[divider] | Integer |
2 |
divider of speed, something between 2-17 works |
iracing.playbackControls.slowBackward(2) // half speed RW
Search things from replay
Kind: static method of playbackControls
Param | Type | Description |
---|---|---|
searchMode | RpySrchMode |
what to search |
iracing.playbackControls.search('nextIncident')
Search timestamp
Kind: static method of playbackControls
Param | Type | Description |
---|---|---|
sessionNum | Integer |
Session number |
sessionTimeMS | Integer |
Session time in milliseconds |
// jump to 2nd minute of 3rd session
iracing.playbackControls.searchTs(2, 2*60*1000)
Go to frame. Frame counting can be relative to begin, end or current.
Kind: static method of playbackControls
Param | Type | Description |
---|---|---|
frameNum | Integer |
Frame number |
rpyPosMode | RpyPosMode |
Is frame number relative to begin, end or current frame |
iracing.playbackControls.searchFrame(1, 'current') // go to 1 frame forward
Latest telemetry, may be null or undefined
Kind: instance property of iracing
Latest telemetry, may be null or undefined
Kind: instance property of iracing
Latest telemetry, may be null or undefined
Kind: instance property of iracing
Execute any of available commands, excl. FFB command
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
msgId | Integer |
Message id |
[arg1] | Integer |
1st argument |
[arg2] | Integer |
2nd argument |
[arg3] | Integer |
3rd argument |
Reload all car textures
Kind: instance method of iracing
iracing.reloadTextures() // reload all paints
Reload car's texture
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
carIdx | Integer |
car to reload |
iracing.reloadTexture(1) // reload paint of carIdx=1
Execute chat command
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
cmd | ChatCommand |
|
[arg] | Integer |
Command argument, if needed |
iracing.execChatCmd('cancel') // close chat window
Execute chat macro
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
num | Integer |
Macro's number (0-15) |
iracing.execChatMacro(1) // macro 1
Execute pit command
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
cmd | PitCommand |
|
[arg] | Integer |
Command argument, if needed |
// full tank, no tires, no tear off
iracing.execPitCmd('clear')
iracing.execPitCmd('fuel', 999) // 999 liters
iracing.execPitCmd('lf') // new left front
iracing.execPitCmd('lr', 200) // new left rear, 200 kPa
Control telemetry logging (ibt file)
Kind: instance method of iracing
Param | Type | Description |
---|---|---|
cmd | TelemCommand |
Command: start/stop/restart |
iracing.execTelemetryCmd('restart')
iRacing, sim, is started
Kind: event emitted by iracing
iracing.on('Connected', function (evt) {
console.log(evt)
})
iRacing, sim, was closed
Kind: event emitted by iracing
iracing.on('Disconnected', function (evt) {
console.log(evt)
})
Telemetry description, contains description of available telemetry values
Kind: event emitted by iracing
iracing.on('TelemetryDescription', function (data) {
console.log(evt)
})
Telemetry update
Kind: event emitted by iracing
iracing.on('Telemetry', function (evt) {
console.log(evt)
})
SessionInfo update
Kind: event emitted by iracing
iracing.on('SessionInfo', function (evt) {
console.log(evt)
})
any update event
Kind: event emitted by iracing
iracing.on('update', function (evt) {
console.log(evt)
})
Parser for SessionInfo YAML
Kind: inner typedef of iracing
Returns: Object
- parsed session info
Param | Type | Description |
---|---|---|
sessionInfo | String |
SessionInfo YAML |
IrSdkConsts, iRacing SDK constants/enums.
Kind: global constant
var IrSdkConsts = require('node-irsdk').getInstance().Consts
Available command messages.
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
CamSwitchPos | 0 |
Switch cam, args: car position, group, camera |
CamSwitchNum | 1 |
Switch cam, args, driver #, group, camera |
CamSetState | 2 |
Set cam state, args: CameraState, unused, unused |
ReplaySetPlaySpeed | 3 |
Set replay speed, args: speed, slowMotion, unused |
ReplaySetPlayPosition | 4 |
Jump to frame, args: RpyPosMode, Frame Number (high, low) |
ReplaySearch | 5 |
Search things from replay, args: RpySrchMode, unused, unused |
ReplaySetState | 6 |
Set replay state, args: RpyStateMode, unused, unused |
ReloadTextures | 7 |
Reload textures, args: ReloadTexturesMode, carIdx, unused |
ChatComand | 8 |
Chat commands, args: ChatCommand, subCommand, unused |
PitCommand | 9 |
Pit commands, args: PitCommand, parameter |
TelemCommand | 10 |
Disk telemetry commands, args: TelemCommand, unused, unused |
FFBCommand | 11 |
not supported by node-irsdk*: Change FFB settings, args: FFBCommandMode, value (float, high, low) |
ReplaySearchSessionTime | 12 |
Search by timestamp, args: sessionNum, sessionTimeMS (high, low) |
Camera state Camera state is bitfield; use these values to compose a new state.
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
IsSessionScreen | 1 |
Is driver out of the car |
IsScenicActive | 2 |
The scenic camera is active (no focus car) |
CamToolActive | 4 |
Activate camera tool |
UIHidden | 8 |
Hide UI |
UseAutoShotSelection | 16 |
Enable auto shot selection |
UseTemporaryEdits | 32 |
Enable temporary edits |
UseKeyAcceleration | 64 |
Enable key acceleration |
UseKey10xAcceleration | 128 |
Enable 10x key acceleration |
UseMouseAimMode | 256 |
Enable mouse aim |
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
Begin | 0 |
Frame number is relative to beginning |
Current | 1 |
Frame number is relative to current frame |
End | 2 |
Frame number is relative to end |
Kind: static enum of IrSdkConsts
Properties
Name | Default |
---|---|
ToStart | 0 |
ToEnd | 1 |
PrevSession | 2 |
NextSession | 3 |
PrevLap | 4 |
NextLap | 5 |
PrevFrame | 6 |
NextFrame | 7 |
PrevIncident | 8 |
NextIncident | 9 |
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
EraseTape | 0 |
Clear any data in the replay tape (works only if replay spooling disabled) |
Kind: static enum of IrSdkConsts
Properties
Name | Default |
---|---|
All | 0 |
CarIdx | 1 |
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
Macro | 0 |
Macro, give macro num (0-15) as argument |
BeginChat | 1 |
Open up a new chat window |
Reply | 2 |
Reply to last private chat |
Cancel | 3 |
Close chat window |
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
Clear | 0 |
Clear all pit checkboxes |
WS | 1 |
Clean the winshield, using one tear off |
Fuel | 2 |
Request fuel, optional argument: liters |
LF | 3 |
Request new left front, optional argument: pressure in kPa |
RF | 4 |
Request new right front, optional argument: pressure in kPa |
LR | 5 |
Request new left rear, optional argument: pressure in kPa |
RR | 6 |
Request new right rear, optional argument: pressure in kPa |
ClearTires | 7 |
Clear tire pit checkboxes |
FR | 8 |
Request a fast repair |
ClearWS | 9 |
Disable clear windshield |
ClearFR | 10 |
Disable fast repair |
ClearFuel | 11 |
Disable refueling |
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
Stop | 0 |
Turn telemetry recording off |
Start | 1 |
Turn telemetry recording on |
Restart | 2 |
Write current file to disk and start a new one |
When switching camera, these can be used instead of car number / position
Kind: static enum of IrSdkConsts
Properties
Name | Default | Description |
---|---|---|
Incident | -3 |
|
Leader | -2 |
|
Exciting | -1 |
|
Driver | 0 |
Use car number / position instead of this |
To develop node-irsdk
itself, you need working working installation of
node-gyp.
Useful commands:
npm install
builds binary addonnpm run ready
runs tests and updates docs
- Check if license file needs updating
npm run ready
- Tag new version using
npm version
, push to Github - Wait for Appveyor to upload binaries
npm publish
- Add release notes to Github, helper
npm run release-notes
.
Released under the MIT License.
Parts of original irsdk used, license available here: https://github.com/apihlaja/node-irsdk/blob/master/src/cpp/irsdk/irsdk_defines.h (BSD-3-Clause)