Skip to content

Event API Documentation

ege-kaya edited this page Jan 3, 2022 · 15 revisions

Get event by id

GET 'api/posts/<id>/'

  • Author: Doğukan Akar

  • Definition: Allows a user to fetch an event from database

  • Example Response Value:

    {
        "@context": "https://www.w3.org/ns/activitystreams",
        "summary": "Sally created an event",
        "type": "Create",
        "actor": {
            "type": "Person",
            "name": "Sally"
        },
        "object": {
            "type": "Event",
            "postId": "",
            "ownerId": "",
            "content": "",
            "title": "Beginner friendly tennis game",
            "creationDate": "2014-11-31T23:00:00-08:00",
            "lastUpdateDate": "2014-11-31T23:00:00-08:00",
            "numberOfClicks": 0,
            "location": {
                "name": "Etiler Tennis Club",
                "type": "Place",
                "longitude": 12.34,
                "latitude": 56.78,
                "altitude": 90,
                "units": "m"
            },
            "eventDate": "2014-12-31T23 00 00-08 00",
            "eventSport": "Tennis",
            "eventMinAge": 16,
            "eventMaxAge": 18,
            "eventMinSkillLevel": 1,
            "eventMaxSkillLevel": 5,
            "eventPlayerCapacity": 12,
            "eventSpectatorCapacity": 12,
            "eventApplicants": [1,2,3],
            "eventPlayers": [1,2,3]
        }
    } 
  • Parameters

    Parameter Description Parameter Type Data Type
    id ID of the searched event Path Int
  • Response Messages

    • 200: Ok.
    • 404: Not Found.

Get all events

GET 'api/posts/'

  • Author: Doğukan Akar

  • Definition: Returns a list of post ids using filters.

  • Example Response Value:

    { 
        "@context": "https://www.w3.org/ns/activitystreams",
        "summary": "Object history",
        "type": "OrderedCollection",
        "totalItems": 2,
        "totalPages": 2,
        "orderedItems": [ 
            { 
                "type": "Create",
                "actor": {
                    "type": "Person",
                    "name": "Sally"
                },
                "object": "/api/posts/1" 
            },
            { 
                "type": "Create",
                "actor": {
                    "type": "Person",
                    "name": "Sally"
                },
                "object": "/api/posts/2" 
            } 
        ] 
    } 
  • Parameters

    Parameter Description Parameter Type Data Type
    query Query string Query String
    creation_date Creation date of the searched event Query DateTime
    location Location of the searched event Query String
    date Date of the searched event Query DateTime
    duration Duration of the searched event Query DateTime
    sport Sport type of the searched event Query Char
    age_group Which age group is preferred for the searched event Query Integer
    player_capacity Player capacity of the searched event Query Integer
    spec_capacity Spectator capacity of the searched event Query Integer
    players Players of the searched event Query Integer
    spectators Spectators of the searched event Query Integer
    latitude Latitude of the searched event Query Float
    longitude Longitude of the searched event Query Float
    owner Owner of the searched event Query User
    player Player of the searched event Query User
    spectator Spectator of the searched event Query User
    player_applicant Player applicant of the searched event Query User
    spectator_applicant Spectator of the searched event Query User
  • Response Messages

    • 200: Ok.
    • 500: Internal server error.

Get events in pages

GET 'api/posts?page=<page>'

  • Author: Kerem Zaman

  • Definition: Returns a list of post ids using filters.

  • Example Response Value:

    [1,2,3]
  • Parameters

    Parameter Description Parameter Type Data Type
    page Page of the list of events Query Integer
  • Response Messages

    • 200: Ok.
    • 500: Internal server error.

Create an event

POST 'api/posts'

  • Author: İbrahim Kağan Bayat

  • Definition: Allows a user to create an event

  • Example Response Value:

    {
        "@context": "https://www.w3.org/ns/activitystreams",
        "summary": "Sally created an event",
        "type": "Create",
        "actor": {
            "type": "Person",
            "name": "Sally"
        },
        "object": {
            "type": "Event",
            "name": "A Simple Event",
            "postId": "",
            "ownerId": "",
            "content": "",
            "title": "Beginner friendly tennis game",
            "creationDate": "2014-11-31T23:00:00-08:00",
            "lastUpdateDate": "2014-11-31T23:00:00-08:00",
            "numberOfClicks": 0,
            "location": {
                "name": "Etiler Tennis Club",
                "type": "Place",
                "longitude": 12.34,
                "latitude": 56.78,
                "altitude": 90,
                "units": "m"
            },
            "eventDate": "2014-12-31T23 00 00-08 00",
            "eventSport": "Tennis",
            "eventMinAge": 16,
            "eventMaxAge": 18,
            "eventMinSkillLevel": 1,
            "eventMaxSkillLevel": 5,
            "eventPlayerCapacity": 12,
            "eventSpectatorCapacity": 12,
            "eventApplicants": [1,2,3],
            "eventPlayers": [1,2,3]
        }
    } 
  • Example Failure Value:

    {
      It gives 204 error code (No content).
    }
  • Parameters

    Parameter Description Parameter Type Data Type
    content Content of the created event Body String
    title Title of the searched event Body String
    location Location of the created event Body String
    date Date of the created event Body DateTime
    duration Duration of the created event Body DateTime
    sport Sport type of the created event Body Char
    age_group Which age group is preferred for the created event Body Integer
    player_capacity Player capacity of the created event Body Integer
    spec_capacity Spectator capacity of the created event Body Integer
    latitude Latitude of the created event Body Float
    longitude Longitude of the created event Body Float
    owner Owner of the created event Body User
  • Response Messages

    • 201: Created.
    • 400: Bad request.

Apply to an event

POST 'api/posts/<id>/apply'

  • Author: Kerem Zaman

  • Definition: Allows a user to apply for an event as a spectator or a player

  • Example Response Value:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "summary": "1 applied to event 1 as spectator",
  "type": "Join",
  "actor": {
    "type": "Person",
    "name": "kerem"
  },
  "object": {
    "type": "Event",
    "name": "A Simple Event",
    "postId": 1,
    "ownerId": 1,
    "content": "nba fans gathering for the lakers vs miami match",
    "title": "basketball event",
    "creationDate": "2021-12-28T19:44:28.254597Z",
    "numberOfClicks": 0,
    "location": {
      "name": "Istanbul",
      "type": "Place",
      "longitude": 28.9784,
      "latitude": 41.0082,
      "units": "m"
    },
    "eventDate": "2022-01-03T10:00:00Z",
    "eventSport": "Basketball",
    "eventMinAge": 18,
    "eventMaxAge": 80,
    "eventMinSkillLevel": 1,
    "eventMaxSkillLevel": 4,
    "eventPlayerCapacity": 3,
    "eventSpectatorCapacity": 3,
    "eventApplicantsAsPlayer": [],
    "eventApplicantsAsSpectator": [
      1
    ],
    "eventPlayers": []
  }
}
  • Parameters

    Parameter Description Parameter Type Data Type
    id ID of the event to apply Path Int
    user ID of the user applying to the event Body Int
    type Type of the applicant (spectator/player) Body String
  • Response Messages

    • 200: Ok.
    • 400: Bad Request.
    • 409: Conflict.

Get list of users applied to an event

GET'api/posts/<id>/applicants'

  • Author: Kerem Zaman

  • Definition: Allows users to see spectator/player applicants for an event

  • Example Response Value:

{
  "applicants": [
    1,
    2
  ]
}
  • Parameters

    Parameter Description Parameter Type Data Type
    id ID of the event Path Int
    type Type of the applicant (spectator/player) Query String
  • Response Messages

    • 200: Ok.
    • 400: Bad Request.

Accept or reject users applied to an event

POST 'api/posts/<id>/applicants'

  • Author: Kerem Zaman

  • Definition: Allows event owners to accept or reject spectator/player applicants

  • Example Response Value:

{
  "@context": "https://www.w3.org/ns/activitystreams",
  "summary": "1 accepted 3 to event 1 as player",
  "type": "Accept",
  "actor": {
    "type": "Person",
    "name": "3"
  },
  "object": {
    "type": "Event",
    "name": "A Simple Event",
    "postId": 1,
    "ownerId": 1,
    "content": "nba nba",
    "title": "basketball event",
    "creationDate": "2021-12-28T19:44:28.254597Z",
    "numberOfClicks": 0,
    "location": {
      "name": "Istanbul",
      "type": "Place",
      "longitude": 28.9784,
      "latitude": 41.0082,
      "units": "m"
    },
    "eventDate": "2022-01-03T10:00:00Z",
    "eventSport": "Basketball",
    "eventMinAge": 18,
    "eventMaxAge": 80,
    "eventMinSkillLevel": 1,
    "eventMaxSkillLevel": 4,
    "eventPlayerCapacity": 3,
    "eventSpectatorCapacity": 3,
    "eventApplicantsAsPlayer": [],
    "eventApplicantsAsSpectator": [
      1,
      2
    ],
    "eventPlayers": [
      3
    ]
  }
}
  • Parameters

    Parameter Description Parameter Type Data Type
    id ID of the event Path Int
    type Type of the applicant (spectator/player) Body String
    user ID of the user applying to the event Body Int
    owner ID of the user hosts the event Body Int
    accept status of the applicant Body Bool
  • Response Messages

    • 200: Ok.
    • 400: Bad Request.
    • 409: Conflict.
Clone this wiki locally