Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
119 lines (78 sloc) 4.22 KB

AT&T M2X Ruby Client


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 Ruby. Refer to the Glossary of Terms to understand the nomenclature used throughout this documentation.

Getting Started

  1. Signup for an M2X Account.
  3. Create your first Device and copy its Device ID.
  4. Review the M2X API Documentation.


$ gem install m2x



m2x =<YOUR-API-KEY>)

This provides an interface to your data in M2X

  • Distribution

    distribution = m2x.distribution("<DISTRIBUTION-ID>")
    distributions = m2x.distributions
  • Device

    device = m2x.device("<DEVICE-ID>")
    devices = m2x.devices
  • Collection

    collection = m2x.collection("<COLLECTION-ID>")
    collections = m2x.collections
  • Key

    key = m2x.key("<KEY-TOKEN>")
    keys = m2x.keys
  • Job

    job = m2x.job("<JOB-ID>")
  • Integration

    integration = m2x.integration("<INTEGRATION-ID>")
    integrations = m2x.integrations

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


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

=> {"seconds"=>1435970368, "millis"=>1435970368451, "iso8601"=>"2015-07-04T00:39:28.451Z"}

=> "1435970400"

=> "1435970418134"

=> "2015-07-04T00:40:37.504Z"


Scripts demonstrating usage of the M2X Ruby Client Library can be found in the examples directory. Each example leverages system environment variables to inject user specific information such as the M2X API Key or Device ID. Review the example you would like to try first to determine which environment variables are required (hint: search for ENV.fetch in the example). Then make sure to set the required environment variable(s) when running the script.

For example, in order to run the m2x-uptime script, you will need a Device ID and API Key. If you have yet to create an M2X Device, access your M2X account, create a new Device, and copy the Device ID and API Key values. The script will send your CPU load average to three different streams named load_1m, load_5m and load_15. In order to execute this script, run:

$ API_KEY=<YOUR-API-KEY> DEVICE=<YOUR-DEVICE-ID> ruby ./m2x-uptime.rb


Please refer to the M2X Ruby Client Tutorials for additional hands on examples.



  3. PATCH will increment with backwards-compatible bug fixes.





You can’t perform that action at this time.