get https://onesignal.com/api/v1/players?app_id=:app_id&limit=:limit&offset=:offset
View the details of multiple devices in one of your OneSignal apps
Requires Authentication Key
Requires your OneSignal App's REST API Key, available in Keys & IDs.
Unavailable for Apps Over 80,000 Users
For performance reasons, this method is not available for larger apps. Larger apps should use the CSV export API endpoint, which is much more performant.
Query Parameters
Parameter | Type | Description |
---|---|---|
app_id | String | Required The app ID that you want to view devices from |
limit | String | How many devices to return. Max is 300. Default is 300 |
offset | String | Result offset. Default is 0. Results are sorted by id; |
Response Parameters
Parameter | Type | Description |
---|---|---|
invalid_identifier | boolean | If true , this is the equivalent of a user being Unsubscribed (as seen in All Users). |
Example Code - View devices
See our PUT player call for a description of the fields listed below in the example.
curl --include \
--header "Authorization: Basic NGEwMGZmMjItY2NkNy0xMWUzLTk5ZDUtMDAwYzI5NDBlNjJj" \
"https://onesignal.com/api/v1/players?app_id={appId}&limit=300&offset=0"
<?php
// NOTE: Only fetches the first 300 devices.
// Will need to add looping with offset to get all devices.
function getDevices(){
$app_id = "YOUR_ONESIGNAL_APP_ID_HERE";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/players?app_id=" . $app_id);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
'Authorization: Basic YOUR_ONESIGNAL_APP_AUTH_KEY_HERE'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = getDevices();
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n")
?>
Result Format - View devices
{
"total_count":3,
"offset":2,
"limit":2,
"players":
[
{
"identifier":"ce777617da7f548fe7a9ab6febb56cf39fba6d382000c0395666288d961ee566",
"session_count":1,
"language":"en",
"timezone":-28800,
"game_version":"1.0",
"device_os":"7.0.4",
"device_type":0,
"device_model":"iPhone",
"ad_id":null,
"tags":{"a":"1","foo":"bar"},
"last_active":1395096859,
"amount_spent":0.0,
"created_at":1395096859,
"invalid_identifier":false,
"badge_count": 0,
"external_user_id": null
}
]
}