GET /v2/products
Return all the products
GET /v2/campus/:campus_id/products
Return all the products of the given Campus
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. MoreExample: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 MoreExample:
To filter on products with the
...&filter[id]=a_value,another_value Filterable fields:
|
| 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 MoreExample:
To range on products with the
...&range[one_time_purchase]=min_value,max_value Rangeable fields:
|
Examples
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}]