{"_id":"552926c5ceedaa0d00bc5c71","version":{"_id":"5435693035740020002a1c1f","__v":14,"project":"5435693035740020002a1c1c","createdAt":"2014-10-08T16:41:20.702Z","releaseDate":"2014-10-08T16:41:20.702Z","categories":["5435693035740020002a1c20","551c03c1ff892b3700d1c57a","551ca3927405910d00900a59","551cac6448564a2f0024d89e","551cb4d848564a2f0024d8a3","551cb52db7a32b3b00d1ef78","5526e2064a7ac121004c6073","5526e5147d4a4417009516b3","5526e9877d4a4417009516bb","5528362cd9e1db2d00cd924d","5580240ebe698419008f2ba2","5580a7dabe698419008f2db6","568161799de23c0d00c54750","5866c905a2cbb31900f6f1aa"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"editedParams":true,"project":"5435693035740020002a1c1c","githubsync":"","__v":4,"category":{"_id":"5526e2064a7ac121004c6073","project":"5435693035740020002a1c1c","pages":["5526e2674a7ac121004c6075","5526e439e69c7d0d00047e57"],"__v":2,"version":"5435693035740020002a1c1f","sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-04-09T20:33:10.475Z","from_sync":false,"order":6,"slug":"locations","title":"Locations"},"editedParams2":true,"parentDoc":null,"user":"543569cd35740020002a1c2d","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-04-11T13:51:01.378Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"code":"GET /v1.0/locations/10/presence HTTP/1.1\nHost: api.robinpowered.com\nContent-Type: application/json\nAuthorization: Access-Token :accessToken","language":"http"}]},"method":"get","results":{"codes":[{"name":"","code":"{\n  \"meta\": {\n    \"status_code\": 200,\n    \"status\": \"OK\",\n    \"message\": \"\",\n    \"more_info\": {}\n  },\n\t\"data\": [\n    {\n      \"location_id\": 1,\n      \"space_id\": null,\n      \"user_id\": 4,\n      \"device_id\": 2,\n      \"last_seen_at\": \"2014-05-22T14:49:48+0000\",\n      \"arrived_at\": \"2014-05-22T14:49:48+0000\",\n      \"expired_at\": \"2014-05-22T14:50:18+0000\",\n      \"session_ttl\": 30,\n      \"session_active\": true,\n      \"user\": {\n        \"id\": 1,\n        \"name\": \"Brian\",\n        \"slug\": \"brian\",\n        \"avatar\": \"\",\n        \"created_at\": \"2014-05-05T16:06:58+0000\",\n        \"updated_at\": \"2014-05-05T16:06:58+0000\",\n        \"primary_email\": {\n          \"email\": \"brian:::at:::robinpowered.com\",\n          \"is_verified\": false\n        }\n      }\n    },\n    {\n      \"location_id\": 1,\n      \"space_id\": 1,\n      \"user_id\": null,\n      \"device_id\": 1,\n      \"last_seen_at\": \"2014-05-22T14:49:52+0000\",\n      \"arrived_at\": \"2014-05-22T14:49:52+0000\",\n      \"expired_at\": \"2014-05-22T14:50:28+0000\",\n      \"session_ttl\": 30,\n      \"session_active\": true,\n      \"user\": null,\n      \"device\": {\n        \"id\": 1,\n        \"account_id\": 3,\n        \"device_manifest_id\": 13,\n        \"name\": \"PIR sensor\",\n        \"created_at\": \"2014-05-19T21:00:35+0000\",\n        \"updated_at\": \"2014-05-19T21:00:35+0000\"\n      }\n    }\n  ],\n  \"paging\": {\n    \"page\": 1,\n    \"per_page\": 10\n  }\n}","language":"json","status":200}]},"settings":"","auth":"required","params":[{"_id":"551c0ce223a1ee190034d100","ref":"","in":"path","required":true,"desc":"The ID of the location","default":"","type":"int","name":"id"},{"_id":"5526eab3e69c7d0d00047e6f","ref":"","in":"query","required":false,"desc":"Will filter by a specified space name","default":"","type":"string","name":"query"},{"_id":"5866bac01bd8d723003c7d9d","ref":"","in":"query","required":false,"desc":"A comma separated list of space IDs to filter by.","default":"","type":"string","name":"space_ids"},{"_id":"5526eab3e69c7d0d00047e6e","ref":"","in":"query","required":false,"desc":"The page of the result","default":"1","type":"int","name":"page"},{"_id":"5526eab3e69c7d0d00047e6d","ref":"","in":"query","required":false,"desc":"How many results are returned per page","default":"10","type":"int","name":"per_page"}],"url":"/locations/:id/presence"},"isReference":true,"order":4,"body":"[block:callout]\n{\n  \"type\": \"success\",\n  \"title\": \"This is great for long polling presence\",\n  \"body\": \"Polling this endpoint is the best way to track updates to your location activity across multiple spaces. Unless you're only working with a single space, using this endpoint with `space_ids` is more efficient than querying each space presence directly.\"\n}\n[/block]\n\nReturns all the current presence sessions for a location. Presence can be associated to a user or a device resource. If the presence belongs to a specific user, that user model will be embedded in the response. If it belongs to a device, likewise it will be embedded in the response.\n\nThis endpoint returns the most accurate version of presence we have for active users. Presence with a `space_id` of `null`, are location level. (e.g. Users outside a space's range, but still visible to the beacon signal)\n\nPlease note that the space ID is returned, but not the model. It is recommended that all spaces or a specific list of spaces for the location are first fetched before fetching the presence for the location. Using both these responses, spaces can be mapped to presence resources, or vice-versa.\n\nPresence reporting by a device is indicative of \"anonymous\" presence where it is not known who is in the space, just that it is occupied. This information is inferred from device data from a sensor, such as an infrared sensor.","excerpt":"Get current presence for a location","slug":"get-location-presence","type":"endpoint","title":"/locations/:id/presence"}

get/locations/:id/presence

Get current presence for a location

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

id:
required
integer
The ID of the location

Query Params

query:
string
Will filter by a specified space name
space_ids:
string
A comma separated list of space IDs to filter by.
page:
integer1
The page of the result
per_page:
integer10
How many results are returned per page

Examples


Result Format


Documentation

[block:callout] { "type": "success", "title": "This is great for long polling presence", "body": "Polling this endpoint is the best way to track updates to your location activity across multiple spaces. Unless you're only working with a single space, using this endpoint with `space_ids` is more efficient than querying each space presence directly." } [/block] Returns all the current presence sessions for a location. Presence can be associated to a user or a device resource. If the presence belongs to a specific user, that user model will be embedded in the response. If it belongs to a device, likewise it will be embedded in the response. This endpoint returns the most accurate version of presence we have for active users. Presence with a `space_id` of `null`, are location level. (e.g. Users outside a space's range, but still visible to the beacon signal) Please note that the space ID is returned, but not the model. It is recommended that all spaces or a specific list of spaces for the location are first fetched before fetching the presence for the location. Using both these responses, spaces can be mapped to presence resources, or vice-versa. Presence reporting by a device is indicative of "anonymous" presence where it is not known who is in the space, just that it is occupied. This information is inferred from device data from a sensor, such as an infrared sensor.

User Information

Try It Out

get
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}