The `mg-api-js` library provides a robust JavaScript wrapper for interacting with the MyGeotab API, designed for both client-side browser environments and Node.js applications. Currently stable at version `3.0.2`, the library offers a convenient abstraction over direct API calls, managing authentication via username/password or session IDs. It includes built-in credential storage (localStorage in browsers, a mock in Node.js) with options for custom datastore integration. Key differentiators include its dual-environment support and direct integration with MyGeotab's authentication mechanisms, simplifying common API interaction patterns. Releases occur on an as-needed basis, addressing bugs, security patches, and Node.js compatibility updates, such as recent fixes for Node.js 22+.
npm install mg-api-jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to initialize the GeotabApi client with credentials and options, then make a basic API call to retrieve device information. Uses environment variables for sensitive data.
Review the updated documentation on 'Full Responses' in the README to adapt your code to the new response structure when `fullResponse` is set to true.
Ensure your Node.js environment is updated to version 18.0.0 or higher to use `mg-api-js` v3.0.2 and above.
Remove the authentication callback from the `GeotabApi` constructor. Authentication is now handled implicitly or through direct credential/session ID objects.
Always provide the full server address in the `path` field of the authentication object if you are using a `sessionId`.
Explicitly set the `path` property in the authentication object if your Geotab server is not `my.geotab.com` to avoid incorrect routing.
To override the default storage, provide an object implementing `get()`, `set()`, and `clear()` methods to the `newCredentialStore` option during API initialization.
Upgrade to `mg-api-js` version `2.1.3` or higher to ensure you have the security patches for `follow-redirects`.
Upgrade to `mg-api-js` version `3.0.2` or higher to fix compatibility with Node.js 22+.
Use `import GeotabApi from 'mg-api-js';` for ESM environments, or `const GeotabApi = require('mg-api-js');` for CommonJS environments.Review the 'Full Responses' section in the library's README for `v3.0.0` onwards and adjust your code to handle the new response object structure.
Upgrade to `mg-api-js` version `2.0.1` or higher to resolve the missing `api.min.js` file for Node.js.
Upgrade to `mg-api-js` version `2.1.1` or higher to fix the bug with empty errors on multi-calls.
No dependency data recorded yet.