You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+56-51Lines changed: 56 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,8 @@ Paginates result when products are fetched by categories or subcategories.
13
13
Deployed as a vercel function with Postgres: [ecommerce-rest-api-five.vercel.app](https://ecommerce-rest-api-five.vercel.app)
14
14
<br> Documented with Swagger UI.
15
15
16
+
<br/>
17
+
16
18
### Requirements
17
19
This project is written in `Python 3.12.1`
18
20
@@ -21,6 +23,8 @@ pip install -r requirements.txt
21
23
```
22
24
`requirements.txt` contains an adapter for PostgreSQL by default.
23
25
26
+
<br/>
27
+
24
28
### Usage
25
29
26
30
Copy `.env.example` and rename to `.env`. Provide your database URL to the `SQLALCHEMY_DATABASE_URI` environment variable.
@@ -46,18 +50,17 @@ flask --app app run [--debug]
46
50
47
51
Test the API using Swagger UI (`/` route), Postman, cURL or your preferred HTTP client.
48
52
53
+
<br/>
54
+
49
55
### Endpoints
50
56
51
57
#### Fetch products using name, category, subcategory
52
-
-[GET]`/product/<name: string>` - Get product with name: `name`
53
-
<br></br>
54
-
-[GET]`/subcategory/<subcategory_id: int>/products` - Get product with within subcategory `subcategory`. Returns first page of the paginated results.
55
-
<br></br>
56
-
-[GET]`/subcategory/<subcategory_id: int>/products?page=<page_no>` - Get product with within subcategory `subcategory`. Returns `page_no` of the paginated results.
57
-
<br></br>
58
-
-[GET]`/category/<category_id: int>/products` - Get product with within category `category`. Returns first page of the paginated results.
59
-
<br></br>
60
-
-[GET]`/category/<category_id: int>/products?page=<page_no>` - Get product with within category `category`. Returns `page_no` of the paginated results.
58
+
-[GET]`/product/<name: string>` - Get product with name: `name` <br/><br/>
59
+
-[GET]`/subcategory/<subcategory_id: int>/products?page=<page_no>` - Get product with within subcategory `subcategory`. Returns `page_no` of the paginated results. <br/><br/>
60
+
-[GET]`/category/<category_id: int>/products` - Get product with within category `category`. Returns first page of the paginated results. <br/><br/>
61
+
-[GET]`/category/<category_id: int>/products?page=<page_no>` - Get product with within category `category`. Returns `page_no` of the paginated results. <br/><br/>
62
+
63
+
<br/>
61
64
62
65
<br></br>
63
66
#### Category
@@ -66,66 +69,68 @@ Test the API using Swagger UI (`/` route), Postman, cURL or your preferred HTTP
66
69
-[DELETE]`/category/(int: category_id)` - Delete category with category_id
67
70
68
71
-[POST]`/category/create` - Create a new category
69
-
```
70
-
{
71
-
"name": "name",
72
-
"subcategories": [<subcategory ids>] //optional
73
-
}
74
-
```
72
+
```
73
+
{
74
+
"name": "name",
75
+
"subcategories": [<subcategory ids>] //optional
76
+
}
77
+
```
75
78
76
79
-[PUT]`/category/(int: category_id)/update` - Update category with category_id
77
-
```
78
-
{
79
-
"name": "name",
80
-
"subcategories": [<subcategory ids>] //optional
81
-
}
82
-
```
80
+
```
81
+
{
82
+
"name": "name",
83
+
"subcategories": [<subcategory ids>] //optional
84
+
}
85
+
```
86
+
87
+
<br/>
83
88
84
-
<br></br>
85
89
#### Subcategory
86
90
-[GET]`/subcategories` - Get all subcategories
87
91
-[GET]`/subcategory/(int: subcategory_id)` - Get subcategory with subcategory_id
88
92
-[DELETE]`/subcategory/(int: subcategory_id)` - Delete subcategory with subcategory_id
89
93
90
94
-[POST]`/subcategory/create` - Create a new subcategory
91
-
```
92
-
{
93
-
"name": "name",
94
-
"categories": [(category ids)] //optional
95
-
"products": [<product ids>] // optional
96
-
}
97
-
```
95
+
```
96
+
{
97
+
"name": "name",
98
+
"categories": [(category ids)], //optional
99
+
"products": [<product ids>] // optional
100
+
}
101
+
```
98
102
99
103
-[PUT]`/subcategory/(int: subcategory_id)/update` - Update subcategory with subcategory_id
100
-
```
101
-
{
102
-
"name": "name",
103
-
"categories": [<category ids>] //optional
104
-
"products": [<product ids>] // optional
105
-
}
106
-
```
104
+
```
105
+
{
106
+
"name": "name",
107
+
"categories": [<category ids>], //optional
108
+
"products": [<product ids>] // optional
109
+
}
110
+
```
107
111
108
112
109
-
<br></br>
113
+
<br/>
114
+
110
115
#### Product
111
116
-[GET]`/products` - Get all products
112
117
-[GET]`/product/(int: product_id)` - Get product with product_id
113
118
-[DELETE]`/product/(int: product_id)` - Delete product with product_id
114
119
115
120
-[POST]`/product/create` - Create a new product
116
-
```
117
-
{
118
-
"name": "name",
119
-
"description": "description",
120
-
"subcategories": [<subcategory ids>] //optional
121
-
}
122
-
```
121
+
```
122
+
{
123
+
"name": "name",
124
+
"description": "description",
125
+
"subcategories": [<subcategory ids>] //optional
126
+
}
127
+
```
123
128
124
129
-[PUT]`/product/(int: product_id)/update` - Update product with product_id
0 commit comments