settings Params

Param name Description
campus_id optional . Must be String

The campus id or slug

sort optional . Must be one of: id, name, description, price, quantity, begin_at, end_at, category_id, created_at, updated_at, kind, slug, image, is_uniq, one_time_purchase.

The sort field. Sorted by id desc by default.

Example:

To sort on products on the fields is_uniq on a descending order and one_time_purchase on a ascending order:

...&sort=-is_uniq,one_time_purchase

filter optional . Must be one of: id, name, description, price, quantity, begin_at, end_at, category_id, created_at, updated_at, kind, slug, image, is_uniq, one_time_purchase, future, end.

Filtering on one or more fields

Example:

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

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

Filterable fields:
  • id (standard field)
  • name (standard field)
  • description (standard field)
  • price (standard field)
  • quantity (standard field)
  • begin_at (standard field)
  • end_at (standard field)
  • category_id (standard field)
  • created_at (standard field)
  • updated_at (standard field)
  • kind (standard field)
  • slug (standard field)
  • image (standard field)
  • is_uniq (standard field)
  • one_time_purchase (standard field)
  • future : Return only products which begins in the future. Can be one of: true, false
  • end (standard field)
range optional . Must be one of: id, name, description, price, quantity, begin_at, end_at, category_id, created_at, updated_at, kind, slug, image, is_uniq, one_time_purchase.

Select on a particular range

Example:

To range on products with the one_time_purchase field between min_value and max_value:

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

Rangeable fields:
  • id
  • name
  • description
  • price
  • quantity
  • begin_at
  • end_at
  • category_id
  • created_at
  • updated_at
  • kind
  • slug
  • image
  • is_uniq
  • one_time_purchase
GET /v2/products
200
[
  {
    "id": 1,
    "name": "Jakku",
    "description": "Utapau",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.457Z",
    "updated_at": "2017-11-22T13:41:20.498Z",
    "kind": "auto",
    "slug": "jakku",
    "image": {
      "url": "/uploads/product/image/1/logo.png",
      "thumb": {
        "url": "/uploads/product/image/1/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  },
  {
    "id": 2,
    "name": "Sullust",
    "description": "Lothal",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.528Z",
    "updated_at": "2017-11-22T13:41:20.561Z",
    "kind": "auto",
    "slug": "sullust",
    "image": {
      "url": "/uploads/product/image/2/logo.png",
      "thumb": {
        "url": "/uploads/product/image/2/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  },
  {
    "id": 3,
    "name": "Geonosis",
    "description": "Naboo",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.590Z",
    "updated_at": "2017-11-22T13:41:20.621Z",
    "kind": "auto",
    "slug": "geonosis",
    "image": {
      "url": "/uploads/product/image/3/logo.png",
      "thumb": {
        "url": "/uploads/product/image/3/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  }
]
curl  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/products"

[
  {
    "id": 1,
    "name": "Jakku",
    "description": "Utapau",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.457Z",
    "updated_at": "2017-11-22T13:41:20.498Z",
    "kind": "auto",
    "slug": "jakku",
    "image": {
      "url": "/uploads/product/image/1/logo.png",
      "thumb": {
        "url": "/uploads/product/image/1/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  },
  {
    "id": 2,
    "name": "Sullust",
    "description": "Lothal",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.528Z",
    "updated_at": "2017-11-22T13:41:20.561Z",
    "kind": "auto",
    "slug": "sullust",
    "image": {
      "url": "/uploads/product/image/2/logo.png",
      "thumb": {
        "url": "/uploads/product/image/2/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  },
  {
    "id": 3,
    "name": "Geonosis",
    "description": "Naboo",
    "price": 100,
    "quantity": 20,
    "begin_at": null,
    "end_at": null,
    "category_id": 1,
    "created_at": "2017-11-22T13:41:20.590Z",
    "updated_at": "2017-11-22T13:41:20.621Z",
    "kind": "auto",
    "slug": "geonosis",
    "image": {
      "url": "/uploads/product/image/3/logo.png",
      "thumb": {
        "url": "/uploads/product/image/3/thumb_logo.png"
      }
    },
    "is_uniq": true,
    "one_time_purchase": false
  }
]
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/products")
response.status
# => 200
response.parsed
# => [{"id"=>1, "name"=>"Jakku", "description"=>"Utapau", "price"=>100, "quantity"=>20, "begin_at"=>nil, "end_at"=>nil, "category_id"=>1, "created_at"=>"2017-11-22T13:41:20.457Z", "updated_at"=>"2017-11-22T13:41:20.498Z", "kind"=>"auto", "slug"=>"jakku", "image"=>{"url"=>"/uploads/product/image/1/logo.png", "thumb"=>{"url"=>"/uploads/product/image/1/thumb_logo.png"}}, "is_uniq"=>true, "one_time_purchase"=>false}, {"id"=>2, "name"=>"Sullust", "description"=>"Lothal", "price"=>100, "quantity"=>20, "begin_at"=>nil, "end_at"=>nil, "category_id"=>1, "created_at"=>"2017-11-22T13:41:20.528Z", "updated_at"=>"2017-11-22T13:41:20.561Z", "kind"=>"auto", "slug"=>"sullust", "image"=>{"url"=>"/uploads/product/image/2/logo.png", "thumb"=>{"url"=>"/uploads/product/image/2/thumb_logo.png"}}, "is_uniq"=>true, "one_time_purchase"=>false}, {"id"=>3, "name"=>"Geonosis", "description"=>"Naboo", "price"=>100, "quantity"=>20, "begin_at"=>nil, "end_at"=>nil, "category_id"=>1, "created_at"=>"2017-11-22T13:41:20.590Z", "updated_at"=>"2017-11-22T13:41:20.621Z", "kind"=>"auto", "slug"=>"geonosis", "image"=>{"url"=>"/uploads/product/image/3/logo.png", "thumb"=>{"url"=>"/uploads/product/image/3/thumb_logo.png"}}, "is_uniq"=>true, "one_time_purchase"=>false}]