- All routes, with the exception of
/pin-configrequire an API key be passed in the headerSYSTEM-API-KEY - All routes, with the exception of
/pin-config,/register,/authenticaterequire an auth token be passed in theAuthorizationheader. The header value should be formattedBearer <token>. A token can be obtained using the/registeror/authenticateroutes. - The
/pin-configroute requires special authentication using three headers.io-user-emailis the email address of a registered user.io-device-idis the ID of a registered device and must also belong to the email inio-user-email.io-user-keyis a secret key generated for a user on the/user/keyroute.
POST: /register
Body:
{
"email": "something@something.com",
"password": "$ecR3tP@ssw0rd"
}Response:
{
"token": "somesuperlongauthtokenstring"
}Status Codes:
201if successful400if incorrect data provided409if email already in use
POST: /authenticate
Body:
{
"email": "something@something.com",
"password": "$ecR3tP@ssw0rd"
}Response:
{
"token": "somesuperlongauthtokenstring"
}Status Codes:
200if successful400if incorrect data provided401if incorrect credentials provided
GET: /user
Response:
{
"email": "something@something.com",
"subscription": {
"level": 1,
"end": "2015-03-13T03:07:26.204Z"
}
}Status Codes:
200if successful401if not authenticated403ifSYSTEM-API-KEYis missing
DELETE: /user
Response: None
Status Codes:
204if successful401if not authenticated403ifSYSTEM-API-KEYis missing
POST: /user/key
Body: None
Response:
{
"key": "some-secret-user-key"
}Status Codes:
201if successful401if not authenticated403ifSYSTEM-API-KEYis missing
POST: /user/device
Body: None
Response:
{
"_id": "device_id",
"userEmail": "something@something.com",
"pinConfig": []
}Status Codes:
201if successful401if not authenticated403ifSYSTEM-API-KEYis missing or subscription is expired
GET: /user/device
Response:
[
{
"_id": "device_id",
"userEmail": "something@something.com",
"pinConfig": []
}
]Status Codes:
200if successful401if not authenticated403ifSYSTEM-API-KEYis missing
GET: /user/device/:deviceId
Response:
{
"_id": "device_id",
"userEmail": "something@something.com",
"pinConfig": []
}Status Codes:
200if successful401if not authenticated403ifSYSTEM-API-KEYis missing404if deviceId does not exist
DELETE: /user/device/:deviceId
Response: None
Status Codes:
204if successful401if not authenticated403ifSYSTEM-API-KEYis missing404if deviceId does not exist
POST: /user/device/:deviceId/pin
Body:
{
"pin": 18,
"name": "Red LED",
"mode": "OUT"
}Response:
{
"pin": 18,
"name": "Red LED",
"mode": "OUT",
"initial": "LOW"
}Required Body Properties:
pin- Pin number (integer)name- Custom text label for the pinmode-INorOUT
Optional Body Properties:
resistor-PUD_UPorPUD_DOWNinitial-HIGHorLOWpinEvent-RISING,FALLING,BOTHbounce- Number of milliseconds (integer)
Status Codes:
201if successful400if invalid data401if not authenticated403ifSYSTEM-API-KEYis missing or subscription is expired
GET: /user/device/:deviceId/pin
Response:
[
{
"pin": 18,
"name": "Red LED",
"mode": "OUT",
"initial": "LOW"
}
]Status Codes:
200if successful401if not authenticated403ifSYSTEM-API-KEYis missing404if deviceId does not exist
GET: /user/device/:deviceId/pin/:pinId
Response:
{
"pin": 18,
"name": "Red LED",
"mode": "OUT",
"initial": "LOW"
}Status Codes:
200if successful401if not authenticated403ifSYSTEM-API-KEYis missing404if deviceId or pinId does not exist
DELETE: /user/device/:deviceId/pin/:pinId
Response: None
Status Codes:
204if successful401if not authenticated403ifSYSTEM-API-KEYis missing404if deviceId or pinId does not exist