https://github.com/naufan17/e-commerce
Rest API simple online shop, from choosing a product, adding it to cart and checking out the product to the delivery address. The Rest API is built using the Go programming language and MySQL database. Applications are bundled in containers using Docker.
https://github.com/naufan17/e-commerce
docker e-commerce go rest-api
Last synced: 2 months ago
JSON representation
Rest API simple online shop, from choosing a product, adding it to cart and checking out the product to the delivery address. The Rest API is built using the Go programming language and MySQL database. Applications are bundled in containers using Docker.
- Host: GitHub
- URL: https://github.com/naufan17/e-commerce
- Owner: naufan17
- Created: 2023-05-02T03:48:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-25T16:58:46.000Z (about 3 years ago)
- Last Synced: 2025-04-12T18:25:48.363Z (about 1 year ago)
- Topics: docker, e-commerce, go, rest-api
- Language: Go
- Homepage:
- Size: 1.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# e-commerce
A basic online store API written with Golang Programming language
This API is basic implementation of an e-commerce(online store)
- You can diplay product and category data
- Also can display product by category
- Authentication is based JWT(JSON Web Token)
- Register for new user to get token
- Login for registered user to get token
- User can display, add and delete shipping address
- User can display, add and delete product in cart
- User can orders product in cart by entering shipping address
- Built using golang programming language and MySQL database
- Applications are bundled in containers using Docker
## API Documentation and Usage
### 1. View Category
- **Method** - `GET`
- **URL Pattern** - `/categories`
- **Authentication** - `false`
- **Usage**
```
curl -X GET BASE_URL/categories
```
- **Example**

### 2. View Product
- **Method** - `GET`
- **URL Pattern** - `/products`
- **Authentication** - `false`
- **Usage**
```
curl -X GET BASE_URL/products
```
- **Example**

### 3. View Product by Category
- **Method** - `GET`
- **URL Pattern** - `/products?category={category}`
- **Authentication** - `false`
- **Usage**
```
curl -X GET BASE_URL/products?=category={category}
```
- **Example**

### 4. Register User
- **Method** - `POST`
- **URL Pattern** - `/register`
- **Authentication** - `false`
- **Usage**
```
curl -X POST \
-d '{ "username": "username",
"password": "password"}' \
BASE_URL/register
```
- **Example**

### 5. Login User
- **Method** - `POST`
- **URL Pattern** - `/login`
- **Authentication** - `false`
- **Usage**
```
curl -X POST \
-d '{ "username": "username",
"password": "password"}' \
BASE_URL/login
```
- **Example**

### 6. Add Shipping Address
- **Method** - `POST`
- **URL Pattern** - `/address`
- **Authentication** - `true`
- **Usage**
```
curl -X POST \
-H "Authorization: Bearer " \
-d '{ "shipping_address": "shipping_address"}' \
BASE_URL/address
```
- **Example**

### 7. View Shipping Address
- **Method** - `GET`
- **URL Pattern** - `/address`
- **Authentication** - `true`
- **Usage**
```
curl -X GET \
-H "Authorization: Bearer " \
BASE_URL/address
```
- **Example**

### 8. Update Shipping Address
- **Method** - `PUT`
- **URL Pattern** - `/address`
- **Authentication** - `true`
- **Usage**
```
curl -X PUT \
-H "Authorization: Bearer " \
-d '{ "address_id": "address_id",
"shipping_address": "shipping_address"}' \
BASE_URL/address
```
- **Example**

### 9. Delete Shipping Address
- **Method** - `DELETE`
- **URL Pattern** - `/address/{address_id}`
- **Authentication** - `true`
- **Usage**
```
curl -X DELETE \
-H "Authorization: Bearer " \
BASE_URL/address/{address_id}
```
- **Example**

### 10. Add Product to Cart
- **Method** - `POST`
- **URL Pattern** - `/cart`
- **Authentication** - `true`
- **Usage**
```
curl -X POST \
-H "Authorization: Bearer " \
-d '{ "product_id": "product_id",
"count": "count"}' \
BASE_URL/cart
```
- **Example**

### 11. View Product in Cart
- **Method** - `GET`
- **URL Pattern** - `/cart`
- **Authentication** - `true`
- **Usage**
```
curl -X GET \
-H "Authorization: Bearer " \
BASE_URL/cart
```
- **Example**

### 12. Update Product in Cart
- **Method** - `PUT`
- **URL Pattern** - `/cart`
- **Authentication** - `true`
- **Usage**
```
curl -X PUT \
-H "Authorization: Bearer " \
-d '{ "cart_id": "cart_id",
"count": "count"}' \
BASE_URL/cart
```
- **Example**

### 13. Delete Product in Cart
- **Method** - `DELETE`
- **URL Pattern** - `/cart/{cart_id}`
- **Authentication** - `true`
- **Usage**
```
curl -X DELETE \
-H "Authorization: Bearer " \
BASE_URL/cart/{cart_id}
```
- **Example**
