Skip to content

API Documentation

Duncan Grubbs edited this page Jul 8, 2020 · 14 revisions

Let’s Go API

Outline of the DB models, routes, and general format of the Let's Go REST API

Table of Contents


DB Models

  • Event
  • User

Authorization

We handle authorization through JSON Web Tokens. These are passed through the Authorization request header in the format: Authorization: Bearer {token}, keep in mind that the header parser will not not be able to parse tokens that are passed in a different way, and will throw an unauthorized exception.

Example

const token = 12345;
fetch(URL, {
    Authorization: `Token ${token}`,
})

Response

All endpoints return the response:

{
  error: Boolean,
  message: String,
  data: Object
}

Available Endpoints

Base URL: /api/v0

*Note that endpoints with IMPL next to them are deployed, and endpoints with TODO next to them are yet to be deployed.

GET Endpoints

  • GET /auth/:token IMPL

    • token: Valid JWT
    • returns: JSON data dump of user
  • GET /events/public/:page IMPL

    • page: Current page of events (PAGE_LIMIT = 40)
    • returns: List of public events
  • GET /events/byIDs TODO

    • ids: List of event IDs
    • returns: List of event objects from IDs
  • GET /events/recommended/:page TODO

    • page: Current page of events (PAGE_LIMIT = 40)
    • returns: List of recommended events
  • GET /events/nearby/:radius IMPL

    • radius: Integer, Miles
      • min: 1, max: 50
    • returns: List of events within the provided radius
  • GET /events/search/:query IMPL

    • query: Query string
    • returns: List of events matching the query
  • GET /events/attendees/:id IMPL

    • id: Event ID
    • returns: List of attendees (user objects) of that event

POST Endpoints

  • POST /auth/signup IMPL

    • user: Valid User Object
    • returns: User that was saved to DB
  • POST /auth/login IMPL

    • user:
      • email: Email of the user
      • password: Password
    • returns: Valid JWT of the user
  • POST /events/create-event IMPL

    • event: Valid event object
    • returns: Event that was added to DB or failure

PUT Endpoints

  • PUT /events/edit IMPL

    • eventID: ID of the event to edit
    • fields: Array of fields to be updated
    • values: Array of values to be inserted into those fields
  • PUT /events/attend/ IMPL

    • eventID: ID of the event to attend
    • returns: Success status
  • PUT /auth/update IMPL

    • fields: Array of fields to be updated
    • values: Array of values to be inserted into those fields

DELETE Endpoints

  • DELETE /events IMPL
    • eventID: ID of the event to delete