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, floor, row, post, primary, host, campus_id.

The sort field. Sorted by begin_at desc by default.

Example:

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, floor, row, post, primary, host, campus_id, active, inactive, future, end.

Filtering on one or more fields

Example:

To filter on locations with the id field matching a_value or another_value:

...&filter[id]=a_value,another_value

Filterable fields:
  • id (standard field)
  • user_id (standard field)
  • begin_at (standard field)
  • end_at (standard field)
  • floor (standard field)
  • row (standard field)
  • post (standard field)
  • primary (standard field)
  • host (standard field)
  • campus_id (standard field)
  • active : Keep only active locations. Can be one of: true, false
  • inactive : Keep only inactive locations. Can be one of: true, false
  • future : Return only locations which begins in the future. Can be one of: true, false
  • end (standard field)
range optional . Must be one of: id, user_id, begin_at, end_at, floor, row, post, primary, host, campus_id.

Select on a particular range

Example:

To range on locations with the campus_id field between min_value and max_value:

...&range[campus_id]=min_value,max_value

Rangeable fields:
  • id
  • user_id
  • begin_at
  • end_at
  • floor
  • row
  • post
  • primary
  • host
  • campus_id
comments powered by <span class='logo-disqus'>Disqus</span>
GET /v2/locations
200
[
  {
    "id": 1,
    "begin_at": "2017-03-06T14:59:35.400Z",
    "end_at": "2017-03-06T14:59:35.400Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "callisto",
    "campus_id": 1,
    "user": {
      "id": 17,
      "login": "wantille",
      "url": "https://api.intra.42.fr/v2/users/wantille"
    }
  },
  {
    "id": 2,
    "begin_at": "2017-03-05T14:59:35.966Z",
    "end_at": "2017-03-05T15:59:35.966Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "phobos",
    "campus_id": 1,
    "user": {
      "id": 22,
      "login": "shpalpat",
      "url": "https://api.intra.42.fr/v2/users/shpalpat"
    }
  },
  {
    "id": 3,
    "begin_at": "2017-03-04T14:59:36.028Z",
    "end_at": "2017-03-04T16:59:36.028Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "proteus",
    "campus_id": 1,
    "user": {
      "id": 32,
      "login": "lorgana",
      "url": "https://api.intra.42.fr/v2/users/lorgana"
    }
  }
]
curl  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/locations"

[
  {
    "id": 1,
    "begin_at": "2017-03-06T14:59:35.400Z",
    "end_at": "2017-03-06T14:59:35.400Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "callisto",
    "campus_id": 1,
    "user": {
      "id": 17,
      "login": "wantille",
      "url": "https://api.intra.42.fr/v2/users/wantille"
    }
  },
  {
    "id": 2,
    "begin_at": "2017-03-05T14:59:35.966Z",
    "end_at": "2017-03-05T15:59:35.966Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "phobos",
    "campus_id": 1,
    "user": {
      "id": 22,
      "login": "shpalpat",
      "url": "https://api.intra.42.fr/v2/users/shpalpat"
    }
  },
  {
    "id": 3,
    "begin_at": "2017-03-04T14:59:36.028Z",
    "end_at": "2017-03-04T16:59:36.028Z",
    "primary": true,
    "floor": null,
    "row": null,
    "post": null,
    "host": "proteus",
    "campus_id": 1,
    "user": {
      "id": 32,
      "login": "lorgana",
      "url": "https://api.intra.42.fr/v2/users/lorgana"
    }
  }
]
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"=>1, "begin_at"=>"2017-03-06T14:59:35.400Z", "end_at"=>"2017-03-06T14:59:35.400Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"callisto", "campus_id"=>1, "user"=>{"id"=>17, "login"=>"wantille", "url"=>"https://api.intra.42.fr/v2/users/wantille"}}, {"id"=>2, "begin_at"=>"2017-03-05T14:59:35.966Z", "end_at"=>"2017-03-05T15:59:35.966Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"phobos", "campus_id"=>1, "user"=>{"id"=>22, "login"=>"shpalpat", "url"=>"https://api.intra.42.fr/v2/users/shpalpat"}}, {"id"=>3, "begin_at"=>"2017-03-04T14:59:36.028Z", "end_at"=>"2017-03-04T16:59:36.028Z", "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"proteus", "campus_id"=>1, "user"=>{"id"=>32, "login"=>"lorgana", "url"=>"https://api.intra.42.fr/v2/users/lorgana"}}]