API Documentation - AyranIsTheNewRaki/Herodot GitHub Wiki

API Documentation

Method Path Desc.
POST api.herodot.world/register Register
POST api.herodot.world/auth Authentication
GET api.herodot.world/refresh Refresh Token
GET api.herodot.world/user User Details
POST api.herodot.world/heritage Create Heritage
PUT api.herodot.world/heritage Update Heritage
GET api.herodot.world/heritage/1 Get Heritage by id
GET api.herodot.world/heritage Get All Heritages
DELETE api.herodot.world/heritage/1 Delete a Heritage by id

Register

POST api.herodot.world/register

User registration.

Request

Header

Content-Type: application/json

Body

{
  "username": "HerodotUser",
  "password": "herodot123",
  "email": "[email protected]",
  "firstname" : "Herodot",
  "lastname" : "User"
}

Note : firstname and lastname fields are optional. You can complete registration without providing these information.

Response

Status

201 CREATED

Run in Postman

Authentication

POST api.herodot.world/auth

User login.

Request

Header

Content-Type: application/json

Body

{
  "username": "HerodotUser",
  "password": "herodot123"
}

Response

Body

{
  "token" : "YourJWTtokenHere"
}

Status

200 OK

Run in Postman

Refresh Token

GET api.herodot.world/refresh

Refresh token if it expires.

Request

Header

Authorization : "YourExpiredJWTtoken"

Response

Body

{
  "token" : "YourRefreshedJWTtoken"
}

Status

200 OK

Run in Postman

User Details

GET api.herodot.world/user

Gets current user's details.

Request

Header

Authorization : "YourJWTtoken"

Response

Body

{
  "username": "HerodotUser",
  "firstname": "Herodot",
  "lastname": "User",
  "email": "[email protected]",
  "authorities": [
    {
      "authority": "ROLE_USER"
    }
  ],
  "enabled": true
}

Status

200 OK

Run in Postman

Create Heritage

POST api.herodot.world/heritage

Creates a new heritage.

Request

Header

Content-Type: application/json
Authorization : "YourJWTtoken"

Body

{
  "title" : "Heritage Test",
  "category" : "Architecture",
  "description": "Description for Heritage Test",
  "timeLocations" : ["{ 'test' : 'JSON testing' }", "{ 'another':'test'}"]
}

Response

Body

{
  "id": 1,
  "userId": 1,
  "username": "HerodotUser",
  "title": "Heritage Test",
  "description": "Description for Heritage Test",
  "category": "Architecture",
  "timeLocations": [
    "{ 'test' : 'JSON testing' }",
    "{ 'another':'test'}"
  ]
}

Status

201 CREATED

Run in Postman

Update Heritage

PUT api.herodot.world/heritage

Updates a heritage.

Request

Header

Content-Type: application/json
Authorization : "YourJWTtoken"

Body

{
  "id" : 1,
  "title" : "Heritage Test",
  "category" : "Architecture",
  "description": "Description for Heritage Test",
  "timeLocations" : ["{ 'test' : 'JSON testing' }", "{ 'another':'test'}"]
}

Response

Body

{
  "id": 1,
  "userId": 1,
  "username": "HerodotUser",
  "title": "Heritage Test",
  "description": "Description for Heritage Test",
  "category": "Architecture",
  "timeLocations": [
    "{ 'test' : 'JSON testing' }",
    "{ 'another':'test'}"
  ]
}

Status

200 OK

Run in Postman

Get Heritage by id

GET api.herodot.world/heritage/1

Gets a Heritage by id.

Request

Header

Authorization : "YourJWTtoken"

Response

Body

{
  "id": 1,
  "userId": 1,
  "username": "HerodotUser",
  "title": "Heritage Test",
  "description": "Description for Heritage Test",
  "category": "Architecture",
  "timeLocations": [
    "{ 'test' : 'JSON testing' }",
    "{ 'another':'test'}"
  ]
}

Status

200 OK

Run in Postman

Get All Heritages

GET api.herodot.world/heritage

Get all Heritages.

Request

Header

Authorization : "YourJWTtoken"

Response

Body

{
  "id": 1,
  "userId": 1,
  "username": "HerodotUser",
  "title": "Heritage Test",
  "description": "Description for Heritage Test",
  "category": "Architecture",
  "timeLocations": [
    "{ 'test' : 'JSON testing' }",
    "{ 'another':'test'}"
  ]
},
{
  "id": 2,
  "userId": 1,
  "username": "HerodotUser",
  "title": "Heritage Test2",
  "description": "Description for Heritage Test2",
  "category": "Architecture",
  "timeLocations": [
    "{ 'test' : 'JSON testing2' }",
    "{ 'another':'test2'}"
  ]
}

Status

200 OK

Run in Postman

Delete a Heritage by id

DELETE api.herodot.world/heritage/1

Delete a Heritage by id.

Request

Header

Authorization : "YourJWTtoken"

Response

Status

204 NO CONTENT

Run in Postman