Skip to content

Georide JavaScript API Client for Node and browsers

License

Notifications You must be signed in to change notification settings

NeilujD/georide-js

Repository files navigation

<ORG_NAME>

georide-js

georide-js is a tiny JavaScript API client for Georide which is awesome french tech, mostly if you are a motorcycle rider.

See full API documentation here.

Georide

Georide a french company that provide security and GPS features for motorcycle. To use it you need to buy from them a small box full of sensors that you put on your bike directly powered by its battery.

To make the UX great they also provide a mobile app (iOS and Android supported) and they made their API public so the users/customers can play with it.

See Georide API documentation here. See Georide services status page here.

Features

  • fetch : The project is using fetch to request the data from the API (node-fetch for Node environment). It permit to handle easyly request promises and make it usable in Node application as in browser's.

  • Customizable option : If Georide decide to change their API endpoints you can set options so your client can still works.

  • Socket client implementation : It implement socket.io client to simplify the event subscription the API provide.

Install

npm i -s georide-js

How to use

Example :

const { Client } = require('georide-js')


const EMAIL = process.env.EMAIL
const PASSWORD = process.env.PASSWORD

const main = async () => {
  // Create the client
  const client = new Client(EMAIL, PASSWORD)

  // Authenticate the user
  const token = await client.login()

  // Retrieve the user info
  const info = await client.Tracker.lock()

  // Retrieve my trackers
  const trackers = await client.User.trackers()
  const myTrackers = trackers.filter(t => t.role === 'owner')
  const myTrackerId = myTrackers[0].trackerId

  // Retrieve my tracker trips
  const trips = await client.Tracker.trips(myTrackerId, new Date('May 01, 2019 00:00:00'), new Date())

  // Lock a tracker
  await client.Tracker.lock(myTrackerId)

  // Toggle a tracker lock
  const { locked } = await client.Tracker.toggle(myTrackerId)

  // Share a trip
  const { url, shareId } = await client.Tracker.shareTrip(myTrackerId, {tripId: trips[0].id})
  
  // Subscribe to the `position` event
  client.onPosition(message => {
    const { trackerId, latitude, longitude, moving } = message
  })

  process.exit()
}

main()

Test

npm test

Contributing

Install

git clone [email protected]:NeilujD/next-blog.git
docker build ./

Tips

  • Update tests if needed
  • Update the JSDoc part