Skip to content

asaucedormz/myadmin-geotab-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myadmin-geotab-api

Unofficial nodejs client for myadmin.geotab.com https://myadmin.geotab.com/sdk#/api-reference

Installation

Using npm:

$ npm i myadmin-geotab-api

Note: add --save if you are using npm < 5.0.0

Getting Started

In Node.js:

Examples:

Using Async/Await Promises

const MyAdminAPI = require('myadmin-geotab-api');

(async function main() {
  const username = '[email protected]';
  const password = '12345678';

  const api = new MyAdminAPI({
    username,
    password,
  });
  // Call authenticate method:<Promise>
  const authData = await api.authenticateAsync();

  // get user contacts
  const userContacts = await api.callAsync('GetUserContacts', {
    forAccount: authData.accounts[0].accountId,
  });

  console.log(userContacts);
})();
const MyAdminAPI = require('myadmin-geotab-api');

(async function main() {
  const username = '[email protected]';

  //use apiKey and sessionId valids instead of password
  const apiKey = '0ff000ff-0000-0ff0-f00f-fff00f00000f';
  const sessionId = '00f0000f-0000-0fff-00f0-0fff0f00000f';

  //Use Test Environment
  //https://myadmin.geotab.com/sdk#/getting-started
  const uri = 'https://myadminapitest.geotab.com/v2/MyAdminApi.ashx';

  const api = new MyAdminAPI({
    username,
    apiKey,
    sessionId,
    uri,
  });

  // get user contacts
  const userContacts = await api.callAsync('GetUserContacts', {
    forAccount: authData.accounts[0].accountId,
  });

  console.log(userContacts);
})();

Using Promises then catch

const MyAdminAPI = require('myadmin-geotab-api');

(function main() {
  const username = '[email protected]';
  const password = '12345678';

  const api = new MyAdminAPI({
    username,
    password,
  });
  // Call authenticate method:<Promise>
  api
    .authenticateAsync()
    .then((authData) =>
      api.callAsync('GetUserContacts', {
        forAccount: authData.accounts[0].accountId,
      })
    )
    .then((userContacts) => {
      console.log(userContacts);
    })
    .catch((err) => console.error(err));
})();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published