-
Notifications
You must be signed in to change notification settings - Fork 9
API Specification
Joe Bandenburg edited this page Jul 2, 2015
·
4 revisions
GET /users
- Gets the list of users as a JSON array.
- Example response body:
[{ id: 'bob', name: 'Bobby McBobberson'}, ...]
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
sentfield that is the unix timestamp of when the message was sent. - A
bodyfield containing a string of the message to be sent.
- A
- Example request body:
{ sent: 123445, body: 'Hello!' }
GET /conversations/bob
- Gets the messages in conversation with
bob. This includes both the messages sent byboband tobob. - 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' }, ...]
PUT /groups/stag-do
- Creates a new group or updates an existing one.
- Body is a JSON object containing:
- A
titlefield containing a string of the title of the group.
- A
- 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.
PUT /groups/stag-do/users/bob
- Adds user
bobto thestag-dogroup. - Returns 201 if
bobwas successfully added to the group. - Returns 200 if
bobwas 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
bobfrom thestag-dogroup. - Returns 404 if the group doesn't exist.