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-clientThe 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.jsThe 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 userme.getStatistics()- Get personal driving statisticsme.getLinkedAccounts()- Get linked platform accountsme.subscribeToGroup(groupId)- Subscribe to a data pack groupme.unsubscribeFromGroup(groupId)- Unsubscribe from a data pack group
teams.list()- Get list of joined teamsteams.getInfo(teamId)- Get information about a specific teamteams.getStatistics(teamId)- Get team driving statisticsteams.createInvite(teamId, options)- Create a team inviteteams.removeMember(teamId, userId)- Remove a member from the team
laps.find(options)- Find laps and lap recordslaps.get(lapId)- Get information about a specific laplaps.getTelemetry(lapId)- Export telemetry for a lap as CSV
dataPacks.list(teamId)- Get data packs for a teamdataPacks.get(teamId, dataPackId)- Get a specific data packdataPacks.update(teamId, dataPackId, options)- Update a data packdataPacks.subscribe(dataPackId)- Subscribe to a data packdataPacks.unsubscribe(dataPackId)- Unsubscribe from a data packdataPacks.listGroups(teamId)- Get data pack groups for a teamdataPacks.getGroup(teamId, groupId)- Get a specific data pack groupdataPacks.addToGroup(teamId, groupId, dataPackId)- Add a data pack to a groupdataPacks.removeFromGroup(teamId, groupId, dataPackId)- Remove a data pack from a group
dataPacks.getGhostLap(teamId, dataPackId, itemId)- Download ghost lap filedataPacks.getLapTelemetry(teamId, dataPackId, itemId)- Export lap telemetrydataPacks.getReplay(teamId, dataPackId, itemId)- Download replay filedataPacks.getSetup(teamId, dataPackId, itemId)- Download iRacing setup file
platforms.list()- Get available platformscars.list()- Get available carstracks.list()- Get available trackscarGroups.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.