trackvia-api

    1.9.0 • Public • Published

    API-Node-SDK

    Node SDK for working with application data in TrackVia.

    Getting Started

    Login to your Trackvia account and navigate to https://go.trackvia.com/#/my-info. Copy down the API key and Account ID.

    Install via npm:

    npm install trackvia-api

    Include the source directly:

    Include the build/trackvia-api.js into your project.

    Create an instance of the Trackvia api with your API key:

    var TrackviaAPI = require('trackvia-api'); // if installed through npm
    var TrackviaAPI = require('./path/to/trackvia-api.js'); // if include manually
     
    var api = new TrackviaAPI('YOUR KEY HERE', 'ACCESS TOKEN HERE', 'HOST', 'ACCOUNT ID');

    Authenticating

    You must authenticate before accessing any data in Trackvia. There are two methods to properly authenticate: #login() and #setAccessToken(). With the API Authorization release, an access token can also be passed via the constructor.

    TrackviaAPI constructor

    var api = new TrackviaAPI('myAPIKey', 'myAccessToken', 'https://go.trackvia.com', 12345);
    // Successfully authenticated..
    // Make additional request in here

    #setAccessToken()

    api.setAccessToken('myAccessToken');
    // Successfully authenticated..
    // Make additional request in here

    #login()

    api.login('myTrackviaAccount@trackvia.com', 'myPassword')
    .then(() => {
        // Successfully authenticated..
        // Make additional request in here
    });

    Methods

    All methods return a Promise. These Promises will resolve to an object (JSON response from the request), except for files, which will resolve to a string of the binary representation of the file.


    login(username, password)

    Authenticates as specified user.

    Parameters:

    • username : string
      • Username of Trackvia account.
    • password : string

    getApps()

    Gets all apps available.

    Parameters: none


    getAppByName(name)

    Get an app by name.

    Parameters:

    • name : string

    getUsers([paging])

    Get all users, optionally paged.

    Parameters:

    • [paging : object]
      • Properties:
        • start : number
          • Starting index for paging.
        • max : number
          • Page size.

    addUser(userInfo)

    Add new user.

    Parameters:

    • userInfo: object
      • Properties:
        • email : string
        • firstName : string
        • lastName : string

    getViews()

    Get all views.

    Parameters: none


    getViewByName(name)

    Get view by name.

    Parameters:

    • name : string

    getView(id, [paging , query])

    Get view by id, optionally paged, and optionally filtered records.

    Parameters:

    • id : number
    • [paging : object]
      • Properties:
        • start : number
          • Starting index for paging.
        • max : number
          • Page size.
    • [query : string]
      • Filter record results in view

    getRecord(viewId, recordId)

    Get record by id.

    Parameters:

    • viewId : number
    • recordId : number

    addRecord(viewId, recordData)

    Add new record.

    Parameters:

    • viewId: number
    • recordData : object
      • Key value pair of field names and values for new record.

    updateRecord(viewId, recordId, recordData)

    Update exisiting record.

    Parameters:

    • viewId : number
    • recordId : number
    • recordData : object
      • Key value pair of field names and values to update in record.

    updateRecords(accountId, appId, tableId, recordData)

    Batch Update existing records.

    This method is not offically supported by TrackVia.

    Parameters:

    • accountId : number
    • appId : number
    • tableId : number
    • recordData : object
      • { 'data': [{id: 123, value: 'newValue', type: 'currency', fieldMetaId: '456'}], recordIds: [1, 2, 3] }

    deleteAllRecordsInView(viewId)

    Delete all records in a view.

    Parameters:

    • viewId : number

    deleteRecord(viewId, recordId)

    Delete record.

    Parameters:

    • viewId : number
    • recordId : number

    getFile(viewId, recordId, fieldName, [options])

    Get a file from a record.

    Parameters:

    • viewId : number
    • recordId : number
    • fieldName : string
    • [options : object]
      • Properties:
        • width : number
          • Desired width of image file
        • maxDimension : number
          • Desired max dimension for image file
        • NOTE: These options only apply when the file is an image. Options are mutually exlusive, but if both are defined, only the width will be used).

    attachFile(viewId, recordId, fieldName, filePath)

    Attach a file to a record (or overwrite and existing file).

    Parameters:

    • viewId : number
    • recordId : number
    • fieldName : string
    • filePath : string
      • Path to file being attached

    deleteFile(viewId, recordId, fieldName)

    Delete file from record.

    Parameters:

    • viewId : number
    • recordId : number
    • fieldName : string

    getAccessToken()

    Get access token for authentication.


    getUserKey()

    Get user key for authentication.

    Additional Information

    For additional information visit https://developer.trackvia.com/. Note that the endpoints explained in the docs are from the public api itself. This library is a wrapper around those endpoints to make development easier.

    Testing

    git clone git@github.com:Trackvia/API-Node-SDK.git cd API-Node-SDK npm install

    Create a file testConfig.js by copy and pasting from testConfig.template.js. Open this new file in your text editor and set up a test app and test table in your account according to the instructions. For screenshots of the test setup, open /test/testInstructions.html.

    npm test

    Keywords

    Install

    npm i trackvia-api

    DownloadsWeekly Downloads

    104

    Version

    1.9.0

    License

    ISC

    Unpacked Size

    1.48 MB

    Total Files

    16

    Last publish

    Collaborators

    • trackvia
    • kyle.turner.trackvia
    • peter.smith-trackvia