A Node.js client library for the Garage61 API. This library provides a simple interface to access Garage61's motorsports data and telemetry services.
npm install garage61-js-client
The Garage61 API requires authentication using either a Personal Access Token or OAuth2. This client library currently supports Personal Access Token authentication.
const { Garage61Client } = require('garage61-js-client');
// Initialize with your personal access token
const client = new Garage61Client('your-access-token');
const userInfo = await client.me.getInfo();
console.log(userInfo);
const teamInfo = await client.teams.getInfo('team-id');
console.log(teamInfo);
const laps = await client.laps.find({
tracks: [123], // Track IDs
cars: [456], // Car IDs
limit: 10 // Maximum number of results
});
console.log(laps);
// Get data packs for a team
const dataPacks = await client.dataPacks.list('team-id');
// Get specific data pack
const dataPack = await client.dataPacks.get('team-id', 'datapack-id');
// Subscribe to a data pack
await client.dataPacks.subscribe('datapack-id');
The library includes detailed examples in the examples
directory:
Located in examples/lap_comparison.js
, this example demonstrates how to:
- Download and compare telemetry data from two different laps
- Analyze speed profiles
- Compare throttle and brake usage
- Examine gear usage patterns
- Study acceleration patterns (G-forces)
To run the example:
- Install the required dependency:
npm install papaparse
- Update the configuration in
examples/lap_comparison.js
:
const YOUR_ACCESS_TOKEN = 'your-access-token'; // Get this from your Garage61 account
const LAP_ID_1 = 'first-lap-id'; // Get this from the Garage61 API/interface
const LAP_ID_2 = 'second-lap-id'; // Get this from the Garage61 API/interface
- Run the example:
node examples/lap_comparison.js
The script will output a comprehensive analysis comparing the two laps, including:
- Basic lap information (times, track, car, driver)
- Speed analysis (average and maximum speeds)
- Throttle and brake usage patterns
- Gear usage distribution
- G-force analysis (lateral and longitudinal acceleration)
-
me.getInfo()
- Get information about the authenticated user -
me.getStatistics()
- Get personal driving statistics -
me.getLinkedAccounts()
- Get linked platform accounts -
me.subscribeToGroup(groupId)
- Subscribe to a data pack group -
me.unsubscribeFromGroup(groupId)
- Unsubscribe from a data pack group
-
teams.list()
- Get list of joined teams -
teams.getInfo(teamId)
- Get information about a specific team -
teams.getStatistics(teamId)
- Get team driving statistics -
teams.createInvite(teamId, options)
- Create a team invite -
teams.removeMember(teamId, userId)
- Remove a member from the team
-
laps.find(options)
- Find laps and lap records -
laps.get(lapId)
- Get information about a specific lap -
laps.getTelemetry(lapId)
- Export telemetry for a lap as CSV
-
dataPacks.list(teamId)
- Get data packs for a team -
dataPacks.get(teamId, dataPackId)
- Get a specific data pack -
dataPacks.update(teamId, dataPackId, options)
- Update a data pack -
dataPacks.subscribe(dataPackId)
- Subscribe to a data pack -
dataPacks.unsubscribe(dataPackId)
- Unsubscribe from a data pack -
dataPacks.listGroups(teamId)
- Get data pack groups for a team -
dataPacks.getGroup(teamId, groupId)
- Get a specific data pack group -
dataPacks.addToGroup(teamId, groupId, dataPackId)
- Add a data pack to a group -
dataPacks.removeFromGroup(teamId, groupId, dataPackId)
- Remove a data pack from a group
-
dataPacks.getGhostLap(teamId, dataPackId, itemId)
- Download ghost lap file -
dataPacks.getLapTelemetry(teamId, dataPackId, itemId)
- Export lap telemetry -
dataPacks.getReplay(teamId, dataPackId, itemId)
- Download replay file -
dataPacks.getSetup(teamId, dataPackId, itemId)
- Download iRacing setup file
-
platforms.list()
- Get available platforms -
cars.list()
- Get available cars -
tracks.list()
- Get available tracks -
carGroups.list()
- Get available car groups
The client will throw errors for various failure cases:
try {
const laps = await client.laps.find({ tracks: [123] });
} catch (error) {
if (error.response) {
// The request was made and the server responded with an error status
console.error('API Error:', error.response.data);
} else if (error.request) {
// The request was made but no response was received
console.error('Network Error:', error.request);
} else {
// Something else went wrong
console.error('Error:', error.message);
}
}
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.