How to use it
fakeStoreJSON can be used with any type of shopping project that needs products, carts, and users in JSON format. you can use examples below to check how fakeStoreJSON works and feel free to enjoy it in your awesome projects!
Auth
Register
1fetch('https://api.fakestorejson.com/api/v1/auth/register', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 name: 'duyetnn',
6 phone: '0969131921',
7 email: '[email protected]',
8 password: 'NhatDuyet@JSON*2023#',
9 password_confirmation: 'NhatDuyet@JSON*2023#',
10 })
11 })
12 .then(res => res.json())
13 .then(console.log)
Login
1fetch('https://api.fakestorejson.com/api/v1/auth/login', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 email: '[email protected]',
6 password: 'NhatDuyet@JSON*2023#',
7 })
8 })
9 .then(res => res.json())
10 .then(console.log)
Get Profile
1fetch('https://api.fakestorejson.com/api/v1/auth/user-profile', {
2 headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer access_token' },
3 })
4 .then(res=>res.json())
5 .then(json=>console.log(json))
Refresh Token
1fetch('https://api.fakestorejson.com/api/v1/auth/refresh-token', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json', 'Authorization': 'Bearer access_token' },
4 })
5 .then(res => res.json())
6 .then(console.log)
Product Categories
Get pagination
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories?per_page=10&page=1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get search
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories?keyword=Mac')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get a single
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories/1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get product of category
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories/get/mac')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Create new product category
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 name: 'Mac',
6 parent_id: 0,
7 avatar: File
8 })
9 })
10 .then(res => res.json())
11 .then(console.log)
Update product category
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories/1?_method=PUT', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 name: 'Mac',
6 parent_id: 0,
7 avatar: File
8 })
9 })
10 .then(res => res.json())
11 .then(console.log)
Delete a product category
1fetch('https://api.fakestorejson.com/api/v1/public/product-categories/1', {
2 method: 'DELETE',
3 headers: { 'Content-Type': 'application/json' },
4 })
5 .then(res => res.json())
6 .then(console.log)
Products
Get pagination
1fetch('https://api.fakestorejson.com/api/v1/public/products?per_page=10&page=1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get search
1fetch('https://api.fakestorejson.com/api/v1/public/products?keyword=MacBook')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get a single
1fetch('https://api.fakestorejson.com/api/v1/public/products/3')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Create new product
1fetch('https://api.fakestorejson.com/api/v1/public/products', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 category_id: 1,
6 name: "MacBook Pro 14-inch",
7 avatar: File,
8 code: "bbf878bffcff79fd1420",
9 description: "TheMacBook Pro 14-inch family was initially housed in designs similar to the iBook and PowerBook lines which preceded them,",
10 initial_price: "200000",
11 discount: "12",
12 images[]: File[],
13 content: "TheMacBook Pro 14-inch family was initially housed in designs similar to the iBook and PowerBook lines which preceded them,",
14 })
15 })
16 .then(res => res.json())
17 .then(console.log)
Update product
1fetch('https://api.fakestorejson.com/api/v1/public/products/3?_method=PUT', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 category_id: 1,
6 name: "MacBook Pro 14-inch",
7 })
8 })
9 .then(res => res.json())
10 .then(console.log)
Delete a product
1fetch('https://api.fakestorejson.com/api/v1/public/products/3', {
2 method: 'DELETE',
3 headers: { 'Content-Type': 'application/json' },
4 })
5 .then(res => res.json())
6 .then(console.log)
Orders
Get pagination
1fetch('https://api.fakestorejson.com/api/v1/public/orders?per_page=10&page=1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get search
1fetch('https://api.fakestorejson.com/api/v1/public/orders?keyword=f5e6994d0f22')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get a single
1fetch('https://api.fakestorejson.com/api/v1/public/orders/f5e6994d0f22609ae41055eb')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Create new order
1fetch('https://api.fakestorejson.com/api/v1/public/orders', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 "id": 16,
6 "code": "f5e6994d0f22609ae41055eb",
7 "name": "duyetnn",
8 "phone": 999888777,
9 "email": "[email protected]",
10 "address": "Ha Noi, Viet Nam",
11 "delivery": 1,
12 "payment": 1,
13 "status": 3,
14 "totalPrice": 72109,
15 })
16 })
17 .then(res => res.json())
18 .then(console.log)
Update order
1fetch('https://api.fakestorejson.com/api/v1/public/orders/f5e6994d0f22609ae41055eb?_method=PUT', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 "status": 2
6 })
7 })
8 .then(res => res.json())
9 .then(console.log)
Delete a order
1fetch('https://api.fakestorejson.com/api/v1/public/orders/f5e6994d0f22609ae41055eb', {
2 method: 'DELETE',
3 headers: { 'Content-Type': 'application/json' },
4 })
5 .then(res => res.json())
6 .then(console.log)
Post Categories
Get pagination
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories?per_page=10&page=1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get search
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories?keyword=blog')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get a single
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories/slug')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Create new post category
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 name: 'Apple',
6 parent_id: 0,
7 avatar: "https://google.com"
8 })
9 })
10 .then(res => res.json())
11 .then(console.log)
Update post category
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories/1?_method=PUT', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 name: 'Apple',
6 parent_id: 0,
7 avatar: "https://api.fakestorejson.com/images/post_categories/post_category_01.png"
8 })
9 })
10 .then(res => res.json())
11 .then(console.log)
Delete a post category
1fetch('https://api.fakestorejson.com/api/v1/public/post-categories/1', {
2 method: 'DELETE',
3 headers: { 'Content-Type': 'application/json' },
4 })
5 .then(res => res.json())
6 .then(console.log)
Posts
Get pagination
1fetch('https://api.fakestorejson.com/api/v1/public/posts?per_page=10&page=1')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get search
1fetch('https://api.fakestorejson.com/api/v1/public/posts?keyword=remote')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Get a single
1fetch('https://api.fakestorejson.com/api/v1/public/posts/how-much-does-remote-it-support-cost')
2 .then(res=>res.json())
3 .then(json=>console.log(json))
Create new post
1fetch('https://api.fakestorejson.com/api/v1/public/posts', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 category_id: 1,
6 name: "How Much Does Remote IT Support Cost?",
7 avatar: "https://api.fakestorejson.com/images/posts/post_15.png",
8 content: "How Much Does Remote IT Support Cost?",
9 })
10 })
11 .then(res => res.json())
12 .then(console.log)
Update post
1fetch('https://api.fakestorejson.com/api/v1/public/posts/15?_method=PUT', {
2 method: 'POST',
3 headers: { 'Content-Type': 'application/json' },
4 body: JSON.stringify({
5 category_id: 1,
6 name: "How Much Does Remote IT Support Cost?",
7 avatar: "https://api.fakestorejson.com/images/posts/post_15.png",
8 content: "How Much Does Remote IT Support Cost?",
9 })
10 })
11 .then(res => res.json())
12 .then(console.log)
Delete a post
1fetch('https://api.fakestorejson.com/api/v1/public/posts/15', {
2 method: 'DELETE',
3 headers: { 'Content-Type': 'application/json' },
4 })
5 .then(res => res.json())
6 .then(console.log)