GET /v2/locations/graph(/on/:field(/by/:interval))
Return grouped temporal data on locations
Count all occurences on a particular field (default on begin_at
) by a particular period, starting from the first occurence to now.
settings Params
Param name | Description |
---|---|
field |
optional
. Must be one of: begin_at , end_at .
The date field to graph on. Default to |
interval |
optional
. Must be one of: day , week , month , quarter , year , hour_of_day , day_of_week , day_of_month , month_of_year .
The interval to graph by. Default to |
sort |
optional
. Must be one of: id , user_id , begin_at , end_at , primary , host , campus_id .
The sort field. Sorted by begin_at desc, id desc by default. MoreExample:To sort on locations on the fields host on a descending order and campus_id on a ascending order: ...&sort=-host,campus_id |
filter |
optional
. Must be one of: id , user_id , begin_at , end_at , primary , host , campus_id , active , inactive , future , end .
Filtering on one or more fields MoreExample:
To filter on locations with the
...&filter[id]=a_value,another_value Filterable fields:
|
range |
optional
. Must be one of: id , user_id , begin_at , end_at , primary , host , campus_id .
Select on a particular range MoreExample:
To range on locations with the
...&range[campus_id]=min_value,max_value Rangeable fields:
|
Examples
GET /v2/locations/graph/on/begin_at/by/day
200
{
"2017-11-13": 1,
"2017-11-14": 1,
"2017-11-15": 1,
"2017-11-16": 1,
"2017-11-17": 1,
"2017-11-18": 2,
"2017-11-19": 2,
"2017-11-20": 2,
"2017-11-21": 2,
"2017-11-22": 2
}
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/locations/graph/on/begin_at/by/day"
{
"2017-11-13": 1,
"2017-11-14": 1,
"2017-11-15": 1,
"2017-11-16": 1,
"2017-11-17": 1,
"2017-11-18": 2,
"2017-11-19": 2,
"2017-11-20": 2,
"2017-11-21": 2,
"2017-11-22": 2
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token
response = token.get("/v2/locations/graph/on/begin_at/by/day")
response.status
# => 200
response.parsed
# => {"2017-11-13"=>1, "2017-11-14"=>1, "2017-11-15"=>1, "2017-11-16"=>1, "2017-11-17"=>1, "2017-11-18"=>2, "2017-11-19"=>2, "2017-11-20"=>2, "2017-11-21"=>2, "2017-11-22"=>2}