npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fleetlog

v0.0.5

Published

Fleetlog API wrapper

Downloads

8

Readme

Fleetlog Node

Fleetlog API wrapper

Installation

npm install fleetlog

API Overview

This SDK is designed to be the simplest way to make request to the Fleetlog API.

var fleetlog = require('fleetlog');

// see Examples for obtaining an access token.
fleetlog.identity(token, function (err, userObject){
  if (!error) {
  	console.log(userObject)  
  }
})

Methods

identity

  • identity(token string, callback function)
fleetlog.identity('access-token', function (err, userObject){
  	console.log(userObject)  
})

getVehicles

  • identity(token string, callback function)
fleetlog.getVehicles('access-token', { limit: 5, offset: 0}, function (err, vehicles){
  	console.log(vehiclesArray)  
})

getTrips

  • identity(token string, query object, callback function)
fleetlog.getTrips('access-token', { limit: 5, offset: 0}, function (err, trips){
  	console.log(tripsArray)  
})

getTrip

  • identity(token string, tripId number, query object, callback function)
fleetlog.getTrip('access-token', 12345, null, function (err, tripObject){
  	console.log(tripObject)  
})

getVehicle

  • identity(token string, vehicleId number, query object, callback function)
fleetlog.getVehicle('access-token', 12345, null, function (err, vehicleObject){
  	console.log(vehicleObject)  
})

getCoordinates

  • identity(token string, query object, callback function)
fleetlog.getCoordinates('access-token', { fields: ['latitude', 'longitude', 'id', 'datetime']}, function (err, coordinates){
  	console.log(coordinatesArray)  
})

getTripWithCoordinates

  • identity(token string, tripId number, query object, callback function)
fleetlog.getTripWithCoordinates('access-token', 12345, { 'coordinates[fields]': 'datetime'}, function (err, tripObject){
  	console.log(tripObject)  
})

Custom request

  • _fleetlogRequest(method string, path string, data object, token string, callback function)
fleetlog._fleetlogRequest('GET', 'trips?limit=5&offset=0', null, 'access-token', function (err, response){
	// Response object
	// { "status": 200, data: [...]} or { "status": 200, data: {...}}
  	console.log(response)  
})

Examples Apps

In order to make authorized calls to Fleetlog API, your application must first obtain an OAuth 2.0 access token on behalf of a Fleetlog user or you could issue Application-only authenticated requests when user context is not required. The way you will obtain such tokens will depend on your use case.

oAuth2-authorization-code

Access to web APIs by native clients and websites is implemented by using the OAuth 2.0.

The authorization code grant type is the most commonly used because it is optimized for server-side applications, where source code is not publicly exposed, and Client Secret confidentiality can be maintained. This is a redirection-based flow, which means that the application must be capable of interacting with the user-agent (i.e. the user's web browser) and receiving API authorization codes that are routed through the user-agent.

oauth2-resource-owner-password-credentials

The resource owner password credentials grant type is suitable in cases where the resource owner has a trust relationship with the client, such as the device operating system or a highly privileged application. The authorization server should take special care when enabling this grant type and only allow it when other flows are not viable.

This grant type is suitable for clients capable of obtaining the resource owner’s credentials (username and password, typically using an interactive form). It is also used to migrate existing clients using direct authentication schemes such as HTTP Basic or Digest authentication to OAuth by converting the stored credentials to an access token:

References from the RFC:
Resource Owner Password Credentials
Resource Owner Password Credentials Grant

Run the Example app

Run the app with environment variables

node app FLEETLOG_CLIENT_ID=<YOUR_CLIENT_ID> FLEETLOG_CLIENT_SECRET=<YOUR_CLIENT_SECRET>

Open localhost:3001 in your browser.

Support

[email protected]

License

This project is licensed under the terms of the Apache 2.0 license.