Skip to content

API Specification

Joe Bandenburg edited this page Jul 2, 2015 · 4 revisions

Users

GET /users

  • Gets the list of users as a JSON array.
  • Example response body: [{ id: 'bob', name: 'Bobby McBobberson'}, ...]

Conversations

GET /conversations

  • Gets the list of conversations for the authenticated user as a JSON array.
  • Example response body: [{ user: 'bob', lastMessage: 123454656, anyUnseen: true }, ...]

POST /conversations/bob

  • Sends a message to the user bob.
  • Body is a JSON object containing:
    • A sent field that is the unix timestamp of when the message was sent.
    • A body field containing a string of the message to be sent.
  • Example request body: { sent: 123445, body: 'Hello!' }

GET /conversations/bob

  • Gets the messages in conversation with bob. This includes both the messages sent by bob and to bob.
  • The messages are ordered in reverse chronological order. i.e. the most recent message is the first message in the array.
  • Returns 404 if there is no existing conversation with bob.
  • Example response body: [{ sent: 123456, body: 'Hello!', seen: true, from: 'bob' }, ...]

Groups

PUT /groups/stag-do

  • Creates a new group or updates an existing one.
  • Body is a JSON object containing:
    • A title field containing a string of the title of the group.
  • Example request body: { title: '#yolo' }
  • Returns 201 if a new group was created.
  • Returns 200 if an existing group was updated.

GET /groups

  • Gets the list of groups for the authenticated user as a JSON array.
  • Example response body: [{ id: 'stag-do', title: '#yolo' }, ...]

GET /groups/stag-do

  • Gets details of a group as a JSON object.
  • Returns 404 if the group doesn't exist.
  • Example response body: { id: 'stag-do', title: '#yolo' }

DELETE /groups/stag-do

  • Removes a group
  • Returns 404 if the group doesn't exist.

Group users

PUT /groups/stag-do/users/bob

  • Adds user bob to the stag-do group.
  • Returns 201 if bob was successfully added to the group.
  • Returns 200 if bob was already in the group.
  • Returns 404 if the group doesn't exist.

GET /groups/stag-do/users

  • Gets the users in the group
  • Returns 404 if the group doesn't exist.
  • Example response body: ['bob', ...]

DELETE /groups/stag-do/users/bob

  • Removes user bob from the stag-do group.
  • Returns 404 if the group doesn't exist.

Clone this wiki locally