Skip to content

RESTFul API for Pixel (Upcoming open source Apps)

Notifications You must be signed in to change notification settings

dinopriyano/Pixel-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pixel API (On Progress)

RESTFul API for Pixel (Upcoming open source Apps)

Setup

  • Setup Database :

    Set your database in src/main/resources/application.properties

  • Start Docker :

    • First, pull MySQL Docker Images using docker pull mysql
    • And then start Pixel Docker Container using docker-compose -f docker-compose.yml up -d
  • Start Spring Boot Apps (Gradle) :

    Type on terminal gradlew bootRun

API Spec

Authentication

Login

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"
    }
}

Register

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

Get Image

Request :

  • Method : GET
  • Endpoint : /api/images/{id_image}
  • Header :
    • Accept: application/json

Response : Image

Users

Authentication

All API in users must use this authentication

  • Header :
    • Authorization : Bearer your_api_key

Create User

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"
    }
}

Get User

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"
    }
}

List User

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"
        }
    ]
}

Update User

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"
    }
}

Change Password

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"
    }
}

Delete User

Request :

  • Method : DELETE
  • Endpoint : /api/users/{id_user}
  • Header :
    • Accept: application/json

Response :

{
    "code" : "number",
    "error" : "boolean",
    "message" : "string",
    "data" : {}
}
Post

Authentication

All API in post must use this authentication

  • Header :
    • Authorization : Bearer your_api_key

Create Post

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"
    }
}

Detail Post

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"
    }
}

List Post

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"
          }
        }
    ]
}

Update Post

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"
    }
}

Delete Post

Request :

  • Method : DELETE
  • Endpoint : /api/post/{id_post}
  • Header :
    • Accept: application/json

Response :

{
    "code" : "number",
    "error" : "boolean",
    "message" : "string",
    "data" : {}
}

Releases

No releases published

Packages

No packages published

Languages