hasanmohdkhan / JTA-Blog

Java traning project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blog API


Blog API is a authenication based api

/register

Request : POST

Body:

{
  "username":"hasan",
  "password":"khan"
}

Response:

{
    "responseStatus": "SUCCESS",
    "response": {
        "username": "hasan",
        "password": "khan"
    }
}

/authenticate

Request : POST

Body:

{
  "username":"hasan",
  "password":"khan"
}

Response:

{
    "responseStatus": "SUCCESS",
    "response": {
        "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtYWhpMSIsImV4cCI6MTYyMzA1NzYzOSwiaWF0IjoxNjIzMDM5NjM5fQ.JkztnEKU3Yp6JaYHUHw4afyIlivqFT1TP-2ctlW7x7BcJv3oB-PdOke90kfb4fCsBlOEuQJpyEoek989ZLvJyA"
    }
}

/blog/add

Request : POST

Header:

Authorization: "Bearer {{token}}"

Body:

{"title":"Test title","body":"test body"}

NOTE: title and body are required and can not be empty.

Response:

{
    "responseStatus": "SUCCESS",
    "response": [
        {
            "id": 1,
            "title": "Test title",
            "body": "test body",
            "author": "hasan",
            "createdAt": 1623019961875
        }
    ]
}

/blog/update/{id}

Request : POST

Header:

Authorization: "Bearer <your token here>"

Body:

{"title":"update Test title","body":"update test body"} // for updating both

Option: {"title":"update Test title"} // for updating title
Option: {"body":"update test body"} // for updating body

Response:

{
  "responseStatus": "SUCCESS",
  "response": {
    "id": 2,
    "title": "update Test title",
    "body": "update test body",
    "author": "hasan",
    "createdAt": 1623020834461,
    "updatedAt": 1623020844738
  }
}

/blog/delete/{id}

Request : GET

Header:

Authorization: "Barer <your token here>"

Response:

{
    "responseStatus": "SUCCESS",
    "response": "Deleted."
}

About

Java traning project


Languages

Language:Java 100.0%