User Tools

Site Tools


oak:tutorials:particle-id-token

This is an old revision of the document!


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.

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:

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.

To test that the values are accurate, you can run these curl commands or simply paste the URL addresses 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.1458440571.txt.gz · Last modified: 2016/03/19 19:22 by jwhendy