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.

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, 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)
  • 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, 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
  • primary
  • host
  • campus_id
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

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"}}]