Getting Started
Alright, so this documentation basically shows you how to use our API like a pro.
Products
Get all products
fetch("https://fakestoreapi.in/api/products")
.then(res => res.json())
.then(res => console.log(res))
⚡ Access all products by using /products?limit=150 endpoint.
Get single product
fetch("https://fakestoreapi.in/api/products/2")
.then(res => res.json())
.then(res => console.log(res))
Get limited products
fetch("https://fakestoreapi.in/api/products?limit=2")
.then(res => res.json())
.then(res => console.log(res))
Pagination
fetch("https://fakestoreapi.in/api/products?page=2")
.then(res => res.json())
.then(res => console.log(res))
⚡ By default, we send 50 products. use /products?page=2&limit=20 to limit products per page.
💁♂️ You don't need to pass ?skip=20 query, we took care of that.
Get all categories
fetch("https://fakestoreapi.in/api/products/category")
.then(res => res.json())
.then(res => console.log(res))
Get products of category
fetch("https://fakestoreapi.in/api/products/category?type=mobile")
.then(res => res.json())
.then(res => console.log(res))
Add a product
fetch("https://fakestoreapi.in/api/products", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
title: "Apple Vision Pro",
brand: "Apple",
model: "Apple vision pro First Gen",
color: "Black",
category: "appliances",
discount: 1
})
})
Update a product
fetch("https://fakestoreapi.in/api/products/2", {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
model: "Apple vision pro Second Gen",
color: "Blue",
discount: 47
})
})
Delete a product
fetch("https://fakestoreapi.in/api/products/2", {
method: 'DELETE',
}).then(res => res.json())
.then(res => console.log(res))
Users
Get all users
fetch("https://fakestoreapi.in/api/users")
.then(res => res.json())
.then(res => console.log(res))
⚡ Access all users by using /users?limit=20 endpoint.
Get single user
fetch("https://fakestoreapi.in/api/users/7")
.then(res => res.json())
.then(res => console.log(res))
Get limited users
fetch("https://fakestoreapi.in/api/users?limit=2")
.then(res => res.json())
.then(res => console.log(res))
Pagination
fetch("https://fakestoreapi.in/api/users?page=2")
.then(res => res.json())
.then(res => console.log(res))
⚡ By default, we send 20 users. use /users?page=2&limit=20 to limit users per page.
?skip=20 query, we took care of that.
Add a user
fetch("https://fakestoreapi.in/api/users", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"email": "Thala@seven.com",
"username": "MSDhoni",
"password": "@2011WC",
"name": {
"firstname": "Mahendra Singh",
"lastname": "Dhoni"
},
"address": {
"city": "Rachi",
"street": "Local Boy",
"number": "7777777",
"zipcode": "7777",
"geolocation": {
"lat": 77.77777,
"long": 77.77777
}
},
"phone": "777777777"
})
})
Update a user
fetch("https://fakestoreapi.in/api/users/18", {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"email": "Virat@king.com",
"username": "Viratkholi",
"password": "@ESALEECUPNAMDE",
"name": {
"firstname": "Virat",
"lastname": "Kohli"
},
"address": {
"city": "Delhi",
"street": "Local Boy",
"number": "181818",
"zipcode": "181818",
"geolocation": {
"lat": 18.1818,
"long": 18.181818
}
},
"phone": "18181818"
})
})
Delete a user
fetch("https://fakestoreapi.in/api/users/11", {
method: 'DELETE',
}).then(res => res.json())
.then(res => console.log(res))