Learning kotlin spring boot application restful API with basic CRUD and authentication API Key
- MySQL Database
- Docker Compose
- Spring Boot
- Download and install MySQL docker images the latest version on your machines
- And run this command :
docker compose -f docker-compose.yml up -d
All the request restful API must have headers authentication
- Header :
- X-Auth-API : secret key
Use default secret api key bellow for authenticated. This key is md5 encryption from secret value, you can find on application.properties
Default Api Key :
5ebe2294ecd0e0f08eab7690d2a6ee69
- Method : GET
- Endpoint :
api/v1/product/{id}
- Header :
- Accept: application/json
{
"status": "boolean",
"code": "number",
"message": "string",
"data": {
"id": 1,
"name": "string",
"price": "number",
"qty": "number"
}
}
- Method : POST
- Endpoint :
api/v1/product
- Header :
- Accept: application/json
- Content-Type: application/json
- Body :
{
"name": "string",
"price": "number",
"qty": "number"
}
{
"status": "boolean",
"code": "number",
"message": "string",
"data": null
}
- Method : GET
- Endpoint :
api/v1/product
- Header :
- Accept: application/json
- Query :
- page: number
- limit: number
{
"status": "boolean",
"code": "number",
"message": "string",
"data": {
"total": "number",
"current_page": "number",
"prev_page": "number",
"content": [
{
"id": 1,
"name": "string",
"price": "number",
"qty": "number"
}
]
}
}
- Method : PUT
- Endpoint :
api/v1/product/{id}
- Header :
- Accept: application/json
- Content-Type: application/json
- Body :
{
"name": "string",
"price": "number",
"qty": "number"
}
{
"status": "boolean",
"code": "number",
"message": "string",
"data": null
}
- Method : DELETE
- Endpoint :
api/v1/product/{id}
- Header :
- Accept: application/json
{
"status": "boolean",
"code": "number",
"message": "string",
"data": null
}