{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"REST Example","type":"basic","slug":"rest-example","excerpt":"","body":"[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var request = require('request');\\n\\n// Check Meshblu status\\nrequest('http://meshblu.octoblu.com/status', function (error, response, body) {\\n    if (!error && response.statusCode == 200) {\\nconsole.log(body) // Print Meshblu status.\\n}\\n})\\n\\n// Subscribe to UUID\\n// curl -X GET http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc?token=qirqglm6yb1vpldixflopnux4phtcsor\\nconsole.log('Subscribing to UUID: 0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc')\\nrequest.get('http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc',\\n    {qs: {'token': 'qirqglm6yb1vpldixflopnux4phtcsor'}}\\n    , function (error, response, body) {\\n        if (!error && response.statusCode == 200) {\\nconsole.log(body) // Print device activity.\\n}\\n})\\n\\n// Send message\\n// curl -X POST -d '{\\\"devices\\\": \\\"0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc\\\", \\\"payload\\\": {\\\"yellow\\\":\\\"off\\\"}}' http://meshblu.octoblu.com/messages\\nsetTimeout(function(){\\n    request.post('http://meshblu.octoblu.com/messages',\\n        {form: {'devices':'0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc', 'payload': 'test'}}\\n        , function (error, response, body) {\\n            if(response.statusCode == 200){\\n                console.log(body);\\n            }\\n        });\\n},1000);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","updates":[],"order":1,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"556747d977c15523002fd591","parentDoc":null,"version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5564f26b1fd04c0d00dc9aae","556741d17acd550d0075eaca","556741d87acd550d0075eacb","556742f87acd550d0075ead1","556781cd6976ef0d0099c545","5568d666d33aad0d00ec8d2e","557f6b2d38249b0d00d0d12b","55b67be9c2e909190073ed38","564e56c601e80e0d00396684","56731b714b2a680d00524daf","573612ac652bd80e00a90027","57365e2cf8ebd31700769f50","57366131f8ebd31700769f58","573b93514e029d19000b8669","573bbfdb7ac6f6170033bd35"],"_id":"5564f26a1fd04c0d00dc9aad","createdAt":"2015-05-26T22:23:38.671Z","project":"5564f26a1fd04c0d00dc9aaa","releaseDate":"2015-05-26T22:23:38.671Z","__v":15},"project":"5564f26a1fd04c0d00dc9aaa","createdAt":"2015-05-28T16:52:41.179Z","githubsync":"","user":"5564f227f0f70f0d00a9ab20","category":{"sync":{"isSync":false,"url":""},"pages":["5567479f77c15523002fd58f","556747d977c15523002fd591","556747fc1c38390d006980ae","556748237acd550d0075eafd"],"title":"Examples","slug":"examples","order":8,"from_sync":false,"reference":false,"_id":"556742f87acd550d0075ead1","project":"5564f26a1fd04c0d00dc9aaa","__v":4,"version":"5564f26a1fd04c0d00dc9aad","createdAt":"2015-05-28T16:31:52.010Z"},"__v":0}
[block:code] { "codes": [ { "code": "var request = require('request');\n\n// Check Meshblu status\nrequest('http://meshblu.octoblu.com/status', function (error, response, body) {\n if (!error && response.statusCode == 200) {\nconsole.log(body) // Print Meshblu status.\n}\n})\n\n// Subscribe to UUID\n// curl -X GET http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc?token=qirqglm6yb1vpldixflopnux4phtcsor\nconsole.log('Subscribing to UUID: 0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc')\nrequest.get('http://meshblu.octoblu.com/subscribe/0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc',\n {qs: {'token': 'qirqglm6yb1vpldixflopnux4phtcsor'}}\n , function (error, response, body) {\n if (!error && response.statusCode == 200) {\nconsole.log(body) // Print device activity.\n}\n})\n\n// Send message\n// curl -X POST -d '{\"devices\": \"0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc\", \"payload\": {\"yellow\":\"off\"}}' http://meshblu.octoblu.com/messages\nsetTimeout(function(){\n request.post('http://meshblu.octoblu.com/messages',\n {form: {'devices':'0d3a53a0-2a0b-11e3-b09c-ff4de847b2cc', 'payload': 'test'}}\n , function (error, response, body) {\n if(response.statusCode == 200){\n console.log(body);\n }\n });\n},1000);", "language": "javascript" } ] } [/block]