This is a free REST api that provides users with real time ecommerce data in json format.If you don't want to run any server side code, you can use this free api.The api is good for learning, teaching and testing purposes only. Enjoy it and feel free to contribute and alert incase of any errors
I made this api for teaching purposes only, In a case for a frontend website i found it hard to using lorem ipsum, hence created the api with mongodb node and express It is also good for testing purposes.
products: https://fakeecommerceapi.onrender.com/api/v1/products auth: https://fakeecommerceapi.onrender.com/api/v1/auth Token: On registration or login you are given a token
You can fetch datausing any methods you know ie fetch, axios etc
fetch("https://fakeecommerceapi.onrender.com/api/v1/products")
.then((res) => res.json())
.then((json) => console.log(json));
fetch("https://fakeecommerceapi.onrender.com/api/v1/products/:id")
.then((res) => res.json())
.then((json) => console.log(json));
fetch("https://fakeecommerceapi.onrender.com/api/v1/products", {
method: "POST",
body: JSON.stringify({
name: "new product",
price: 10,
description: "product desription",
image: "img url",
category: "electronics",
}),
})
.then((res) => res.json())
.then((json) => console.log(json));
/* response
{
"price": 25,
"name": "accent chair",
"image": "img url",
"description": "Comfy chair for you living room",
"category": "electronics",
}
*/
fetch("https://fakeecommerceapi.onrender.com/api/v1/products/:id", {
method: "DELETE",
});
/*
the response
{
"price": 25,
"name": "accent chair",
"image": "img url",
"description": "deleted product description",
"category": "home"
}
*/
fetch("https://fakeecommerceapi.onrender.com/api/v1/products/:id", {
method: "PUT",
body: JSON.stringify({
title: "updated product",
price: 30,
description: "updated product description",
image: "img url",
category: "electronics",
}),
})
.then((res) => res.json())
.then((json) => console.log(json));
/* response
{
"price": 30,
"name": "updated product",
"image": "img url",
"description": "updated product description",
"category": "electrinics",
}
Note: The update will not occur on the database
*/
//request body
{
price: Number,
name:String,
image: String,
description: String,
category: String
}
GET
/products (get all products)
/products/:id (get a single product)
/products/category/home (sort products using category)
POST
/products
PUT
/products/:id
DELETE
/products/:id
{
id:Number,
full_name: String,
email: String,
password: String,
telephone: Number,
}
GET
/user (get all users) /user/:id (get a single user)
POST
/user (add a user)
DELETE
/user/:id (remove a user)
PATCH
/user/:id (update a user)
//login fields
{
email: String;
password: String;
}
POST
/auth/login
//sign in fields
{
full_name: String,
email: String,
password: String,
telephone: Number,
}
/auth/signup
Enjoy and feel free to contribute.