Skip to content

API Version 1: Events

Nikhil Kansal edited this page Aug 20, 2017 · 5 revisions

GET /app/api/v1/event/:uuid?

This route requires authentication. A UUID may be optionally specified, in which case a single event will be returned matching the provided UUID (or null if no such event exists). If no UUID is provided, the route will return all events. Note the following nuance in the usage of this API: Getting all events returns an array of event objects called events, whereas getting a single event returns an event object.

The schema for an event object is as follows:

{
    // event UUID
    uuid: String,
    // event organization, e.g. ACM
    organization: String,
    // event committee, e.g. 'Hack' (empty string means Board or general)
    committee: String,
    // URL of cover image
    cover: String,
    // title of event
    title: String,
    // description of event
    description: String,
    // location of event
    location: String,
    // link to FB event, eventbrite, etc.
    eventLink: String,
    // start date+time of event (UTC String format)
    startDate: Date,
    // end date+time of event (UTC String format)
    endDate: Date,
    // attendance points for event
    attendancePoints: Number
}

An example usage of getting all events:

$ curl -H "Authorization: Bearer <token>" localhost/app/api/v1/event
{
    "error": null,
    "events": [
        {
            "uuid": "4fe2be71-0144-4152-aefd-97a9739e0c31",
            "organization": "ACM",
            "committee": "",
            "cover": "http://link-to.cover/image",
            "title": "Fall General Meeting",
            "description": "Come to the ACM kickoff meeting. There will be free food!",
            "location": "CNSI",
            "eventLink": "http://facebook.com/link-to-event",
            "startDate": 2017-05-07T19:00:00.000Z,
            "endDate": 2017-05-07T21:00:00.000Z,
            "attendancePoints": 20
        }, ...
    ]
}

An example of getting an event by UUID:

$ curl -H "Authorization: Bearer <token>" localhost/app/api/v1/event/4fe2be71-0144-4152-aefd-97a9739e0c31
{
    "error": null,
    "event": {
        "uuid": "4fe2be71-0144-4152-aefd-97a9739e0c31",
        "organization": "ACM",
        "committee": "",
        "cover": "http://link-to.cover/image",
        "title": "Fall General Meeting",
        "description": "Come to the ACM kickoff meeting. There will be free food!",
        "location": "CNSI",
        "eventLink": "http://facebook.com/link-to-event",
        "startDate": 2017-05-07T19:00:00.000Z,
        "endDate": 2017-05-07T21:00:00.000Z,
        "attendancePoints": 20
    }
}

GET /app/api/v1/event/past

This route requires authentication. It works just like the GET /app/api/v1/event route in the case that no UUID is provided, except it only returns events that are in the past. If there are no past events, the events field will be empty. Otherwise, it will be an array of event objects.

GET /app/api/v1/event/future

This route requires authentication. It works just like the GET /app/api/v1/event route in the case that no UUID is provided, except it only returns events that are in the future. If there are no future events, the events field will be empty. Otherwise, it will be an array of event objects.

POST /app/api/v1/event

This route requires authentication, as well as admin privileges. It adds a specified event to the organization's event list. The body must be a JSON object with a top-level event object which specifies the parameters of the event. Refer to the event object schema above for full details. The following fields are required:

  • title
  • description
  • startDate
  • endDate
  • attendanceCode -- the attendance code for the event

Although not required, it is recommended that the attendancePoints field be set as well. By default, it is 0. The other fields are optional, except the uuid field, which is not allowed to be specified. If the request was successful, an HTTP response with status code 200 will be issued with a JSON body containing a top-level event object that contains the full details of the newly created event:

{
    error: null,
    event: {
        ...
    }
}