RESTFul API for Pixel (Upcoming open source Apps)
-
Set your database in
src/main/resources/application.properties
-
- First, pull MySQL Docker Images using
docker pull mysql
- And then start Pixel Docker Container using
docker-compose -f docker-compose.yml up -d
- First, pull MySQL Docker Images using
-
Type on terminal
gradlew bootRun
Authentication
Request :
- Method : POST
- Endpoint :
/api/auth/login
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"email" : "string",
"password" : "string"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date",
"token" : "string"
}
}
Request :
- Method : POST
- Endpoint :
/api/auth/register
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"name" : "string",
"email" : "string",
"password" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "file"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Image
Request :
- Method : GET
- Endpoint :
/api/images/{id_image}
- Header :
- Accept: application/json
Response : Image
Users
All API in users must use this authentication
- Header :
- Authorization :
Bearer your_api_key
- Authorization :
Request :
- Method : POST
- Endpoint :
/api/users
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"name" : "string",
"email" : "string",
"password" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "file"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : GET
- Endpoint :
/api/users/{id_user}
- Header :
- Accept: application/json
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : GET
- Endpoint :
/api/users
- Header :
- Accept: application/json
- Query Params
- page : number, def = 1
- size : number, def = 10
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"currentPage" : "number",
"isLast" : "boolean",
"totalPage" : "number",
"data" : [
{
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
]
}
Request :
- Method : PUT
- Endpoint :
/api/users/{id_user}
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"name" : "string",
"email" : "string",
"password" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "file"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : PUT
- Endpoint :
/api/users/{id_user}/changepassword
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"oldPassword" : "string",
"newPassword" : "string"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"name" : "string",
"email" : "string",
"gender" : "string",
"phone" : "string",
"photo" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : DELETE
- Endpoint :
/api/users/{id_user}
- Header :
- Accept: application/json
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {}
}
Post
All API in post must use this authentication
- Header :
- Authorization :
Bearer your_api_key
- Authorization :
Request :
- Method : POST
- Endpoint :
/api/post
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"title" : "string",
"description" : "string",
"users_id" : "string",
"image" : "file"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"title" : "string",
"description" : "string",
"image" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : GET
- Endpoint :
/api/post/{id_post}
- Header :
- Accept: application/json
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id": "string",
"title": "string",
"description": "string",
"image": "string",
"created_at": "date",
"updated_at": "date"
}
}
Request :
- Method : GET
- Endpoint :
/api/users
- Header :
- Accept: application/json
- Query Params
- page : number, def = 1
- size : number, def = 10
- users_id : string, def = null
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"currentPage" : "number",
"isLast" : "boolean",
"totalPage" : "number",
"data" : [
{
"id": "string",
"title": "string",
"description": "string",
"image": "string",
"created_at": "date",
"updated_at": "date",
"users": {
"name": "string",
"photo": "string",
"id": "string"
}
}
]
}
Request :
- Method : PUT
- Endpoint :
/api/post/{id_post}
- Header :
- Content-Type: multipart/form-data
- Accept: application/json
- Body :
{
"title" : "string",
"description" : "string",
"users_id" : "string",
"image" : "file, allow null"
}
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {
"id" : "string, unique",
"title" : "string",
"description" : "string",
"image" : "string",
"updated_at" : "Date",
"deleted_at" : "Date"
}
}
Request :
- Method : DELETE
- Endpoint :
/api/post/{id_post}
- Header :
- Accept: application/json
Response :
{
"code" : "number",
"error" : "boolean",
"message" : "string",
"data" : {}
}