API version 1

GET /users

A list of all users - requires admin or researcher authorization.

Example request:

GET /users HTTP/1.1
Host: textscroll.cs.hmc.edu
Authorization: Credential=alsdkfjqeprt798sdhvzxkfnioq34ruaps98dfyaskjcan

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
    "users": [
        "user1",
        "user2",
        "user3"
    ]
}
Request Headers:
 
  • Authorization – encrypted token for authentication, or a username/password combo
Status Codes:
POST /users/create_user

Creates a new user user_id with the application, logs them in, and returns a token to be used for future authentication.

Example request:

POST /users/create_user
Host: textscroll.cs.hmc.edu
Content-Type: application/x-www-form-urlencoded

username=MyNewUserName&password=SuPeRH@x0rPa$$w()rD

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json
Location: https://textscroll.cs.hmc.edu/api/v1/users/MyNewUserName

token=alsdkfjqeprt798sdhvzxkfnioq34ruaps98dfyaskjcan
Status Codes:
GET /users/(string: user_id)

Gets information about user_id.

Example request:

GET /users/MyUserName
Host: textscroll.cs.hmc.edu

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
   "username": "MyUserName",
   "trials": [
      1,
      3,
      11
   ],
   "library": [
      "The Once and Future King",
      "A Brief History of Time"
   ],
   "settings": {
      "FontSize": "Large",
      "FontColor": "Black",
      "Theme": "Light"
   }
}
Status Codes:
POST /users/(string: user_id)/authenticate

Authenticates user_id.

Example request:

POST /users/MyUserName/authenticate
Host: textscroll.cs.hmc.edu
Authorization: Credential=SuPeRH@x0rPa$$w()rD

Example response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "authenticated": true
}
Request Headers:
 
  • Authorization – Authorization for the request in the form of the user’s password.
Status Codes:
POST /users/(string: user_id)/change_password

Changes user_id‘s password, invalidates all existing sessions, and returns a new valid session token.

Example request:

POST /users/MyUserName/change_password
Host: textscroll.cs.hmc.edu
Authorization: Credential=SuPeRH@x0rPa$$w()rD

new_password=XxXtr4SuPeRH@x0rPa$$w()rD

Example Response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

{
   "password_changed": true,
   "new_token": oqwe879fasokdljfqnl3o4fi7asicvqjwek
}
Request Headers:
 
  • Authorization – Authorization for the request - a token or password
Status Codes:
GET /users/(string: user_id)/trials

Returns a list of the trial-ids that user_id had participated in.

Requires administrator or researcher credentials.

Example Request:

GET /users/MyUserName/trials
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "trials": [
      1,
      3,
      11
   ],
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - must be an administrator or researcher credential
Status Codes:
GET /users/(string: user_id)/trials/(int: trial_id)

Returns the trial for user user_id and trial trial_id

Requires administrator or researcher credentials.

Example Request:

GET /users/MyUserName/trials/1
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   1: {
      "trial_data": "stuff",
      "other_data": "other_stuff"
   }
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - must be an administrator or researcher credential.
Status Codes:
GET /users/(string: user_id)/settings

Returns the settings for user_id.

Example Request:

GET /users/MyUserName/settings
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "settings": {
      "FontSize": "Large",
      "FontColor": "Black",
      "Theme": "Light"
   }
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /users/(string: user_id)/settings/(string: setting_id)

Returns the setting value of setting_id for user_id.

Example Request:

GET /users/MyUserName/settings/FontSize
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "FontSize": "Large"
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
POST /users/(string: user_id)/settings/(string: setting_id)

Sets the value of setting_id for user_id.

Example Request:

POST /users/MyUserName/settings/FontSize
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

FontSize=Small

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "FontSize": "Small"
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /users/(string: user_id)/library

Get user_id‘s text library.

Example Request:

GET /users/MyUserName/library
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "library": [
      "The Once and Future King",
      "A Brief History of Time"
   ]
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /users/(string: user_id)/library/(string: text_id)

Get the text associated with text_id from user_id‘s text library.

Example Request:

GET /users/MyUserName/library/The%20Once%20and%20Future%20King
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "bookmarks": [30, 80, 117],
   "title": "The Once and Future King",
   "pages": "lots",
   "last page read": 3,
   "preview": "...excerpt...",
   "contents": Object(compressed_contents)
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
POST /users/(string: user_id)/library/(string: text_id)

Add a text to user_id‘s library with text_id name.

Example Request:

POST /users/MyUserName/library/The%20Once%20and%20Future%20King
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

title=The%20Once%20and%20Future%20King&bookmarks=30,80,117

Example Response:

HTTP/1.1 201 Created
Content-Type: application/json
Location: https://textscroll.cs.hmc.edu/api/v1/users/MyUserName/library/The%20Once%20and%20Future%20King
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /users/(string: user_id)/library/(string: text_id)/(string: text_attr)

Get the attribute named by text_attr of the text text_id in user_id‘s library.

Example Request:

GET /users/MyUserName/library/The%20Once%20and%20Future%20King/title
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "title": "The Once and Future King"
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
POST /users/(string: user_id)/library/(string: text_id)/(string: text_attr)

Set the attribute named by text_attr of the text text_id in user_id‘s library.

Example Request:

POST /users/MyUserName/library/The%20Once%20and%20Future%20King/title
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

title=The%20once%20and%20Future%20King

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "original": "The Once and Future King",
   "updated": "The once and Future King"
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /trials

Get all trials that have been conducted, and the user who performed them.

Requires administrator or researcher credentials.

Example Request:

GET /trials
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   1: "MyUserName",
   2: "SomeOtherUserName",
   ...
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
GET /trials/(int: trial_id)

Get the trial with an id of trial_id.

Requires administrator or researcher credentials.

Example Request:

GET /trials/13
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

Example Response:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "trial_data": "stuff",
   "other_data": "other_stuff",
   "user_id": "MyUserName"
}
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes:
POST /trials/(int: trial_id)

Set the trial with an id of trial_id.

Requires administrator or researcher credentials.

Example Request:

POST /trials/13
Host: textscroll.cs.hmc.edu
Authorizaton: Credential=s0upersecrett0ken

trial_data=stuff&other_data=other_stuff&user_id=MyUserName

Example Response:

HTTP/1.1 201 Created
Content-Type: application/json
Location: https://textscroll.cs.hmc.edu/api/v1/trials/13
Request Headers:
 
  • Authorization – Authorizes the user for this request - can be a token or a password.
Status Codes: