GET /v2/locations
Return all the locations
GET /v2/users/:user_id/locations
Return all the locations of the given User
GET /v2/campus/:campus_id/locations
Return all the locations of the given Campus
live_help Notes
chrome_reader_mode
This resource is paginated by 30 items
settings Params
Param name | Description |
---|---|
user_id |
optional
. Must be String
The user id or slug |
campus_id |
optional
. Must be String
The campus id or slug |
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:
|
page |
optional
. Must be a Hash
The pagination params, as a hash |
page[number] |
optional
. Must be Fixnum
The current page |
page[size] |
optional
. Must be Fixnum
The number of items per page, defaults to 30, maximum 100 |
Examples
GET /v2/locations
200
[
{
"id": 6,
"begin_at": "2017-11-22T13:42:10.248Z",
"end_at": "2017-11-22T13:42:10.248Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "ariel",
"campus_id": 1,
"user": {
"id": 120,
"login": "obkenobi",
"url": "https://api.intra.42.fr/v2/users/obkenobi"
}
},
{
"id": 1,
"begin_at": "2017-11-22T13:42:09.406Z",
"end_at": "2017-11-22T13:42:09.406Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "puck",
"campus_id": 1,
"user": {
"id": 73,
"login": "padmamid",
"url": "https://api.intra.42.fr/v2/users/padmamid"
}
},
{
"id": 7,
"begin_at": "2017-11-21T13:42:10.737Z",
"end_at": "2017-11-21T14:42:10.737Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "ganymede",
"campus_id": 1,
"user": {
"id": 53,
"login": "dvader",
"url": "https://api.intra.42.fr/v2/users/dvader"
}
}
]
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/locations"
[
{
"id": 6,
"begin_at": "2017-11-22T13:42:10.248Z",
"end_at": "2017-11-22T13:42:10.248Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "ariel",
"campus_id": 1,
"user": {
"id": 120,
"login": "obkenobi",
"url": "https://api.intra.42.fr/v2/users/obkenobi"
}
},
{
"id": 1,
"begin_at": "2017-11-22T13:42:09.406Z",
"end_at": "2017-11-22T13:42:09.406Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "puck",
"campus_id": 1,
"user": {
"id": 73,
"login": "padmamid",
"url": "https://api.intra.42.fr/v2/users/padmamid"
}
},
{
"id": 7,
"begin_at": "2017-11-21T13:42:10.737Z",
"end_at": "2017-11-21T14:42:10.737Z",
"primary": true,
"floor": null,
"row": null,
"post": null,
"host": "ganymede",
"campus_id": 1,
"user": {
"id": 53,
"login": "dvader",
"url": "https://api.intra.42.fr/v2/users/dvader"
}
}
]
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")
response.status
# => 200
response.parsed
# => [{"id"=>6, "begin_at"=>"2017-11-22T13:42:10.248Z", "end_at"=>"2017-11-22T13:42:10.248Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"ariel", "campus_id"=>1, "user"=>{"id"=>120, "login"=>"obkenobi", "url"=>"https://api.intra.42.fr/v2/users/obkenobi"}}, {"id"=>1, "begin_at"=>"2017-11-22T13:42:09.406Z", "end_at"=>"2017-11-22T13:42:09.406Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"puck", "campus_id"=>1, "user"=>{"id"=>73, "login"=>"padmamid", "url"=>"https://api.intra.42.fr/v2/users/padmamid"}}, {"id"=>7, "begin_at"=>"2017-11-21T13:42:10.737Z", "end_at"=>"2017-11-21T14:42:10.737Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"ganymede", "campus_id"=>1, "user"=>{"id"=>53, "login"=>"dvader", "url"=>"https://api.intra.42.fr/v2/users/dvader"}}]