Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Tested API functions

Jeremy Neal edited this page May 13, 2014 · 1 revision

Inputs and Outputs. Currently all authentication and security is commented out

API: Users


**/deku/api/users POST**
API currently requires only: firstName, lastName, email, password, university
other possible json input variables: grad_year, major, classes[], bio
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X POST http://localhost:4568/deku/api/users -d 
'{"firstName":"fname","lastName":"lname","email":"email@email.edu","password":"password","university":"UMBC","grad_year":"2012","major":"cmsc","classes":["cmsc203","cmsc204","cmsc205"],"bio":"a biography"}'
{
  "user": {
    "bio": "a biography", 
    "cards": [], 
    "classes": [
      "cmsc203", 
      "cmsc204", 
      "cmsc205"
    ], 
    "email": "email@email.edu", 
    "firstName": "fname", 
    "grad_year": "2012", 
    "id": 1, 
    "lastName": "lname", 
    "major": "cmsc", 
    "role": 0, 
    "university": "UMBC"
  }
}

**/deku/api/users PUT**
API only requires id to be valid
any valid fields sent in will update
possible json input parameters: firstName, lastName, email, password, university, grad_year, major, classes[], bio
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT http://localhost:4568/deku/api/users/1 -d
'{"firstName":"fname","lastName":"lname","email":"email@email.edu","password":"password","university":"UMBC","grad_year":"2012","major":"cmsc","classes":["cmsc203","cmsc204","cmsc205"],"bio":"a biography"}'
{
  "user": {
    "bio": "a biography", 
    "cards": [], 
    "classes": [
      "cmsc203", 
      "cmsc204", 
      "cmsc205"
    ], 
    "email": "email@email.edu", 
    "firstName": "fname", 
    "grad_year": "2012", 
    "id": 1, 
    "lastName": "lname", 
    "major": "cmsc", 
    "role": 0, 
    "university": "UMBC"
  }
}



**/deku/api/users GET**
Returns the 20 newest users
no json input parameters
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X GET http://localhost:4568/deku/api/users
{
  "users": [
    {
      "bio": "a fbiography", 
      "cards": [], 
      "classes": [
        "cmsc204", 
        "cmsc205"
      ], 
      "email": "mail@emal.el", 
      "firstName": "first", 
      "grad_year": "2014", 
      "id": 3, 
      "lastName": "last", 
      "major": "cmscS", 
      "role": 0, 
      "university": "UMBCCC"
    }, 
    {
      "bio": "a fbiography", 
      "cards": [], 
      "classes": [
        "cmsc204", 
        "cmsc205"
      ], 
      "email": "email@emal.el", 
      "firstName": "first", 
      "grad_year": "2014", 
      "id": 2, 
      "lastName": "last", 
      "major": "cmscS", 
      "role": 0, 
      "university": "UMBCCC"
    }, 
    {
      "bio": "a fbiography", 
      "cards": [], 
      "classes": [
        "cmsc204", 
        "cmsc205"
      ], 
      "email": "email@email.email", 
      "firstName": "first", 
      "grad_year": "2014", 
      "id": 1, 
      "lastName": "last", 
      "major": "cmscS", 
      "role": 0, 
      "university": "UMBCCC"
    }
  ]
}



**/deku/api/users/<int:user_id> GET**
no json input parameters
curl -H 'Content-Type: application/json' -H 'Accept: application/json' -X GET http://localhost:4568/deku/api/users/2
{
  "user": {
    "bio": "a fbiography", 
    "cards": [], 
    "classes": [
      "cmsc204", 
      "cmsc205"
    ], 
    "email": "email@emal.el", 
    "firstName": "first", 
    "grad_year": "2014", 
    "id": 2, 
    "lastName": "last", 
    "major": "cmscS", 
    "role": 0, 
    "university": "UMBCCC"
  }
}

Clone this wiki locally