garage61-js-client

1.0.0 • Public • Published

Garage61 Node.js Client

A Node.js client library for the Garage61 API. This library provides a simple interface to access Garage61's motorsports data and telemetry services.

Installation

npm install garage61-js-client

Authentication

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');

Quick Examples

Get User Information

const userInfo = await client.me.getInfo();
console.log(userInfo);

Get Team Information

const teamInfo = await client.teams.getInfo('team-id');
console.log(teamInfo);

Find Laps

const laps = await client.laps.find({
  tracks: [123],  // Track IDs
  cars: [456],    // Car IDs
  limit: 10       // Maximum number of results
});
console.log(laps);

Data Pack Operations

// 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');

Advanced Examples

The library includes detailed examples in the examples directory:

Lap Comparison Analysis

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:

  1. Install the required dependency:
npm install papaparse
  1. 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
  1. 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)

API Reference

User Methods

  • 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

Team Methods

  • 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

Lap Methods

  • 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

Data Pack Methods

  • 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

Content Download Methods

  • 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

Platform Methods

  • platforms.list() - Get available platforms
  • cars.list() - Get available cars
  • tracks.list() - Get available tracks
  • carGroups.list() - Get available car groups

Error Handling

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);
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i garage61-js-client

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

29.2 kB

Total Files

6

Last publish

Collaborators

  • mariocodarin