# mg-api-node

> Nodejs client for the MyGeotab API

Latest version **1.3.1** (published 2022-07-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install mg-api-node
pnpm add mg-api-node
yarn add mg-api-node
bun add mg-api-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-07-19 |
| First published | 2015-09-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 33.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Steve Hansen |
| Maintainers | beefo |
| Keywords | mygeotab, geotab, api, node, nodejs |

## Links

- npm: https://www.npmjs.com/package/mg-api-node
- Repository: https://github.com/Geotab/mg-api-node
- Homepage: https://github.com/Geotab/mg-api-node#readme
- Issues: https://github.com/Geotab/mg-api-node/issues
- npm.io page: https://npm.io/package/mg-api-node

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.3.1 (latest) — 2022-07-19
- 1.3.0 — 2020-05-08
- 1.2.0 — 2019-01-07
- 1.0.1 — 2016-08-16
- 1.0.0 — 2015-09-19

## README

# This project has been deprecated. Please use [mg-api-js](https://github.com/Geotab/mg-api-js).

# mg-api-node #

Unofficial nodejs client for the MyGeotab API

### Getting Started ###

```javascript
$ npm install mg-api-node --save
```

### Usage ###
```javascript
var api = new API(userName, password, database);

api.authenticate(function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  api.call('Get', {
    typeName: 'User',
    search: {
      name: data.userName
    }
  }, function(err, data) {

    if(err){
      console.log('Error', err);
      return;
    }

    console.log('User', data);

  });

});
```

#### HTTP Timeout ####

If you need to handle potential slow HTTP requests, you can access [request.setTimeout](https://nodejs.org/api/http.html#http_request_settimeout_timeout_callback) by passing an optional timeout (ms) and timeoutCallback to `api.call()` and `api.multicall()`:

```javascript
var api = new API(userName, password, database, server, {ssl: false}, sessionId);

// Timeout (ms) and TimeoutCallback
api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {
  if(err){
    console.log('Error', err);
    return;
  }
  console.log('User', data);
}, 10000, function(){
    console.log('Timeout');
});

// Just Timeout
api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {
  if(err){
    console.log('Error', err);
    return;
  }
  console.log('User', data);
}, 10000);

```

#### Session ID ####

It's also possible to supply session ID and direct server to re-use a session ID. This avoids costly authentication.

```javascript
var api = new API(userName, password, database, server, options, sessionId);

api.call('Get', {
  typeName: 'User',
  resultsLimit: 1
}, function(err, data) {

  if(err){
    console.log('Error', err);
    return;
  }

  console.log('User', data);

});

```

### Running Tests ###
```javascript
$ npm install -g mocha
$ npm install
$ mocha
```

---
_Source: https://npm.io/package/mg-api-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
