Ninja Blocks API

/rest/v0

Home

Core Concepts

REST

Device Protocols

See Also

List of Device IDs

Forums

Code

Mailing List

User

cURL tip: JSON responses on the command line can be very hard to read. The simplest way is to get this excellent json script and then add pipe to json | json at the end of your curl commands. Slightly more work to install but well worth the effort if you regularly work with restful APIs is the python utility HTTPie.

Resource Description
GET user Return information about the authenticated user.
GET user/stream Returns the 30 most recent entries in the authenticating user's activity stream.
GET user/pusherchannel Returns user's pusher channel key.
PUT user/realtime Sets the amount of time that 'realtime' mode will be active for. If successful, during this duration all messages received from all blocks will be forwarded via Pusher.

 

GET user

Return information about the authenticated user.

Parameters
none

Resource URL

https://api.ninja.is/rest/v0/user

Sample JSON response

{
    "email": "help@ninjablocks.com",
    "id": "1fb889da-f331-11e1-9acb-ab5bc6c99ebf",
    "name": "Ninja Support",
    "pusherChannel": "97f0b1e1-e504-f333-b7ad-eadaa8590b99"
}

 

GET user/stream

Returns the 30 most recent entries in the authenticating user's activity stream.

Parameters
none

Resource URL

https://api.ninja.is/rest/v0/user/stream

Sample JSON response

[
{
  "message": "Rule \"Door Bell\" Executed.",
  "timestamp": 1343268860669
},
{
  "message": "Rule \"Door Bell\" Executed.",
  "timestamp": 1343268810530
},
{
  "message": "Rule \"Door Bell\" Executed.",
  "timestamp": 1343268782287
},
{
  "message": "Rule \"Door Bell\" Executed.",
  "timestamp": 1343268757513
}
]

 

GET user/pusherchannel

Returns user's pusher channel key.

Parameters
none

Notes

Resource URL

https://api.ninja.is/rest/v0/user/pusherchannel

Sample JSON response

{
  "result": 1,
  "error": null,
  "id": 0,
  "data": {
    "pusherChannel": "1c0c8929-3318-411d-96e0-36fb7872ea5e"
  }
}

 

PUT user/realtime

Sets the amount of time that 'realtime' mode will be active for, defaulting to 10 seconds. If successful, during this duration all messages received from all blocks will be forwarded via Pusher.

Parameters
length
number
Optional
The amount of time to activate 'realtime' mode for. This value must be between 1 and 30. Values out of this range will be ignored, and defaulted to 10.
Example: 15

Resource URL

https://api.ninja.is/rest/v0/user/realtime

Sample JSON response

{
  "result": 1,
  "error": null,
  "id": 0
}