REST API Document - UoaWDCC/Stick-Insect GitHub Wiki

REST API Documentation

  • This documentation specifies what the REST API end points.
  • Frontend will make requests to these end points to receive necessary responses.
  • Server will provide middlewares to handle requests and send responses for these endpoints.

Data Structure

The frontend will follow these data structures when communicating with the server

Game

Data format for "game"

{
    rounds, [round]
    isFirstAttempt, (Boolean)
}

Round

Data format for "round"

{
    roundNum, (Number)
    backgroundId, (String)
    timeTaken, (Number)
    isFound, (Boolean)
}

Email

Data format for "email"

{
    email, (String)
}

End Points

Game Data

Send game result to the server

Method Endpoint
POST /game

REQUEST BODY

{
    game,
}

REQUEST BODY EXAMPLE

{
    rounds: [round, round, ...],
    isFirstAttempt: true,
}

RESPONSE (If successful)

201

Email (Subscription)

Save user email so that the user can be notified the outcome of the research

Method Endpoint
POST /email

REQUEST BODY

{
    email,
}

REQUEST BODY EXAMPLE

{
    email: "[email protected]",
}

RESPONSE (If successful)

201