User Tools

Site Tools


oak:tutorials:particle-id-token

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
oak:tutorials:particle-id-token [2016/03/19 19:16]
jwhendy created
oak:tutorials:particle-id-token [2016/03/22 21:56]
jwhendy
Line 1: Line 1:
 +===== 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. 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 [[https://​build.particle.io/​|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: Go to [[https://​build.particle.io/​|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:
Line 5: Line 9:
 [[http://​digistump.com/​wiki/​_media/​oak/​tutorials/​particle-device-id.png|{{http://​digistump.com/​wiki/​_media/​oak/​tutorials/​particle-device-id.png?​400}}]] ​ [[http://​digistump.com/​wiki/​_media/​oak/​tutorials/​particle-device-id.png|{{http://​digistump.com/​wiki/​_media/​oak/​tutorials/​particle-device-id.png?​400}}]] ​
  
 +
 +=== Access token ===
  
 Next, click the bottom icon on the left, shaped like a gear. This will reveal your access token. Next, click the bottom icon on the left, shaped like a gear. This will reveal your access token.
Line 11: Line 17:
  
 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. 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''​):​
 +
 +<​code>​$ curl https://​api.particle.io/​v1/​devices?​access_token=token_here</​code>​
 +
 +Example response:
 +<​code>​[
 +  {
 +    "​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"​
 +  }
 +]
 +</​code>​
 +
 +You can target a single device as well:
 +
 +<​code>​$ curl "​https://​api.particle.io/​v1/​devices/​id_here?​access_token=token_here"</​code>​
 +
 +Example response:
 +
 +<​code>​
 +{
 +  "​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":​ []
 +}
 +</​code>​
oak/tutorials/particle-id-token.txt · Last modified: 2016/03/22 21:56 by jwhendy