Skip to content

Latest commit

 

History

History
196 lines (196 loc) · 3.15 KB

README.md

File metadata and controls

196 lines (196 loc) · 3.15 KB

Kitsurfing - Backend

API Calls

Api Structure

API General Structure

Api General Structure

Database design

DB design

Inputs Examples

For /signup

{
    "username" : "demo",
    "password" : "demo123"
}

For /login

{
    "username" : "demo",
    "password" : "demo123"
}

For /signout and /spots/* and /favorites/*

{
    "token" : "6f8ec628-8772-4fd8-8dcf-91b9b134f758"
}

For /users/me/forgot-password

{
    "username" : "demo"
}

For /users/me/reset-password

{
    "password" : "newDemo123",
    "resetToken" : {
        "token" : "37cd3b23-75a0-499e-be9e-80f51353a4c3"
    }
}

Successful Outputs Examples

For /signup

{
    "response" : null,
    "status" : "succes",
    "message" : "User has been registered!"
}

For /login

{
    "response" : 
    {
        "token" : "6f8ec628-8772-4fd8-8dcf-91b9b134f758"
    },
    "status" : "succes",
    "message" : ""
}

For /signout

{
    "response" : null,
    "status" : "succes",
    "message" : "The token has been changed!"
}

For /users/me/forgot-password

{
    "response" : 
    {
        "token" : "37cd3b23-75a0-499e-be9e-80f51353a4c3"
    },
    "status" : "succes",
    "message" : ""
}

For /users/me/reset-password

{
    "response" : null,
    "status" : "succes",
    "message" : "Password has been changed!"
}

For /spots?country=Spain&windProbability=97

{
  "response": [
    {
      "id": 58,
      "name": "Dakhla",
      "country": "Spain"
    },
    {
      "id": 59,
      "name": "Heliophora Lagoon",
      "country": "Spain"
    }
  ],
  "status": "success",
  "message": ""
}

For /spots/5

{
  "response": {
    "longitude": 59.67,
    "latitude": 22.03,
    "windProbability": 87,
    "whenToGo": "AUGUST"
  },
  "status": "success",
  "message": ""
}

For /spots/countries

{
  "response": [
    "Cook Islands",
    "South Africa",
    "Venezuela",
    "Oman",
    "Ecuador",
    "Morocco",
    "Australia",
    "Mexico",
    "Tanzania",
    "Viet Nam",
    "Peru",
    "Senegal",
    "Brazil",
    "Guadeloupe",
    "Libya",
    "Saudi Arabia",
    "Indonesia",
    "United Kingdom",
    "New Zealand",
    "United Arab Emirates",
    "Israel",
    "Sri Lanka",
    "Spain",
    "Egypt",
    "India"
  ],
  "status": "success",
  "message": ""
}

For /favorites/spots/add/5

{
    "response" : null,
    "status" : "succes",
    "message" : "The spot has been added!"
}

For /favorites/spots/delete/5

{
    "response" : null,
    "status" : "succes",
    "message" : "The spot has been deleted!"
}

Invalid inputs

The server will return the error in this format:

{
    "response" : null,
    "status" : "failed",
    "message" : "Information about the error"
}

E.g For /spots

With input

{
    "token" : "12345-abc"
}

It will return

{
  "response": null,
  "status": "failed",
  "message": "Invalid token format!"
}