Skip to content

Products

You can access the list of 50 products by using the /products endpoint.

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products
Response
[
{
"id": 4,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"image": "https://placehold.co/600x400",
"slug": "others"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}
// ...
]

Get a single product by id

You can get a single product by adding the id as a parameter: /products/<id>

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products/4
Response
{
"id": 4,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"image": "https://placehold.co/600x400",
"slug": "others"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}

Get a single product by slug

You can get a single product by its slug using the endpoint: /products/slug/<slug>

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products/slug/handmade-fresh-table
Response
{
"id": 4,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"image": "https://placehold.co/600x400",
"slug": "others"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}

Create a product

You can create a new product by sending an object like the following to /products/

Request
Terminal window
[POST] https://api.escuelajs.co/api/v1/products/
# Body
{
"title": "New Product",
"price": 10,
"description": "A description",
"categoryId": 1,
"images": ["https://placehold.co/600x400"]
}
Response
{
"title": "New Product",
"slug": "new-product",
"price": 10,
"description": "A description",
"images": ["https://placehold.co/600x400"],
"category": {
"id": 1,
"name": "Clothes",
"image": "https://placehold.co/600x400",
"slug": "clothes"
},
"id": 210,
"creationAt": "2023-01-03T16:51:33.000Z",
"updatedAt": "2023-01-03T16:51:33.000Z"
}

Note that the categoryId should be an ID that exists in /categories and the images are an array with URLs.

Update a product

You can update a product by sending an object like the following and adding the id as a parameter: /products/<id>

Request
Terminal window
[PUT] https://api.escuelajs.co/api/v1/products/1
# Body
{
"title": "Change title",
"price": 100
}
Response
{
"id": 1,
"title": "Change title",
"slug": "change-title",
"price": 100,
"description": "The automobile layout consists of a front-engine design, with transaxle-type transmissions mounted at the rear of the engine and four wheel drive",
"images": ["https://placehold.co/600x400"],
"category": {
"id": 4,
"name": "Shoes",
"image": "https://placehold.co/600x400",
"slug": "shoes"
}
}

Note that it is not necessary to send all product attributes, just send the ones you want to update.

Delete a product

You can delete a product by adding the id as a parameter: /products/<id>

Request
Terminal window
[DELETE] https://api.escuelajs.co/api/v1/products/1
Response
true

Pagination

The API supports offset-based pagination for retrieving products in manageable chunks. Use the offset and limit query parameters to control which products are returned.

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products?offset=0&limit=10
Response
[
{
"id": 1,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"slug": "others",
"image": "https://placehold.co/600x400"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}
// ... and 9 items more
]
How pagination works
  • offset: The number of items to skip before starting to collect the result set
  • limit: The maximum number of items to return

To navigate through pages, increase the offset by the value of the limit:

RequestDescription
/products?offset=0&limit=10Return the first 10 products
/products?offset=10&limit=10Return products from 11 to 20
/products?offset=20&limit=10Return products from 21 to 30

For a pagination with 20 items per page:

RequestDescription
/products?offset=0&limit=20Return the first 20 products
/products?offset=20&limit=20Return products from 21 to 40
/products?offset=40&limit=20Return products from 41 to 60

You can access the list of related products by using the /products/<id>/related endpoint.

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products/1/related
Response
[
{
"id": 4,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"image": "https://placehold.co/600x400",
"slug": "others"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}
// ...
]

You can get the list of related products by using the /products/slug/<slug>/related endpoint.

Request
Terminal window
[GET] https://api.escuelajs.co/api/v1/products/slug/handmade-fresh-table/related
Response
[
{
"id": 4,
"title": "Handmade Fresh Table",
"slug": "handmade-fresh-table",
"price": 687,
"description": "Andy shoes are designed to keeping in...",
"category": {
"id": 5,
"name": "Others",
"image": "https://placehold.co/600x400",
"slug": "others"
},
"images": [
"https://placehold.co/600x400",
"https://placehold.co/600x400",
"https://placehold.co/600x400"
]
}
// ...
]

Product Schema

AttributeTypeDescriptionRequired for Create
idnumberThe unique identifier of the productNo (auto-generated)
titlestringThe name of the productYes
pricenumberPrice of the productYes
descriptionstringDescription of the productYes
categoryIdnumberID of the category (for create/update)Yes
categoryobjectObject containing category informationNo (auto-populated)
imagesstring[]List of image URLsYes
slugstringURL-friendly version of the titleNo (auto-generated)
creationAtstringCreation timestampNo (auto-generated)
updatedAtstringLast update timestampNo (auto-generated)