_ImposterAPI

Getting Started

Alright, so this documentation basically shows you how to use ImposterAPI like a pro.

Products

Get all products

fetch("https://imposterapi-5.onrender.com/data")
.then(res => res.json())
.then(res => console.log(res))

Get single product

fetch("https://imposterapi-5.onrender.com/api/data/1") 
.then(res => res.json())
.then(res => console.log(res))

Get limited products

fetch("https://imposterapi-5.onrender.com?limit=28") 
.then(res => res.json())
.then(res => console.log(res))

Pagination

fetch("https://imposterapi-5.onrender.com?page=2") 
.then(res => res.json())
.then(res => console.log(res))

Get Products by Category

fetch("https://imposterapi-5.onrender.com/api/data/category/dairy_breakfast")
.then(res => res.json())
.then(res => console.log(res))

Get Products by Category & Sub-category

fetch("https://imposterapi-5.onrender.com/api/data/category/dairy_breakfast/subcategory/bread")
.then(res => res.json())
.then(res => console.log(res))

Add a product

fetch("https://imposterapi-5.onrender.com/data", {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"id": 777,
"title": "Bonn Bombay Pav (12 slices)",
"unit": "350g (12 pieces)",
"type": "Pav",
"price": 55,
"image": "https://fakeapi.s3.ap-south-1.amazonaws.com/dairy%26breakfast/bread/bonn-bombay-pav.webp",
"description": "Bonn Prime Time Pav buns, the bread that you seek out, the bread that you believe in, the bread that you relate with and take home each day",
"categories": {
"category": "dairy_breakfast",
"sub-category": "bread"
},
"fssaiLicense": "10019064001813",
"countryOfOrigin": "India",
"shelfLife": "6 Days"
})
})

Update a product (PUT)

fetch("https://imposterapi-5.onrender.com/api/data/2", {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"categories": {
"category": "atta_rice",
"sub-category": "dal"
},
})
})

Update a product (PATCH)

fetch("https://imposterapi-5.onrender.com/api/data/2", {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
"categories": {
"category": "atta_rice",
"sub-category": "dal"
},
})
})

Delete a product

fetch("https://imposterapi-5.onrender.com/api/data/1", {
method: 'DELETE',
}).then(res => res.json())
.then(res => console.log(res))