All Projects → keikaavousi → Fake Store Api

keikaavousi / Fake Store Api

FakeStoreAPI is a free online REST API that provides you fake e-commerce JSON data

Labels

Projects that are alternatives of or similar to Fake Store Api

Community
a community based on Node.js
Stars: ✭ 44 (-68.79%)
Mutual labels:  ejs
Hibiki
🤖 The best all-in-one Discord bot! Automod, fun, music, utilities, and more. Customizable, easy-to-use, and fully translatable.
Stars: ✭ 86 (-39.01%)
Mutual labels:  ejs
Bangajs
Bàngá is a CLI generator for scaffolding ExpressJS applications with speed and efficiency.
Stars: ✭ 102 (-27.66%)
Mutual labels:  ejs
Hexo Theme Volantis
A Wonderful Theme for Hexo https://volantis.js.org
Stars: ✭ 1,050 (+644.68%)
Mutual labels:  ejs
Quebradev.github.io
Site do podcast perifatécnico QuebraDev
Stars: ✭ 73 (-48.23%)
Mutual labels:  ejs
Root Config
Stars: ✭ 87 (-38.3%)
Mutual labels:  ejs
Cmms
Computerized Maintenance Management System
Stars: ✭ 31 (-78.01%)
Mutual labels:  ejs
Hexo Theme Zhaoo
🐳 A simple theme for Hexo
Stars: ✭ 131 (-7.09%)
Mutual labels:  ejs
Template.js
A javascript template engine, simple, easy & extras, support webpack, rollup, parcel, browserify, fis and gulp
Stars: ✭ 1,201 (+751.77%)
Mutual labels:  ejs
Ejs Compiled Loader
EJS loader for webpack (without frontend dependencies)
Stars: ✭ 102 (-27.66%)
Mutual labels:  ejs
Egg View Ejs
egg view plugin for ejs.
Stars: ✭ 54 (-61.7%)
Mutual labels:  ejs
Nodejs Koa Blog
基于 Node.js Koa2 实战开发的一套完整的博客项目网站
Stars: ✭ 1,162 (+724.11%)
Mutual labels:  ejs
Poetries.github.io
博客,用于记录学习总结的地方。关注公众号「前端进阶之旅」,一起学习
Stars: ✭ 94 (-33.33%)
Mutual labels:  ejs
Node Chat One To One
Node.js socket-io based one to one chat engine
Stars: ✭ 47 (-66.67%)
Mutual labels:  ejs
Webpack Seed
🚀 A Multi-Page Application base on webpack and babel. webpack搭建基于ES6,支持模板的多页面项目
Stars: ✭ 113 (-19.86%)
Mutual labels:  ejs
Friend.ly
A social media platform with a friend recommendation engine based on personality trait extraction
Stars: ✭ 41 (-70.92%)
Mutual labels:  ejs
Generator Jhipster Quarkus
Quarkus blueprint for JHipster
Stars: ✭ 85 (-39.72%)
Mutual labels:  ejs
Koa2 Blog
第一个web项目,仿照cnode,欢迎新建账号试用
Stars: ✭ 141 (+0%)
Mutual labels:  ejs
Generator Hexo Theme
Generate a hexo theme: ejs, pug, swig, nunjucks | Moved to https://tcrowe.commons.host/contact
Stars: ✭ 119 (-15.6%)
Mutual labels:  ejs
Dejs
ejs template engine for deno.
Stars: ✭ 99 (-29.79%)
Mutual labels:  ejs

FakeStoreAPI

FakeStoreAPI is a free online REST API that you can use whenever you need Pseudo-real data for your e-commerce or shopping website without running any server-side code. It's awesome for teaching purposes, sample codes, tests and etc.

You can visit in detail docs in FakeStoreAPI for more information.

Why?

When I wanted to design a shopping website prototype and needed fake data, I had to use lorem ipsum data or create a JSON file from the base. I didn't find any online free web service to return semi-real shop data instead of lorem ipsum data. so I decided to create this simple web service whit NodeJs(express) and MongoDB as a database.

Resources

There are 3 main resources need in shopping prototypes:

How to

you can fetch data with any kind of methods you know(fetch API, Axios, jquery ajax,...)

Get all products

fetch('https://fakestoreapi.com/products')
  .then(res => res.json())
  .then(json => console.log(json))

Get a single product

fetch('https://fakestoreapi.com/products/1')
  .then(res => res.json())
  .then(json => console.log(json))

Add new product

fetch('https://fakestoreapi.com/products', {
  method: 'POST',
  body: JSON.stringify({
     title: 'test product',
     price: 13.5,
     description: 'lorem ipsum set',
     image: 'https://i.pravatar.cc',
     category: 'electronic'
  })
})
  .then(res => res.json())
  .then(json => console.log(json))

/* will return
{
 id:31,
 title:'...',
 price:'...',
 category:'...',
 description:'...',
 image:'...'
}
*/

Note: Posted data will not really insert into the database and just return a fake id.

Updating a product

fetch('https://fakestoreapi.com/products/7', {
  method: 'PUT',
  body: JSON.stringify({
     title: 'test product',
     price: 13.5,
     description: 'lorem ipsum set',
     image: 'https://i.pravatar.cc',
     category: 'electronic'
  })
})
  .then(res => res.json())
  .then(json => console.log(json))

/* will return
{
    id:7,
    title: 'test product',
    price: 13.5,
    description: 'lorem ipsum set',
    image: 'https://i.pravatar.cc',
    category: 'electronic'
}
*/
fetch('https://fakestoreapi.com/products/8', {
  method: 'PATCH',
  body: JSON.stringify({
     title: 'test product',
     price: 13.5,
     description: 'lorem ipsum set',
     image: 'https://i.pravatar.cc',
     category: 'electronic'
  })
})
  .then(res => res.json())
  .then(json => console.log(json))

/* will return
{
    id:8,
    title: 'test product',
    price: 13.5,
    description: 'lorem ipsum set',
    image: 'https://i.pravatar.cc',
    category: 'electronic'
}
*/

Note: Edited data will not really be updated into the database.

Deleting a product

fetch('https://fakestoreapi.com/products/8', {
  method: 'DELETE'
})

Nothing will delete on the database.

Sort and Limit

You can use query string to limit results or sort by asc|desc

// Will return all the posts that belong to the first user
fetch('https://fakestoreapi.com/products?limit=3&sort=desc')
  .then(res => res.json())
  .then(json => console.log(json))

All available routes

Products

fields: 
{
    id:Number,
    title:String,
    price:Number,
    category:String,
    description:String,
    image:String
}

GET:

  • /products (get all products)
  • /products/1 (get specific product based on id)
  • /products?limit=5 (limit return results )
  • /products?sort=desc (asc|desc get products in ascending or descending orders (default to asc))
  • /products/products/categories (get all categories)
  • /products/category/jewelery (get all products in specific category)
  • /products/category/jewelery?sort=desc (asc|desc get products in ascending or descending orders (default to asc))

POST:

  • /products

-PUT,PATCH

  • /products/1

-DELETE

  • /products/1

Carts

fields: 
{
    id:Number,
    userId:Number,
    date:Date,
    products:[{productId:Number,quantity:Number}]
}

GET:

  • /carts (get all carts)
  • /carts/1 (get specific cart based on id)
  • /carts?startdate=2020-10-03&enddate=2020-12-12 (get carts in date range)
  • /carts/user/1 (get a user cart)
  • /carts/user/1?startdate=2020-10-03&enddate=2020-12-12 (get user carts in date range)
  • /carts?limit=5 (limit return results )
  • /carts?sort=desc (asc|desc get carts in ascending or descending orders (default to asc))

POST:

  • /carts

PUT,PATCH:

  • /carts/1

DELETE:

  • /carts/1

Users

fields: 
{
    id:20,
    email:String,
    username:String,
    password:String,
    name:{
        firstname:String,
        lastname:String
        },
    address:{
    city:String,
    street:String,
    number:Number,
    zipcode:String,
    geolocation:{
        lat:String,
        long:String
        }
    },
    phone:String
}

GET:

  • /users (get all users)
  • /users/1 (get specific user based on id)
  • /users?limit=5 (limit return results )
  • /users?sort=desc (asc|desc get users in ascending or descending orders (default to asc))

POST:

  • /users

PUT,PATCH:

  • /users/1

DELETE:

  • /users/1

ToDo

  • Add graphql support
  • Add pagination
  • Add another language support
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].