node-irsdk

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:
Installing
Make sure you have Node.js v6 x64 or later.
npm install --save node-irsdk
API documentation
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
[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')
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()
iracing ⇐ events.EventEmitter
Kind: global class
Extends: events.EventEmitter
Emits: Connected
, Disconnected
, Telemetry
, TelemetryDescription
, SessionInfo
See: EventEmitter API
new JsIrSdk()
JsIrSdk is javascript implementation of iRacing SDK.
Don't use constructor directly, use getInstance.
var iracing = require('node-irsdk').getInstance()
iRacing SDK related constants
Kind: instance property of iracing
iracing.camControls : Object
Camera controls
Kind: instance property of iracing
camControls.setState(state)
Change camera tool state
Kind: static method of camControls
var States = iracing.Consts.CameraState
var state = States.CamToolActive | States.UIHidden | States.UseMouseAimMode
iracing.camControls.setState(state)
camControls.switchToCar(carNum, [camGroupNum], [camNum])
Switch camera, focus on car
Kind: static method of camControls
carNum | Integer | String | CamFocusAt | Car to focus on |
[camGroupNum] | Integer | Select camera group |
[camNum] | Integer | Select camera |
iracing.camControls.switchToCar(2)
iracing.camControls.switchToCar('02')
iracing.camControls.switchToCar('leader')
iracing.camControls.switchToCar(2, 3)
camControls.switchToPos(position, [camGroupNum], [camNum])
Switch camera, focus on position
Kind: static method of camControls
position | Integer | CamFocusAt | Position to focus on |
[camGroupNum] | Integer | Select camera group |
[camNum] | Integer | Select camera |
iracing.camControls.switchToPos(2)
iracing.playbackControls : Object
Replay and playback controls
Kind: instance property of iracing
playbackControls.play()
Play replay
Kind: static method of playbackControls
iracing.playbackControls.play()
playbackControls.pause()
Pause replay
Kind: static method of playbackControls
iracing.playbackControls.pause()
playbackControls.fastForward([speed])
fast-forward replay
Kind: static method of playbackControls
[speed] | Integer | 2 | FF speed, something between 2-16 works |
iracing.playbackControls.fastForward()
playbackControls.rewind([speed])
rewind replay
Kind: static method of playbackControls
[speed] | Integer | 2 | RW speed, something between 2-16 works |
iracing.playbackControls.rewind()
playbackControls.slowForward([divider])
slow-forward replay, slow motion
Kind: static method of playbackControls
[divider] | Integer | 2 | divider of speed, something between 2-17 works |
iracing.playbackControls.slowForward(2)
playbackControls.slowBackward([divider])
slow-backward replay, reverse slow motion
Kind: static method of playbackControls
[divider] | Integer | 2 | divider of speed, something between 2-17 works |
iracing.playbackControls.slowBackward(2)
playbackControls.search(searchMode)
Search things from replay
Kind: static method of playbackControls
iracing.playbackControls.search('nextIncident')
playbackControls.searchTs(sessionNum, sessionTimeMS)
Search timestamp
Kind: static method of playbackControls
sessionNum | Integer | Session number |
sessionTimeMS | Integer | Session time in milliseconds |
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
frameNum | Integer | Frame number |
rpyPosMode | RpyPosMode | Is frame number relative to begin, end or current frame |
iracing.playbackControls.searchFrame(1, 'current')
iracing.telemetry
Latest telemetry, may be null or undefined
Kind: instance property of iracing
iracing.telemetryDescription
Latest telemetry, may be null or undefined
Kind: instance property of iracing
iracing.sessionInfo
Latest telemetry, may be null or undefined
Kind: instance property of iracing
iracing.execCmd(msgId, [arg1], [arg2], [arg3])
Execute any of available commands, excl. FFB command
Kind: instance method of iracing
msgId | Integer | Message id |
[arg1] | Integer | 1st argument |
[arg2] | Integer | 2nd argument |
[arg3] | Integer | 3rd argument |
iracing.reloadTextures()
Reload all car textures
Kind: instance method of iracing
iracing.reloadTextures()
iracing.reloadTexture(carIdx)
Reload car's texture
Kind: instance method of iracing
carIdx | Integer | car to reload |
iracing.reloadTexture(1)
iracing.execChatCmd(cmd, [arg])
Execute chat command
Kind: instance method of iracing
iracing.execChatCmd('cancel')
iracing.execChatMacro(num)
Execute chat macro
Kind: instance method of iracing
num | Integer | Macro's number (0-15) |
iracing.execChatMacro(1)
iracing.execPitCmd(cmd, [arg])
Execute pit command
Kind: instance method of iracing
cmd | PitCommand | |
[arg] | Integer | Command argument, if needed |
iracing.execPitCmd('clear')
iracing.execPitCmd('fuel', 999)
iracing.execPitCmd('lf')
iracing.execPitCmd('lr', 200)
iracing.execTelemetryCmd(cmd)
Control telemetry logging (ibt file)
Kind: instance method of iracing
iracing.execTelemetryCmd('restart')
"Connected"
iRacing, sim, is started
Kind: event emitted by iracing
iracing.on('Connected', function (evt) {
console.log(evt)
})
"Disconnected"
iRacing, sim, was closed
Kind: event emitted by iracing
iracing.on('Disconnected', function (evt) {
console.log(evt)
})
"TelemetryDescription"
Telemetry description, contains description of available telemetry values
Kind: event emitted by iracing
iracing.on('TelemetryDescription', function (data) {
console.log(evt)
})
"Telemetry"
Telemetry update
Kind: event emitted by iracing
iracing.on('Telemetry', function (evt) {
console.log(evt)
})
"SessionInfo"
SessionInfo update
Kind: event emitted by iracing
iracing.on('SessionInfo', function (evt) {
console.log(evt)
})
"update"
any update event
Kind: event emitted by iracing
iracing.on('update', function (evt) {
console.log(evt)
})
iracing~sessionInfoParser ⇒ Object
Parser for SessionInfo YAML
Kind: inner typedef of iracing
Returns: Object
- parsed session info
sessionInfo | String | SessionInfo YAML |
IrSdkConsts
IrSdkConsts, iRacing SDK constants/enums.
Kind: global constant
var IrSdkConsts = require('node-irsdk').getInstance().Consts
IrSdkConsts.BroadcastMsg
Available command messages.
Kind: static enum of IrSdkConsts
Properties
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) |
IrSdkConsts.CameraState
Camera state
Camera state is bitfield; use these values to compose a new state.
Kind: static enum of IrSdkConsts
Properties
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 |
IrSdkConsts.RpyPosMode
Kind: static enum of IrSdkConsts
Properties
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 |
IrSdkConsts.RpySrchMode
Kind: static enum of IrSdkConsts
Properties
ToStart | 0 |
ToEnd | 1 |
PrevSession | 2 |
NextSession | 3 |
PrevLap | 4 |
NextLap | 5 |
PrevFrame | 6 |
NextFrame | 7 |
PrevIncident | 8 |
NextIncident | 9 |
IrSdkConsts.RpyStateMode
Kind: static enum of IrSdkConsts
Properties
EraseTape | 0 | Clear any data in the replay tape (works only if replay spooling disabled) |
IrSdkConsts.ReloadTexturesMode
Kind: static enum of IrSdkConsts
Properties
IrSdkConsts.ChatCommand
Kind: static enum of IrSdkConsts
Properties
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 |
IrSdkConsts.PitCommand
Kind: static enum of IrSdkConsts
Properties
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 |
IrSdkConsts.TelemCommand
Kind: static enum of IrSdkConsts
Properties
Stop | 0 | Turn telemetry recording off |
Start | 1 | Turn telemetry recording on |
Restart | 2 | Write current file to disk and start a new one |
IrSdkConsts.CamFocusAt
When switching camera, these can be used instead of car number / position
Kind: static enum of IrSdkConsts
Properties
Incident | -3 | |
Leader | -2 | |
Exciting | -1 | |
Driver | 0 | Use car number / position instead of this |
Development
To develop node-irsdk
itself, you need working working installation of
node-gyp.
Useful commands:
npm install
builds binary addon
npm run ready
runs tests and updates docs
Making a new release
- 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
.
License
Released under the MIT License.
Credits
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)