MyGeotab Node.js API Client

1.3.1 · deprecated · verified Tue Apr 21

This package, `mg-api-node`, functions as an unofficial Node.js client for programmatically interacting with the MyGeotab API. It offers capabilities for authentication, executing API calls (such as `Get`, `call`, and `multicall`), and managing request timeouts and session IDs to optimize repeated interactions. The latest stable version is 1.3.1. Its release cadence has been infrequent, with the most recent feature addition (request timeout functionality) in v1.3.0. While it once served as a direct Node.js interface for MyGeotab, this project is now officially deprecated. Users are strongly advised to transition to the `mg-api-js` package for ongoing support, new feature development, and improved maintainability.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic authentication and a 'Get' API call to fetch user data using callback patterns.

const API = require('mg-api-node');

const userName = process.env.GEOTAB_USERNAME ?? 'YOUR_USERNAME';
const password = process.env.GEOTAB_PASSWORD ?? 'YOUR_PASSWORD';
const database = process.env.GEOTAB_DATABASE ?? 'YOUR_DATABASE'; // e.g., 'geotab-live'

const api = new API(userName, password, database);

api.authenticate(function(err, data) {
  if (err) {
    console.error('Authentication Error:', err);
    return;
  }

  console.log('Authenticated successfully. User:', data.userName);

  api.call('Get', {
    typeName: 'User',
    search: {
      name: data.userName
    }
  }, function(err, userData) {
    if (err) {
      console.error('API Call Error:', err);
      return;
    }
    console.log('User Data:', userData);
  });
});

view raw JSON →