Skip to content

RESTful API Docs

Andre Hijaouy edited this page Oct 29, 2017 · 2 revisions

Drawchange RESTful API Documentation

This page will serve to document all the RESTful API endpoints being exposed.

Authentication Endpoints

TODO

Data Endpoints

Users

  • GET /api/users
  • POST /api/users
  • GET /api/users/:user_id
  • PUT /api/users/:user_id
  • DELETE /api/users/:user_id

Events

  • GET /api/events Gets a list of all the events in the database.
    Takes no parameters. Query parameters will be added in v2.

Successful Response

{  
  "events": [ Objects (Event) ]  
} 
  • POST /api/events Post a new event to the database.

Request Body

{  
  "name": String Required,  
  "date": Date Required,  
  "location": String Required,  
  "description": String Required,  
  "contact": String Required,  
  "volunteers": Array[ Object (Users)],  
  "max_volunteers": Number Required
} 

Successful Response (Status Code 200)

{  
  "event": Object (Event) 
} 

Failed Response (Status Code 422: Field Validation Failed)

{  
  "errors": {  
        Name of broken field: {  
            "location": body, params, or query,  
            "param": Name of Conflicting Param,  
            "msg": Error Msg  
        }  
    }  
}  

Internal Server Error Response (Status Code 500)

{  
  "errors": Object(Error)  
}  
  • GET /api/events/:id Get details for a single event.
    Takes a valid MongoDB ID as a URL Parameter.

Successful Response

{  
  "event": Object (Event) 
} 

Failed Response (Status Code 404: MongoDB ID Not Found)

{  
  "errors": "No response found with id: XXXXXXXXXXXXX"  
}  

Failed Response (Status Code 422: Invalid MongoDB ID)

{  
  "errors": {  
        "id": {  
            "location": "params",  
            "param": "id",  
            "msg": "Invalid value" 
        }  
    }  
}  

Internal Server Error Response (Status Code 500)

{  
  "errors": Object(Error)  
}  
  • PUT /api/events/:id
  • DELETE /api/events/:id

Clone this wiki locally