Skip to content

Practice app API Documentation

eye-78 edited this page Jun 13, 2021 · 26 revisions

API Documentation

Event Related Endpoints

/api/v1.0/events POST - Create an Event

Endpoint: api/v1.0/events
Method: POST
Authorization: Not Needed
Author: Elif Sema Balcıoğlu
Body Parameters:

 {
             “name” : Name of the event, title. required
             “creator_user” : Id of the user creating the event. Id must be registered to a user. required
             “location” : Address of the event, given using basic English. required
             “sport” : Id of the sport. Between 102-120. required
             “date” : Date of the event. Format is "YYYY-MM-DDTHH:MM required
}

Expected Response When No Error:

{
             "creator_user": Id of the user creating the event.
             "date": Date of the event.
             "entered_address":  Address of the event, given using basic English. Same as location on parameters.
             "formatted_address": Formatted address by Google Maps API.
             "id": Id of the event.
             "latitude": Latitude of the location.
             "longitude": Longitude of the location.
             "name": Name of the event, title.,
             "sport": Id of the sport.
}

Responses:
201: "Event created and added to database." Example Response:

{
              "creator_user": 1,
              "date": "10.12.2021",
              "entered_address": "Trabzon",
              "formatted_address": "Trabzon, Ortahisar/Trabzon, Turkey",
              "id": 2,
              "latitude": 41.0026969,
              "longitude": 39.7167633,
              "name": "abc",
              "sport": 103
}

400: "Body parameters are not correct."
Example Response:

{
              "error": "Parameters are not correct"
}

503:"There is an error, try later."

{
              "error": "Service Unavailable"
}

/api/v1.0/events GET - Display Events

Endpoint: api/v1.0/events
Method: POST
Authorization: Not Needed
Author: Ekrem Yusuf Ekmekci
Query Parameters:

        “sport”: Sport id that represents sport type. Between 102-120   
	“date_from”: Date string. Filters events before the given date. Format: YYYY-MM-DDTHH:HH   
	“date_to”: Date string. Filters events after the given date. Format: YYYY-MM-DDTHH:HH   

Responses:
200: “Events are fetched from database”
Returns an array of json objects.

	[{
		“Creator_name”: (string) Full name of the creator. Random value for every call.
		"creator_user”: (integer) User id of the creator.
		“date”: (string) Date of the event. Format is YYYY-MM-DDTH:HH
		“Entered_address”: (string) Address entered by the creator.
		“formatted_address”: (string) Formatted address returned by google api. Takes entered address as input.
		“id” : (integer) Id of the event
		“latitude” : (number) Latitude of the event. Based on the formatted address.
		“longitude” : (number) Longitude of the event. Based on the formatted address.
		“name” : (string) Event description entered by the creator.
		“sport” : (integer) Sport type represented as a number. Corresponds to a string in another table.
	}]

400: Error. Single generic message

	“Properties can not be fetched from database.”

503: Unexpected. Single generıc message

	“There is an error. Try later.”

/api/v1.0/events/<event_id>/interesteds POST - Post New Interested Into System

Endpoint: api/v1.0/events/<event_id>/interesteds
Method: POST
Authorization: Not Needed
Author: Ekrem Yusuf Ekmekci
Paremeters:

  • Path Parameter
<event_id>: (integer) Id of the event that the user is interested in.
  • Body Parameter
{ “user_id” : (integer) Id of the user that declares their interest }

Responses:
201: “Interested user is inserted into database”
Returns the pair that was inserted into the database.

	{
		“event_id” : (integer) Id of the event that the user is interested in.
		“user_id” : (integer) Id of the user that declares their interest.
	}

400: Error. Single generic message

	“Properties can not be inserted into database.”

503: Unexpected. Single generıc message

	“There is an error. Try later.”

/api/v1.0/events/<event_id> GET - Get an event by its id

Endpoint: api/v1.0/events/<event_id> Method: GET
Authorization: Not Needed
Author: Deniz Arda Budak
Parameters:
Path parameter:
event_id (required)

Expected Response When No Error:

{
                 "event_id": Id of the user creating the event, obtained from the path
		 "id": oId of the user creating the event, obtained from database
                 "name": Latitude of the location.
                 "date": Date of the event.
                 "entered_address":  Address of the event, given using basic English. Same as location on parameters.
                 “Formatted_address”: Address of the event, taken using Google Maps API
                 "latitude": Latitude of the address
                 "longitude": Id of the event.
		 “creator_user”: ID of the user creating the event.                         
                 "sport": Longitude of the location.
                 "hour": The hour at which the event will take place.
                 "weather": The description of the weather, taken using OpenWeatherMap API.
                 "weather_icon": The weather icon id, taken using OpenWeatherMap API.
}

Responses:
200: "Event with the corresponding ID is fetched."
Example Response:

{ 
          "event_id”: 56
          "id": 56
          "name": “Football Match at 9”
          "date": “2021-06-16”
          "entered_address": “Ankara”                          
          “formatted_address”: “Ankara, Turkey”
          "latitude":  39.9333365                        
          "Longitude": 32.885654
          “creator_user”:  160                      
          "sport": “Soccer”
          "hour":  “19:00”
          "weather": “scattered clouds”
          "weather_icon": “03d”        
 }

400: "Event ID is not correct."

        {
                 "error": “Event ID is not correct”
        }

/api/v1.0/events/<event_id>/spectators POST - Add a spectator to an event

Endpoint: api/v1.0/events/<event_id>/spectators
Method: POST
Description: API for adding a new Spectator to an event. The path parameter is required to be an integer. Body parameter is described below. Both parameters are required.
Authorization: Not Needed
Author: Deniz Arda Budak
Parameters:
Path Parameter:
<event_id>: (integer) Id of the event that the user that wants to be a spectator of the event.
Body Parameter:

{ 
        “user_id” : (integer) Id of the user that wants to be a spectator of the event
}

Responses:
201: “Spectator user is inserted into database.”
Returns the pair that was inserted into the database.

{
	“event_id” : (integer) Id of the event that the user wants to spectate.   
	“user_id” : (integer) Id of the user that the user wants to spectate.
}

400: "Bad request"

{
        'error': "user id is not given"
} 

503: "There is a server problem, try again later."

Sport Related Endpoints

/api/v1.0/sports GET - Basic Filtering of Sports

Endpoint: api/v1.0/sports?keyword=<keyword>
Method: GET
Authorization: Not Needed
Author: Elif Sema Balcıoğlu
Expected Response When No Error:

{
               "sports": List of sports which contain the keyword in their names.
               [
                  {
                     "id": Id of the sport.
                     "sport": Name of the sport.
                  }
               ]
}

Responses:
200: "Result returned with no error"
Example Response for <keyword> = sp:

{
               "sports": [
                  {
                     "id": 103, 
                     "sport": "Motorsport"
                  }
               ]
}

503: "Service unavailable"

{
              "error": “Service unavailable”
}

Badge Related Endpoints

/api/v1.0/badges POST - Create a Badge

Endpoint: api/v1.0/badges
Method: POST
Authorization: Not Needed
Author: Berk Atıl
Body Parameters:

 {
             “name” : Name of the badge.
             “symbol” : Symbol URL of the badge.
}

Expected Response When No Error:

{
             "badgeId": Id of the badge.
             "name": Name of the badge.
             "symbol": Symbol URL of the badge
             "point": Point of the badge extracted from a bitcoin price.
}

Responses:
201: "Badge added."
Example Response:

{
              "badgeId": 1,
              "name": "Name",
              "symbol": "picture.com",
              "point": 7
}

503:"Try Later"

/api/v1.0/badges/point GET - Getting a Badge Point by Name

Endpoint: api/v1.0/badges/point?name=<name>
Method: GET
Authorization: Not Needed
Author: Berk Atıl
Expected Response When No Error:

{
             "name": Name of the badge.
             "point": Point of the badge extracted from a bitcoin price.
}

Responses:
200: "Badge point is retrieved."
Example Response:

{
             "name": "Name
             "point": 7
}

400:"No badge with this name."
503:"Error Occured, Try Again Later"

api/v1.0/show_badge GET - Showing All Badges

Endpoint: /show_badge
Method: Get
Authorization: Not Needed
Author: İbrahim Melih Aktaş
Parameters: -
Expected Response When No Error:

{
               "badgeID": Name of the badge.,  
               "control": Decides whether HTML should show badges or not,  
               "dog_photos": Cat photo from the RandomCat API,  
               "name": Name of the badge.,  
               "point": Point of the badge,  
               "symbol": It is a URL for the symbol picture of the badge. 
} 

Responses:
200: "All badges are retrieved."
Example Response:

{
               "badgeID": 5,  
               "control": true,  
               "dog_photos": "https://i.thatcopy.pw/cat/H20brn4.jpg",  
               "name": "Best Scorer",  
               "point": 3,  
               "Symbol": "https://www.wikihow.com/images_en/thumb/d/db/Get-the-URL-for-Pictures-Step-2-Version-6.jpg/v4-460px-Get-the-URL-for-Pictures-Step-2-Version-6.jpg.webp"
} 

Discussion Related Endpoints

api/v1.0/events/<event_id>/discussions GET - Viewing Discussions For An Event

Endpoint: api/v1.0/events/<event_id>/discussions
Method: GET
Authorization: Not Needed
Author: Musa Nuri İhtiyar

Parameters: { “event_id”: ID of the event }

Expected Response When No Error:

{
  “id”:  ID of the event
  “description”: Description of the sport type of the event
  “text”: Discussions of the event
                                   }

Responses:

201:  "Discussion has been found and returned in the proper format"

Example Response:

{
                     "id": 1,
                     "description": "Competitive and recreative sport opposing two teams, basketball is played on a court where two hoops are suspended in height at each extremity. With your team, your goal is to score points by throwing the ball into the basket. You will have to do some feints and dribble the ball to progress on the court and get as close as possible to the basket before throwing the ball. Can you jump high enough to make a dunker?",
                     "text": "Hello how are you?",
                    }

Error responses

400: "A problem related with database has occured." 
401: "Given event_id is wrong"

Equipment Related Endpoint

api/v1.0/equipments/ POST - Adding an Equipment

Endpoint: api/v1.0/equipments/
Method: POST
Authorization: Not Needed
Author: Ömer Faruk Süve

Parameters: { “name”: Name of the equipment }

Expected Response When No Error:

{
  “id”:  ID of the equipment
  “name”: Name of the equipment
  “price”: Price of the equipment
                                   }

Responses:

201:  "Successfully added!"

Example Response:

{ "id": 1, "name": "Ball", "price": "10.0", }

Error responses

400: "A problem has occured." 
409: "Equipment already exists."

General

🏠 Home

📖 Project Description

📞 Communication Plan

📝 Contributing

Team

Project

Cmpe 451


Cmpe 352

Meeting Notes

CmpE352 Meetings
Android Meetings
Front-End Meetings

Research

Templates

Clone this wiki locally