GithubHelp home page GithubHelp logo

iot-alex / m2x-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from erwink/m2x-nodejs

0.0 2.0 0.0 119 KB

AT&T M2X Node.js Library

Home Page: https://m2x.att.com/developer/client-libraries

License: MIT License

JavaScript 100.00%

m2x-nodejs's Introduction

AT&T's M2X Node.js Client

AT&T M2X is a cloud-based fully managed time-series data storage service for network connected machine-to-machine (M2M) devices and the Internet of Things (IoT).

The AT&T M2X API provides all the needed operations and methods to connect your devices to AT&T's M2X service. This library aims to provide a simple wrapper to interact with the AT&T M2X API for Node.js. Refer to the Glossary of Terms to understand the nomenclature used throughout this documentation.

Getting Started

  1. Signup for an M2X Account.
  2. Obtain your Master Key from the Master Keys tab of your Account Settings screen.
  3. Create your first Device and copy its Device ID.
  4. Review the M2X API Documentation.

Installation

m2x-nodejs is available as an npm package (https://www.npmjs.com/package/m2x). Install the latest version with:

npm install m2x

Usage

M2X Class

The main object encapsulating all API functionality is the global variable M2X. In order to create a M2X object you will need an API key, which can be either a Master Key or a key belonging to a specific device (in which case you will only be allowed to read/write to this device).

The following is a short example on how to instantiate an M2X object:

var M2X = require("m2x");

var m2x = new M2X("<API-KEY>");

The M2X object also provides a simple method for checking the API status (so if you are having connectivity issues, you can check whether the API is currently down):

m2x.status(function(status) {
    console.log(status);
});

An M2X object provides methods for communicating with the remote API. Methods are organized under the following modules: keys, devices, charts and distributions.

  • Distributions

    m2x.distributions.view("<DISTRIBUTION-ID>", function(response) {
        console.log(response.json);
    });
    
    m2x.distributions.list(function(response) {
        console.log(response.json);
    });
  • Devices

    m2x.devices.view("<DEVICE-ID>", function(response) {
        console.log(response.json);
    });
    
    m2x.devices.list(function(response) {
        console.log(response.json);
    });
  • Jobs

    m2x.jobs.view("<JOB-ID>", function(response) {
        console.log(response.json);
    });
  • Keys

    m2x.keys.view("<KEY-TOKEN>", function(response) {
        console.log(response.json);
    });
    
    m2x.keys.list(function(response) {
        console.log(response.json);
    });

Time

For devices that do not have a Real Time Clock, M2X provides a set of endpoints that returns the server's time.

m2x.time(function(response) {
  console.log(response.json);
});

m2x.timeSeconds(function(response) {
  console.log(response.raw);
});

m2x.timeMillis(function(response) {
  console.log(response.raw);
});

m2x.timeIso8601(function(response) {
  console.log(response.raw);
});

Refer to the documentation on each class for further usage instructions.

Examples

//
// This is a simple application that requests the list
// of available devices for the provided API Key and then
// prints the details for each of those devices
//

var API_KEY = "<YOUR KEY>",
    M2X = require("m2x"),
    m2xClient = new M2X(API_KEY);

m2xClient.devices.list(function(response) {
    if (response.isSuccess()) {
        response.json.devices.forEach(function(device) {
            console.log(device);
        });
    } else {
        console.log(response.error());
    }
});

Example usage

You can find the examples in the examples directory.

To use them, you should set up your key in examples/config.js, then execute like: $ node examples/print-devices.js.

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. As a summary, given a version number MAJOR.MINOR.PATCH:

  1. MAJOR will increment when backwards-incompatible changes are introduced to the client.
  2. MINOR will increment when backwards-compatible functionality is added.
  3. PATCH will increment with backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Note: the client version does not necessarily reflect the version used in the AT&T M2X API.

License

This library is provided under the MIT license. See LICENSE for applicable terms.

Acknowledgements

This client is a direct port of Leandro Lopez' AT&T M2X client for Ruby so all the credit should go to him.

m2x-nodejs's People

Contributors

gabriel-garcia-zz avatar fsaravia avatar grilix avatar stream7 avatar seriousmoth avatar skazska avatar cb-frontend avatar stewart avatar kristinpeterson avatar inkel avatar adonya avatar bradybd avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.