tracktik-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.3.11 • Public • Published

TrackTik JavaScript SDK

The TrackTik JavaScript SDK is a lightweight, promise based interface to the TrackTik v1 API that works in both nodejs and browser environments. It provides common services for making API requests and helper utilities.

Documentation

Please view our full JavaScript SDK documentation at https://github.com/TrackTik/tracktik-sdk-js.

Quickstart

Install the latest version of the SDK

# instalation
npm install tracktik/tracktik-sdk#master --save
#or
yarn add tracktik/tracktik-sdk#master

Import the library using ES6 syntax

import Api, { RestApiConnectorAuth } from "tracktik-sdk";

ES5 and require to load the SDK

var SDK = require('tracktik-sdk');
var Api = SDK.default
var RestApiConnectorAuth = SDK.RestApiConnectorAuth

Once the module was imported, procceed to authenticate with the REST API

const connector = await RestApiConnectorAuth({ username: 'foo', password:'bar' })
const api = new Api(connector)

With the Api initialized, the next step is to consume the API resources.

//Create entity
const newEmployee = await api.employees.create({
  firstName: 'bob',
  lastName: 'security'
})

//Update entity
const updatedEmployee = await api.employees.update(employee.id, {
  firstName: 'alice',
  lastName: 'guard'
})

//Edit entity
const editedEmployee = await api.employees.edit(employee.id, {
  lastName: 'officer'
})

//Get one entity
const aliceEmployee = await api.employee.get(employee.id)

//Get a collection of entities
const collection = await api.employee.getAll({
  filters: [{
    field: 'lastName',
    operator: 'eq',
    value: 'officer'
  }]
})

Contributing

Please see CONTRIBUTING.md for information on how to contribute, setup the development environment and run tests.

Versioning

We will try to follow semver as close as possible. That means bug fixes will be patch releases (1.0.1 -> 1.0.2), additional functionality like new endpoints will be minor releases (1.0.1 -> 1.1.0) and breaking changes to both the library and the API endpoints it hits, will be major releases (1.0.1 -> 2.0.0).

Readme

Keywords

Package Sidebar

Install

npm i tracktik-sdk

Weekly Downloads

1,224

Version

0.3.11

License

none

Unpacked Size

202 kB

Total Files

150

Last publish

Collaborators

  • diegooliveiratt
  • vanackp
  • tuliodiaz