Get Product(s) APIs
There are five (5) APIs to get the products in different scenarios:
- Get Products by Category ID: This API will be used to get the products based on the desired category.
- Get One Product by ID: This API will be used to get a single product by using the
product id. - Get Sale Products: This API will return the sale products since it's not a category but the sale products have a different criteria.
- Get Relative Products: This API will give the relative products to one product.
- Get Index Content: And this API will give you the home page content categorized under different headings.
Product SKU calculation
Now there is a very important thing about the product object which is its SKU Number. Each product object will have a sku_number property at the top level and a sku property in its each variant object which both will be partial numbers and aren't ready to use. For user's point of view, one product to add in the cart will differentiated by a particular size of a specific variant.
When a user adds a product to the cart, you will have to put the size symbol at the end of the respected variant's sku.
For example the user selects a product with variant white of size L (Large), then the actual sku will be UF1014-#ffffff-LL. The size symbol have to be appended 2 times in the end.
1. Get Products by Category ID
Endpoint
GET /products/get/bycategory
Payload
There will be 5 URL Query parameters as payload:
id yesundefined65ddb7496a09ca290bec88b2min_price partialmax_price partialpage no1limit no30Now let's say we make a request by using the women's category id: /products/get/bycategory?id=64a59d5816b4c91fa1967b2e
In this case the page will defaulted 1, limit will be defaulted to 30, min_price will be defaulted to minimum available price in these 30 products and max_price will be the maximum price available in these 30 products.
Let's take a look at the response:
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
{
"success": true,
"msg": "Products found with the category of id 64a59d5816b4c91fa1967b2e",
"currentPage": 1,
"totalPages": 1,
"products": [
{
"name": {
"en": "Women Collar Solid Color Pocket Cardigan",
"ar": "كارديجان نسائي بياقة وجيب لون صلب"
},
"description": {
"en": "%65 RAYON % 35 POLYAMID",
"ar": "% 65 رايون ٪ 35 بولي أميد"
},
"seo_details": {
"title": "Women Collar Solid Color Pocket Cardigan",
"description": "%65 RAYON % 35 POLYAMID",
"meta_keywords": "women, cardigan"
},
"shipping_details": {
"width": "8",
"height": "73",
"weight": 400
},
"_id": "656a339e560eeb201a25d23a",
"cover_image": "/product-images/656a339e560eeb201a25d23a/656a339e560eeb201a25d23a.webp",
"price": 626,
"uf_points": 350,
"sale_price": null,
"categories": [
{
"name": {
"en": "women",
"ar": "نساء"
},
"description": {
"en": "This is a clothing category for women of the age above 18",
"ar": "هذه فئة الملابس للنساء اللاتي تزيد أعمارهن عن 18 عامًا"
},
"_id": "64a59d5816b4c91fa1967b2e",
"slug": "women/",
"path": "women/",
"children": [
"64b5391e2c57908f1e94dc27"
],
"createdAt": "2023-07-05T16:42:00.778Z",
"updatedAt": "2024-05-16T20:47:35.378Z",
"__v": 0
}
],
"slug": "women-collar-solid-color-pocket-cardigan/",
"tags": [
"women",
"cardigan"
],
"active": false,
"ratings": 0,
"variants": [
{
"color": "#ffffff",
"color_name": "White",
"images": [
"/product-images/656a339e560eeb201a25d23a/656a339e560eeb201a25d23b/0.webp",
"/product-images/656a339e560eeb201a25d23a/656a339e560eeb201a25d23b/1.webp",
"/product-images/656a339e560eeb201a25d23a/656a339e560eeb201a25d23b/2.webp"
],
"sizes": [
{
"size": "M",
"quantity": 10,
"_id": "656a33a2560eeb201a25d244"
}
],
"stock": 10,
"_id": "656a33a2560eeb201a25d243",
"sku": "UF1014-#ffffff"
}
],
"bundle_items": [],
"createdAt": "2023-12-01T19:27:26.639Z",
"updatedAt": "2024-05-12T11:31:14.245Z",
"__v": 0,
"sku_number": 1014
}
// and 29 more products if exist...
],
"min_price": 349,
"max_price": 1190,
"available_colors": [
{
"color": "#000000",
"color_name": "Black"
},
{
"color": "#ffffff",
"color_name": "White"
},
{
"color": "#767387",
"color_name": "Mink"
},
{
"color": "#E1A822",
"color_name": "Camel"
},
{
"color": "#01c63c",
"color_name": "Green"
},
{
"color": "#f25e07",
"color_name": "Orange"
},
{
"color": "#d5a22a",
"color_name": "Yellow"
},
{
"color": "#b0b0b0",
"color_name": "Grey"
},
{
"color": "#EA3838",
"color_name": "Red"
},
{
"color": "#e2dfc1",
"color_name": "Stone"
},
{
"color": "#14133a",
"color_name": "Dark Blue"
},
{
"color": "#757575",
"color_name": "Dark Grey"
},
{
"color": "#EA3838",
"color_name": "Carol"
},
{
"color": "#D97133",
"color_name": "Honey Foam"
},
{
"color": "#212236",
"color_name": "Petrol"
},
{
"color": "#111032",
"color_name": "Petrol grey"
}
],
"available_sizes": [
"M",
"L",
"Xl",
"S"
]
}In the response, 30 products will be returned which come under the women category or any subcategory of the women. First the server will look at the top level of the women category and if the number of products still deosn't satisfies then it go down the hierarchy with sub-categories.
After getting the respected category products according to provided or default pagination and limit, the server will calculate the the minimum and maximum available prices in the current batch of the products; in this case 30.
Then the server will filter out all the unique available colors in current batch (of 30 products) and then the available sizes.
All this calculation is intended to show the correct and smooth filtering on the client side so the user know that each of these filteration options must have some matching products. And in addition, the users will have a faster experience with filteration.
2. Get One Product by ID
Endpoint
GET /products/get/one
Payload
You have to send a mandatory Query Parameter: id. It will be the product id which you want to get the details for.
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
"success": true,
"msg": "Product found with the id 656a0cc84839597ecab95819",
"product": {
"name": {
"en": "Waist Fabric Belt Knitwear Tunic",
"ar": "قميص بحزام من الصوف"
},
"description": {
"en": "%65 RAYON % 35 POLYAMID/ %100 POLYESTER",
"ar": "% 65 رايون ٪ 35 بولي أميد / ٪ 100 بوليستر"
},
"seo_details": {
"title": "Waist Fabric Belt Knitwear Tunic",
"description": "%65 RAYON % 35 POLYAMID/ %100 POLYESTER",
"meta_keywords": "women, fabric dress, knitwear"
},
"shipping_details": {
"width": "8",
"height": "72",
"weight": 430
},
"_id": "656a0cc84839597ecab95819",
"cover_image": "/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab95819.webp",
"price": 425,
"uf_points": 350,
"sale_price": null,
"categories": [
{
"name": {
"en": "women",
"ar": "نساء"
},
"description": {
"en": "This is a clothing category for women of the age above 18",
"ar": "هذه فئة الملابس للنساء اللاتي تزيد أعمارهن عن 18 عامًا"
},
"_id": "64a59d5816b4c91fa1967b2e",
"slug": "women/",
"path": "women/",
"children": [
"64b5391e2c57908f1e94dc27"
],
"createdAt": "2023-07-05T16:42:00.778Z",
"updatedAt": "2024-05-16T20:47:35.378Z",
"__v": 0
},
{
"name": {
"en": "Latest Arrival",
"ar": "أحدث الوافدين"
},
"description": {
"en": "Urban Fits latest arrivals.",
"ar": "أحدث الوافدين إلى Urban Fits."
},
"_id": "65526c04994e55da77576df6",
"slug": "latest-arrival/",
"path": "latest-arrival/",
"parent": null,
"children": [],
"createdAt": "2023-11-13T18:33:40.077Z",
"updatedAt": "2024-05-16T20:47:37.394Z",
"__v": 0
}
],
"slug": "waist-fabric-belt-knitwear-tunic/",
"tags": [
"women",
"fabric dress",
"knitwear"
],
"active": false,
"ratings": 0,
"variants": [
{
"color": "#000000",
"color_name": "Black",
"images": [
"/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab9581a/0.webp",
"/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab9581a/1.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "656a0cce4839597ecab9582f"
},
{
"size": "M",
"quantity": 10,
"_id": "656a0cce4839597ecab95830"
},
{
"size": "L",
"quantity": 10,
"_id": "656a0cce4839597ecab95831"
}
],
"stock": 30,
"_id": "656a0cce4839597ecab9582e",
"sku": "UF1011-#000000"
},
{
"color": "#01c63c",
"color_name": "Green",
"images": [
"/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab9581e/0.webp",
"/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab9581e/1.webp",
"/product-images/656a0cc84839597ecab95819/656a0cc84839597ecab9581e/2.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "656a0cce4839597ecab95833"
},
{
"size": "M",
"quantity": 10,
"_id": "656a0cce4839597ecab95834"
},
{
"size": "L",
"quantity": 10,
"_id": "656a0cce4839597ecab95835"
}
],
"stock": 30,
"_id": "656a0cce4839597ecab95832",
"sku": "UF1011-#01c63c"
}
],
"bundle_items": [],
"createdAt": "2023-12-01T16:41:44.734Z",
"updatedAt": "2024-05-12T11:31:13.583Z",
"__v": 0,
"sku_number": 1011
}
}In the response you will get the full detailed product object. It will have the full objects of the categories to which it was assigned, all the variants, each variant containing all available colors, sizes and quanitity of them available for each size.
3. Get Sale Products
Endpoint
GET /products/get/sales
Payload
This API will have the same Query Parameters as explained above in table for the Get Products by Category ID API except the id parameter, its not required.
Response
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
{
"length": 4,
"totalProducts": 4,
"totalPages": 1,
"currentPage": 1,
"products": [
{
"name": {
"en": "Waist Knitwear Belt Solid Color Dress",
"ar": "فستان ذو حزام من الصوف واللون الصلب"
},
"description": {
"en": "%65 RAYON % 35 POLYAMID",
"ar": "% 65 رايون ٪ 35 بولي أميد"
},
"seo_details": {
"title": "Waist Knitwear Belt Solid Color Dress",
"description": "%65 RAYON % 35 POLYAMID",
"meta_keywords": "women, belt, knitwear"
},
"shipping_details": {
"width": "8",
"height": "72",
"weight": 450
},
"_id": "6569fe0d6edd1997d14d9aea",
"cover_image": "/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aea.webp",
"price": 425,
"uf_points": null,
"sale_price": 399,
"categories": [
{
"name": {
"en": "women",
"ar": "نساء"
},
"description": {
"en": "This is a clothing category for women of the age above 18",
"ar": "هذه فئة الملابس للنساء اللاتي تزيد أعمارهن عن 18 عامًا"
},
"_id": "64a59d5816b4c91fa1967b2e",
"slug": "women/",
"path": "women/",
"children": [
"64b5391e2c57908f1e94dc27"
],
"createdAt": "2023-07-05T16:42:00.778Z",
"updatedAt": "2024-05-16T20:47:35.378Z",
"__v": 0
}
],
"slug": "waist-knitwear-belt-solid-color-dress/",
"tags": [
"women",
"belt",
"knitwear"
],
"active": false,
"ratings": 0,
"variants": [
{
"color": "#14133a",
"color_name": "Dark Blue",
"images": [
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/0.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/1.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/2.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e60"
},
{
"size": "M",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e61"
},
{
"size": "L",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e62"
}
],
"stock": 30,
"_id": "6569fe18b56ee511ddcf6e5f",
"sku": "UF1007-#14133a"
},
{
"color": "#757575",
"color_name": "Dark Grey",
"images": [
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/0.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/1.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/2.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e64"
},
{
"size": "M",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e65"
},
{
"size": "L",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e66"
}
],
"stock": 30,
"_id": "6569fe18b56ee511ddcf6e63",
"sku": "UF1007-#757575"
}
],
"bundle_items": [],
"createdAt": "2023-12-01T15:38:53.379Z",
"updatedAt": "2024-05-12T11:31:12.716Z",
"__v": 0,
"sku_number": 1007
}
// Other 3 Sale Products...
],
"min_price": 425,
"max_price": 599,
"available_colors": [
{
"color": "#14133a",
"color_name": "Dark Blue"
},
{
"color": "#757575",
"color_name": "Dark Grey"
},
{
"color": "#bfbfbf",
"color_name": "Grey"
},
{
"color": "#000000",
"color_name": "Black"
}
],
"available_sizes": [
"S",
"M",
"L"
]
}Now the only different between Get Products by Categories and this API is that the returned products by this API in response, each product will have sale_price specified along with the original price. It's just to show difference to the user but for the Sale Products, you will have to calculate things using sale_price instead of price.
4. Get Products by IDs
Endpoint
GET /products/get/relative-products
Payload
This API expects a mandatory product_id Query Parameter which will be a product id of type String. Let's get some relative products by using the the product id 6569d376a7fcb35928d0f1f5 by using the follwing URL: /products/get/relative-products?product_id=6569d376a7fcb35928d0f1f5
Response
This API will return maximum 5 products which are relative to the given ID of the product. It will identify the relative products by the category relationships. It's first priority of lookup will be in the product's category's child categories and onwards down the hierarchy, and then at last it will lookup in the sibling categories. Here's the response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
"success": true,
"msg": '',
"relative_products": [
{
"name": {
"en": "Waist Knitwear Belt Solid Color Dress",
"ar": "فستان ذو حزام من الصوف واللون الصلب"
},
"description": {
"en": "%65 RAYON % 35 POLYAMID",
"ar": "% 65 رايون ٪ 35 بولي أميد"
},
"seo_details": {
"title": "Waist Knitwear Belt Solid Color Dress",
"description": "%65 RAYON % 35 POLYAMID",
"meta_keywords": "women, belt, knitwear"
},
"shipping_details": {
"width": "8",
"height": "72",
"weight": 450
},
"_id": "6569fe0d6edd1997d14d9aea",
"cover_image": "/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aea.webp",
"price": 425,
"uf_points": null,
"sale_price": 399,
"categories": [
{
"name": {
"en": "women",
"ar": "نساء"
},
"description": {
"en": "This is a clothing category for women of the age above 18",
"ar": "هذه فئة الملابس للنساء اللاتي تزيد أعمارهن عن 18 عامًا"
},
"_id": "64a59d5816b4c91fa1967b2e",
"slug": "women/",
"path": "women/",
"children": [
"64b5391e2c57908f1e94dc27"
],
"createdAt": "2023-07-05T16:42:00.778Z",
"updatedAt": "2024-05-16T20:47:35.378Z",
"__v": 0
}
],
"slug": "waist-knitwear-belt-solid-color-dress/",
"tags": [
"women",
"belt",
"knitwear"
],
"active": false,
"ratings": 0,
"variants": [
{
"color": "#14133a",
"color_name": "Dark Blue",
"images": [
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/0.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/1.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aeb/2.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e60"
},
{
"size": "M",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e61"
},
{
"size": "L",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e62"
}
],
"stock": 30,
"_id": "6569fe18b56ee511ddcf6e5f",
"sku": "UF1007-#14133a"
},
{
"color": "#757575",
"color_name": "Dark Grey",
"images": [
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/0.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/1.webp",
"/product-images/6569fe0d6edd1997d14d9aea/6569fe0d6edd1997d14d9aef/2.webp"
],
"sizes": [
{
"size": "S",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e64"
},
{
"size": "M",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e65"
},
{
"size": "L",
"quantity": 10,
"_id": "6569fe18b56ee511ddcf6e66"
}
],
"stock": 30,
"_id": "6569fe18b56ee511ddcf6e63",
"sku": "UF1007-#757575"
}
],
"bundle_items": [],
"createdAt": "2023-12-01T15:38:53.379Z",
"updatedAt": "2024-05-12T11:31:12.716Z",
"__v": 0,
"sku_number": 1007
}
// Other 4 other Relative Products if exist...
]
}5. Get Index Content
Endpoint
GET /get-index-content
Payload
No kind of payload is required.
Response
In the response, a few featured categories will returned along with their respected array of products. Each of them will be having maximum 5 products if exist.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
success: true,
msg: '',
latestArrivals: [
//... respected products here (max 5)
],
newCollection: [
//... respected products here (max 5)
],
womenCollection: [
//... respected products here (max 5)
],
menCollection: [
//... respected products here (max 5)
],
kidsCollection: [
//.. respected products here (max 5)
]
}