Registry / http-networking / mg-api-node

mg-api-node

JSON →
library1.3.1jsnpmunverified

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.

npm install mg-api-node
INSTALL
IMPORT
SIG · MG-API-NODE
M
mg-api-node
http-networkingjavascriptv1.3.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

API
✓ const API = require('mg-api-node');
✗ import API from 'mg-api-node';
This library uses CommonJS `require` syntax. Attempting to use ES module `import` will result in a runtime error.
API constructor
✓ const api = new API(userName, password, database);
✗ const api = mg_api_node(userName, password, database);
The primary export is a class/constructor function named `API`, which must be instantiated with `new`.

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); }); });
Debug
Known issues
breakingThis project has been officially deprecated. No further development, bug fixes, or security updates will be provided for `mg-api-node`.
fix
Migrate to the `mg-api-js` package, which is the officially supported successor. `mg-api-js` offers modern features, active maintenance, and improved API patterns.
affects: >=1.0.0
gotchaThe API exclusively uses Node.js callback patterns for asynchronous operations, which can lead to 'callback hell' in complex scenarios.
fix
For new projects or migrations, consider `mg-api-js` which utilizes Promises/async-await. If stuck with `mg-api-node`, use utility libraries like `util.promisify` (Node.js built-in) or `async` to manage callbacks.
affects: >=1.0.0
gotchaAuthentication failures, such as `InvalidUserException`, are common if credentials or the database name are incorrect or user permissions are insufficient.
fix
Ensure `userName`, `password`, and `database` are correct. Verify user permissions within MyGeotab. The library includes reauthentication logic for `InvalidUserException` but correct initial setup is critical.
affects: >=1.0.0
gotchaBy default, HTTP requests have no explicit timeout, potentially causing long hangs on slow network connections or unresponsive API endpoints.
fix
From v1.3.0 onwards, you can pass a timeout (milliseconds) and an optional timeout callback to `api.call()` and `api.multicall()` to prevent indefinite waits. For example: `api.call(..., 10000, () => console.log('Request timed out'))`.
affects: <1.3.0
Errors
Common errors & fixes
TypeError: API is not a constructor
Attempting to use `mg-api-node` with ES module `import` syntax.
fix
Change your import statement to `const API = require('mg-api-node');` to correctly load the CommonJS module.
Error: InvalidUserException
Authentication failed due to incorrect username, password, or database name, or insufficient user permissions.
fix
Double-check your `userName`, `password`, and `database` parameters. Ensure the provided user has necessary API access within the MyGeotab system.
Error: read ECONNRESET
The connection to the MyGeotab API server was reset, possibly due to server-side issues, network instability, or an intermediate proxy.
fix
Implement robust error handling and retry mechanisms. Verify network connectivity and check MyGeotab's status page for outages. Ensure your environment's proxy settings are correct if applicable.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
8
OpenAI (training)
2
Bingbot
1
Resources
mg-api-node — npm install mg-api-node · libregistry