Skip to content

Latest commit

 

History

History
126 lines (71 loc) · 3.32 KB

README.md

File metadata and controls

126 lines (71 loc) · 3.32 KB

What's That Chord Doing API

General info

Our endpoints send and receive account- and scores-related data.

Endpoints accept and return JSON as request data. Authenticated endpoints want JSON Web Tokens, which our POST /accounts/register and POST /accounts/log-in endpoints return to us.

Request data types:

gameType is one of the following:

"easyMajor", "easyMajorInv", "easyMinor", "easyMinorInv", "intermediateMinor",
"intermediateMinorInv", "hardMajor", "hardMajorInv", "hardMinor", "hardMinorInv", 
"allChords", "allChordsInv"

score takes the form:

{
    "name": {String},
    "scores": {
        gameType: {
            "totalClicks": {Number},
            "nAnsweredRight": {Number},
            "nQuestionNumber": {Number},
            *"winRatio": {Number}
        }
    }
}
names are letters, numbers, and underscores
passwords are at least six characters in length

*We don't include winRatio in PUT requests; it's calculated by the server and returned by GET requests


Accounts endpoints

GET /accounts

Returns all the (non-password) data associated with an account. Data is of type score. Identical to GET /my-scores endpoint

Authenticated

success => score, 200 status

error => 404, 401, 500 status code

POST /accounts/log-in

Log in endpoint; (obviously) for existing accounts.

request body => { "name": {String}, "password": {String} }

success => JWT token, 201 status code

error => 404, 401, 500 status code

POST /accounts/register

Creates an account and returns the relevant JWT.

request body => { "name": {String}, "password": {String} }

success => JWT token, 200 success

error => 400, 409, 500 status code

PUT /accounts/change-password

Change an account password.

Authenticated

request body => { "name": {String}, "newPassword": {String} }

success => 204 status code

error => 400, 500 status code

DELETE /accounts

Deletes an account and associated data.

Authenticated

success => 200 status

error 404, 500 status


Scores endpoints

GET /my-scores

Returns all the (non-password) data associated with an account. Data is of type score. Identical to GET /accounts endpoint

Authenticated

success => score, 200 status

error => 404, 401, 500 status code

PUT /my-scores

Updates a specific gameType's scores'. Submit only one gameType, at once.

Authenticated

body => score, with updated data

success => 200 status code

error => 400, 304, 500 status code

GET /high-scores/:gameType

success => an array of scores of the given :gameType, ordered by win percentage.

error => 500 status

-DR, 2017