GET
/users/?search=:type&min=:timestamp&max=:timestampFind users by date
You can find users based on their first_seen, last_seen, last_contacted, or updated_at attributes. These results can be filtered by conditions defined in the request body.
| Attributes | Type | Required | Description |
|---|---|---|---|
| search | fixed | yes | An attribute through which you can search. 4 types to choose from: first_seen, last_seen, last_contacted, updated_at (UNIX format) |
| min | timestamp | no | A start date of search in UNIX format. |
| max | timestamp | no | An end date of search in UNIX format. |
| with_email | boolean | no | If value is set up to true results includes only users with emails. |
| tags | string | no | A tag name. |
The lookup value has to be in ISO-8601 format.
| Lookup | Description | Example usage |
|---|---|---|
| __lt | Lesser than | ?first_seen__lt=2019-05-16+00:00 |
| __lte | Lesser than or equal | ?first_seen__lte=2019-05-16+00:00 |
| __gt | Greater than | ?first_seen__gt=2019-05-16+00:00 |
| __gte | Greater than or equal | ?first_seen__gte=2019-05-16+00:00 |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X GET -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2"
-H "Accept: */*; version=2" -H "Content-Type: application/json" "https://<your_app_subdomain>.user.com/api/public/users/?search=last_seen&min=1477008000&max=1477139136"
var data = null;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://<your_app_subdomain>.user.com/api/public/users/?search=last_seen&min=1477008000&max=1477139136");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/users/?search=last_seen&min=1477008000&max=1477139136",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
import http.client
conn = http.client.HTTPSConnection("<your_app_subdomain>.user.com")
headers = {
'authorization': "Token <your_64_char_api_key>",
'Accept': "*/*; version=2",
'content-type': "application/json"
}
conn.request("GET", "/api/public/users/?search=last_seen&min=1477008000&max=1477139136", headers=headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Response
{
"next": null,
"count": 1,
"results": [
{
"google_url": null,
"first_seen": null,
"region": null,
"unsubscribed": false,
"city": null,
"name": "Jane Doe",
"browser_language": null,
"gravatar_url": "https://randomuser.me/api/portraits/men/51.jpg",
"updated_at": "2017-06-14T07:06:18.495809Z",
"gender": "unknown",
"phone_number": null,
"last_seen": "2017-06-14T11:06:08.182761Z",
"id": 19678376,
"os_type": null,
"notifications": true,
"country": null,
"page_views": 0,
"timezone": null,
"score": 0,
"linkedin_url": null,
"tags": [
{
"id": 1441,
"name": "tag"
}
],
"attributes": [
{
"value": true,
"name": "Example attr",
"name_std": "example_attr",
"id": 1109
},
{
"value": "attribute value",
"name": "My string attr",
"name_std": "my_string_attr",
"id": 2429
}
],
"twitter_url": null,
"key": "g3FaYocCy0U6",
"created_at": "2017-06-07T09:41:13.466897Z",
"facebook_url": null,
"last_contacted": null,
"lists": [],
"chat_id": "Chat ID is deprecated and will be removed in future",
"resolution": null,
"last_ip": null,
"status": "visitor",
"email": "updated@email.com",
"browser": null
}
],
"previous": null
}