Skip to content

Devices

Matthew Dowdell edited this page May 8, 2017 · 3 revisions

Register a device

To register a device, a user must be logged in and be a member of a group. Upon successful registration, the device will be assigned to the group to allow all users in the group to view the data generated by the device.

To register the device via the API, send the following to /v1/devices/register as a POST request

{
    "identity": "$identity"
}

The identity should be the identity of the device.

The response to this request if no errors occur will be:

{
    "identity": "$identity",
    "token": "$token"
}

The identity will be the same as sent in the request body. The token will be a unique token for the device that acts as a password for the device.

Example

import requests

session = requests.Session()
server = 'http://sensly.io/v1%s'
login_data = {'email': 'bill@example.com',
              'password': 'password'}

r1 = session.post(server % '/tokens')
token = r1.json()['token']
login_data['token'] = token

session.post(server % '/users/login', json=login_data)

register_data = {'identity': '00000000000000000000000000000000'}

r2 = requests.post(server % '/devices/register', json=register_data)
print r2.json()
Clone this wiki locally