User Tools

Site Tools


oak:tutorials:particle-id-token

Oak: Particle API basics

To access the Particle API (such as using Particle.variable(), Particle.publish(), Particle.function() et al.), you will need your device ID and an access token. This short tutorial points out where to obtain those values.

Device ID

Go to build.particle.io and click the icon second from the bottom on the left hand side. It will bring up a list of your registered devices and corresponding device IDs. The icon to click and location of the first device's ID are shown outlined in red:

Access token

Next, click the bottom icon on the left, shaped like a gear. This will reveal your access token.

It may be handy to copy/paste these values somewhere locally for using with API calls (curl, python, javascript, etc.). Keep them safe, as they can be used maliciously. If you believe your token has been compromised, use the option to reset the token shown in the screenshot.

Testing

To test that the values are accurate, you can run these curl commands or simply paste the URL into a browser (substituting the appropriate values for id_here and token_here):

$ curl https://api.particle.io/v1/devices?access_token=token_here

Example response:

[
  {
    "id": "device_id_1",
    "name": "device_name_1",
    "last_app": null,
    "last_ip_address": "xx.xxx.xx.xxx",
    "last_heard": "2016-03-17T04:36:16.759Z",
    "product_id": 82,
    "connected": false,
    "platform_id": 82,
    "cellular": false,
    "status": "normal"
  },
  {
    "id": "device_id_2",
    "name": "device_name_2",
    "last_app": null,
    "last_ip_address": "xx.xxx.xx.xxx",
    "last_heard": "2016-03-20T01:51:05.680Z",
    "product_id": 82,
    "connected": true,
    "platform_id": 82,
    "cellular": false,
    "status": "normal"
  }
]

You can target a single device as well:

$ curl "https://api.particle.io/v1/devices/id_here?access_token=token_here"

Example response:

{
  "id": "device_id",
  "name": "device_name",
  "last_app": null,
  "last_ip_address": "xx.xxx.xx.xxx",
  "last_heard": "2016-03-20T01:51:05.680Z",
  "product_id": 82,
  "connected": true,
  "platform_id": 82,
  "cellular": false,
  "status": "normal",
  "variables": {
    "x": "int32"
  },
  "functions": []
}
oak/tutorials/particle-id-token.txt · Last modified: 2016/03/22 21:56 by jwhendy