API for accessing information about a user
- Get a user profile
- Get a user's transit bookmarks
- Add a transit bookmark for a user
- Delete a transit bookmark for a user
Usage notes:
The :username
parameter can either be self
, or the user's SFU Computing ID (e.g. kipling
).
Retrieve a user's profile.
Returns a user object.
curl https://snap.sfu.ca/api/v1/users/self \
-X GET \
-H 'Authorization: Bearer <...JWT...>'
{
"id": 12345,
"username": "kipling",
"uid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"lastname": "Kipling",
"firstnames": "Joseph Rudyard",
"commonname": "Rudy",
"barcode": "1234567890"
}
Retrieve the saved transit bookmarks for a user.
Returns an array of transit bookmark objects.
curl https://snap.sfu.ca/api/v1/users/self/transitBookmarks \
-X GET \
-H 'Authorization: Bearer <...JWT...>'
[
{
"stop": "50490",
"route": "209",
"destination": "VANCOUVER"
},
{
"stop": "50490",
"route": "004",
"destination": "UBC"
}
]
Add a transit bookmark for a user and return the new list of all bookmarks.
The new bookmark will be merged with the user's existing bookmarks. The array of bookmarks is unique'd when saving; no duplicate bookmarks will be saved.
The JSON payload must conform to the following schema:
{
type: 'object',
properties: {
stop: {
type: 'string',
required: true,
minLength: 5,
maxLength: 5
},
route: {
type: 'string',
required: true
},
destination: {
type: 'string',
required: true
}
}
}
curl https://snap.sfu.ca/api/v1/users/self/transitBookmarks \
-X POST \
-H 'Authorization: Bearer <...JWT...>' \
-d '{"stop":"51861","route":"145","destination":"PRODUCTION STN"}'
[
{
"stop": "50490",
"route": "209",
"destination": "VANCOUVER"
},
{
"stop": "50490",
"route": "004",
"destination": "UBC"
},
{
"stop": "51861",
"route": "145",
"destination": "PRODUCTION STN"
}
]
Delete a transit bookmark for a user and return the new list of all bookmarks.
Bookmark objects that are not present in the user's bookmarks are ignored; no error is thrown.
The JSON payload must conform to the following schema:
{
type: 'object',
properties: {
stop: {
type: 'string',
required: true,
minLength: 5,
maxLength: 5
},
route: {
type: 'string',
required: true
},
destination: {
type: 'string',
required: true
}
}
}
curl https://snap.sfu.ca/api/v1/users/self/transitBookmarks \
-X DELETE \
-H 'Authorization: Bearer <...JWT...>' \
-d '{"stop":"51861","route":"145","destination":"PRODUCTION STN"}'
[
{
"stop": "50490",
"route": "209",
"destination": "VANCOUVER"
},
{
"stop": "50490",
"route": "004",
"destination": "UBC"
}
]