This API provides access to sample data for the TRIBE app. Tribe is an communal living management app intended for a group of housemates to keep track of bulletins, bills, and chores.
POST Authentication
- Issues the user a JWT according to the authorization level.
- User will need to submit email and application name in order to be issued a JWT.
- Only users with a valid email ending in @turing.io will be granted "Admin" privileges to be able to POST, PUT, PATCH, DELETE.
- At the root page of the application, there is a form you can submit for a JWT.
fetch('/api/v1/houses', {
method: 'POST',
body: JSON.stringify({
appName: 'Lola',
email: 'lola@turing.io',
admin: true
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
});
Get Houses
- Returns an array of all House records.
fetch('./api/v1/houses');
[
{
"id": 17,
"name": "DogHouse",
"secretKey": "oiuhasrfou",
"created_at": "2017-12-14T04:23:29.966Z",
"updated_at": "2017-12-14T04:23:29.966Z"
},
{
"id": 18,
"name": "CatHouse",
"secretKey": "234tewrf",
"created_at": "2017-12-14T04:23:29.966Z",
"updated_at": "2017-12-14T04:23:29.966Z"
},
{
"id": 19,
"name": "BirdHouse",
"secretKey": "098ht4t",
"created_at": "2017-12-14T04:23:29.966Z",
"updated_at": "2017-12-14T04:23:29.966Z"
}
]
GET users
- Returns an array of all user records.
fetch('./api/v1/users')
[
{
"name": "Lola",
"houseId": "1"
},
{
"name": "Nik",
"houseId": "1"
},
{
"name": "Rufus",
"houseId": "1"
}
]
GET users:id
- Returns a specific user.
fetch('./api/v1/users/:id')
{
name: 'Lola',
houseId: 1
}
GET users:houseId
- Returns an array of users belonging to a specific house.
fetch('./api/v1/houses/:id/users')
[
{
"name": "Lola",
"houseId": "1"
},
{
"name": "Nik", "houseId": "1"
},
{
"name": "Rufus", "houseId": "1"
},
{
"name": "Adam",
"houseId": "1"
},
{
"name": "Alex",
"houseId": "1"
}
]
GET bills:houseId
- Returns an array of all bills records for a specific house.
fetch('./api/v1/houses/:houseId/bills')
[
{
name: 'electricity',
total: '101.23',
dueDate: '12/31/17',
houseId: 1
},
{
name: 'water',
total: '99.67',
dueDate: '12/30/17',
houseId: 2
},
{
name: 'trash',
total: '99.67',
dueDate: '12/30/17',
houseId: 3
}
]
GET chores:houseId
- Returns an array of all chores records for a specific house.
fetch('./api/v1/houses/:houseId/chores')
[
{
"name": "sweep the front deck",
"details": "get this done today!",
"userId": "1",
"houseId": "1"
},
{
"name": "sweep the back deck",
"details": "get this done tomorrow!",
"userId": "2",
"houseId": "2"
},
{
"name": "sweep the stairs",
"details": "get this done now!æ,
"userId": "3",
"houseId": "3"
},
]
Get bills:houseId
- Returns an array of bulletins records for a specific house.
fetch('./api/v1/houses/:houseId/bulletins')
[
{
"title": "May Bulletin",
"body": "May news",
"houseId": "1"
},
{
"title": "June Bulletin",
"body": "June news",
"houseId": "1"
},
]
POST houses
- Adds a house record to the houses table in the database.
- You must include your token in the body, as well as a name and secretKey property.
fetch('./api/v1/houses', {
method: 'POST',
body: JSON.stringify({
name: 'My House',
secretKey: 'password'
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
{
id: 45
}
POST users
- Adds a new user record to the users table in the database.
- You must include your token in the body, as well as a name property.
fetch('./api/v1/houses/:houseId/users', {
method: 'POST',
body: JSON.stringify({
name: 'Name',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
{
id: 46
}
POST bills
- Adds a bill record to the bills table in the database.
- You must include your token in the body, as well as a name, total, and dueDate property.
fetch('./api/v1/houses/:houseId/bills', {
method: 'POST',
body: JSON.stringify({
name: 'electric',
total: '100',
dueDate: '12/12/17',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
{
id: 201
}
POST chores
- Adds a chore record to the chores table in the database.
- You must include your token in the body, as well as a name, and details property.
fetch('./api/v1/houses/:houseId/chores', {
method: 'POST',
body: JSON.stringify({
name: 'sweep',
details: 'the kitchen',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
{
id: 9
}
POST bulletins
- Adds a new bulletin record to the bulletins table in the database.
- You must include your token in the body, as well as a body and title property.
fetch('./api/v1/houses/:houseId/bulletins', {
method: 'POST',
body: JSON.stringify({
title: 'News',
body: 'more news',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
{
id: 204
}
PATCH houses
- Updates a house record on the houses table in the database.
- You must include your token in the body, as well as any property you wish to change.
fetch('./api/v1/houses/:id', {
method: 'PATCH',
body: JSON.stringify({
name: 'My House',
secretKey: 'password'
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
returns status 204
PATCH users
- Updates a user record on the users table in the database.
- You must include your token in the body, as well as any property you wish to change.
fetch('./api/v1/users/:id', {
method: 'PATCH',
body: JSON.stringify({
name: 'Name',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
returns status 204
PATCH bills
- Updates a bill record on the bills table in the database.
- You must include your token in the body, as well as any property you wish to change.
fetch('./api/v1/houses/:houseId/bills/:id', {
method: 'PATCH',
body: JSON.stringify({
name: 'electric',
total: '100',
dueDate: '12/12/17',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204
PATCH chores
- Updates a chore record on the chores table in the database.
- You must include your token in the body, as well as any property you wish to change.
fetch('./api/v1/houses/:houseId/chores/:id', {
method: 'PATCH',
body: JSON.stringify({
name: 'sweep',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204
PATCH bulletins
- Updates a bulletin record on the bulletins table in the database.
- You must include your token in the body, as well as any property you wish to change.
fetch('./api/v1/houses/:houseId/bulletins/:id', {
method: 'PATCH',
body: JSON.stringify({
title: 'News',
body: 'more news',
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204
DELETE bills
- Removes a bill record from the bills table in the database.
- You must include your token in the body.
fetch('./api/v1/houses/:houseId/bills/:id', {
method: 'DELETE',
body: JSON.stringify({
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204
DELTE chores
- Removes a chore record from the chores table in the database.
- You must include your token in the body.
fetch('./api/v1/houses/:houseId/chores/:id', {
method: 'DELETE',
body: JSON.stringify({
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204
DELTE bulletins
- Removes a bulletin record from the bulletins table in the database.
- You must include your token in the body.
fetch('./api/v1/houses/:houseId/bulletins/:id', {
method: 'DELETE',
body: JSON.stringify({
token: 'yourTokenHere'
}),
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
});
returns status 204