Skip to main content

Users

Get a user

GET /api/v1/user/:username

Get publicly available information about a user

Depending on the user’s privacy settings, some user information may not be present.

Parameters

Path

username stringThe handle for the Trek user account

Response Codes

Status codeDescription
200OK
404Not found

Code samples for "Get a user"

GET /api/v1/user/:username
curl -L \
http://localhost:3000/api/v1/user/gregork

status: 200

{
"name": "Gregor Kiczales",
"username": "gregork",
"image": "http://localhost:3000/api/v1/user/gregork/picture"
}

Get a user's profile picture

GET /api/v1/user/:username/picture

Get the profile picture of the given username

Parameters

Max-Width numbermaximum width of the image to return (required?)
Max-Height numbermaximum height of the image to return (required?)

Path

username stringThe handle for the Trek user account

Response Codes

Status codeDescription
200OK
404Not found

Code samples for "Get a user's profile picture"

GET /api/v1/user/:username/picture
curl -L \
-H "Max-Width: 400" \
-H "Max-Height: 400" \
http://localhost:3000/api/v1/user/gregork/picture

Get the authenticated user

GET /api/v1/user

Get profile information about the currently authenticated user.

Parameters

Header

token stringThe user access token

Response Codes

Status codeDescription
200OK
401Unauthorized

Code samples for "Get the authenticated user"

GET /api/v1/user
curl -L \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user

status: 200

{
"userId": "ksjhfoi-i32aiufh-192oh"
"name": "Gregor Kiczales",
"username": "gregork",
"image": "http://localhost:3000/api/v1/user/gregork/picture",
"description": "Father of all CS students, king of the natural recursion, and the master of the AOP.",
"links": [
{
"type": "twitter",
"url": "https://twitter.com/gregork"
},
{
"type": "site",
"url": "https://cs.ubc.ca/~gregor"
}
],
"interests": ["Island", "Ocean", "Hiking", "Nature", "Recursion"]
}

Get authenticated user settings

GET /api/v1/user/settings

Get all the settings for the currently authenticated user

Parameters

Header

token stringThe user access token

Response Codes

Status codeDescription
200OK
401Unauthorized

Code samples for "Get authenticated user settings"

GET /api/v1/user/settings
curl -L \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user/settings

status: 200

{
"accountLimitedDeals": "false",
"accountNewsletterNotifications": "false",
}

Get authenticated user's experience settings

GET /api/v1/user/experience

Get all the experience settings for the currently authenticated user

Parameters

Header

token stringThe user access token

Response Codes

Status codeDescription
200OK
401Unauthorized

Code samples for "Get authenticated user settings"

GET /api/v1/user/settings
curl -L \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user/settings

status: 200

{
"accountLimitedDeals": "false",
"accountNewsletterNotifications": "false",
}

Create a new user

POST /api/v1/user

Creates a new user

Parameters

Body

name stringThe new user's name
username stringThe new user's username

Response Codes

Status codeDescription
200OK
403Forbidden (Username taken)

Code samples for "Create a new user"

POST /api/v1/user
curl -L \
-X POST \
http://localhost:3000/api/v1/user/gregork/settings \
-d '{"name": "Ron Garcia", "username": "rxg"}'

status: 200

{
"userId": "a87sdhf-9h3iuhfsd-i923hie"
"name": "Ron Garcia",
"username": "rxg",
"image": "http://localhost:3000/api/v1/user/default/picture",
"description": "",
"links": [],
"interests": []
}

Update a user's settings

PUT /api/v1/user/:username/settings

Update the settings of a user with specified username

Parameters

Header

token stringThe user access token

Path

username stringThe handle of the Trek user

Body

accountLimitedDeals booleanEmail for limited deals toggle
accountNewsletterNotifications booleanEmail for newsletter toggle

Response Codes

Status codeDescription
200OK
304Not modified
401Unauthorized
404Not found

Code samples for "Update a user's settings"

PUT /api/v1/user/:username/settings
curl -L \
-X PUT \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user/gregork/settings \
-d '{"accountLimitedDeals": "true"}'

status: 200

{
"accountLimitedDeals": "true",
"accountNewsletterNotifications": "false",
}

Edit a user's profile

PUT /api/v1/user/:username

Edits a user's profile information

Parameters

Header

token stringThe user access token

Path

username stringThe handle of the Trek user

Body

name stringThe new name of the user
username stringThe new handle of the Trek user
image stringThe new URL of the profile picture
description stringThe new description of the Trek user
links Array<{type: string, url: string}>The new links of the Trek user
interests Array<string>The new interests of the Trek user

Response Codes

Status codeDescription
200OK
304Not modified
401Unauthorized
404Not found

Code samples for "Edit a user's profile"

PUT /api/v1/user/:username
curl -L \
-X PUT
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user/:username \
-d '{"description":"Professor at the University of British Columbia. Father of all CS students, king of the natural recursion, and the master of the AOP."}'

status: 200

{
"userId": "ksjhfoi-i32aiufh-192oh"
"name": "Gregor Kiczales",
"username": "gregork",
"image": "http://localhost:3000/api/v1/user/gregork/picture",
"description": "Professor at the University of British Columbia. Father of all CS students, king of the natural recursion, and the master of the AOP.",
"links": [
{
"type": "twitter",
"url": "https://twitter.com/gregork"
},
{
"type": "site",
"url": "https://cs.ubc.ca/~gregor"
}
],
"interests": ["Island", "Ocean", "Hiking", "Nature", "Recursion"]
}

Delete a user

DELETE /api/v1/user/:username

Deletes the user with the specified username

Parameters

Header

token stringThe user access token

Path

username stringThe handle of the Trek user

Response Codes

Status codeDescription
204No Content
401Unauthorized
404Not found

Code samples for "Delete a user"

DELETE /api/v1/user/:username
curl -L \
-X DELETE
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/user/:username
  • No response body