Skip to main content

Users

Get a user by Auth0 subtoken

GET /api/v1/users/:subtoken

Get publicly available information about a user using their subtoken

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

Parameters

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Response Codes

Status codeDescription
200OK
404Not found

Code samples for "Get a user by Auth0 subtoken"

GET /api/v1/users/:subtoken
curl -L \
http://localhost:3000/api/v1/users/auth0|abcdefg123456

status: 200

{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456",
"name": "Gregor Kiczales",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg",
"email": "gregork@example.com",
"trips": ["389c6c16-1094-4901-a062-ab71e14398e5", "389c6c16-1094-4901-a062-ab71e14398e0"]
}

Get a user by username

GET /api/v1/users/username/: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/users/:username
curl -L \
http://localhost:3000/api/v1/users/username/gregork

status: 200

{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456",
"name": "Gregor Kiczales",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg",
"email": "gregork@example.com",
"trips": ["389c6c16-1094-4901-a062-ab71e14398e5", "389c6c16-1094-4901-a062-ab71e14398e0"]
}

Get a user's profile picture

GET /api/v1/users/:subtoken/picture

Get the profile picture of the given username

Parameters

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Response Codes

Status codeDescription
200OK
404Not found

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

GET /api/v1/users/:subtoken/picture
curl -L \
http://localhost:3000/api/v1/users/auth0|abcdefg123456/picture
{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456"
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg"
}

Get the authenticated user

GET /api/v1/users

Get profile information about the currently authenticated user.

Parameters

Header

token stringThe user access token

Response Codes

Status codeDescription
200OK
401Unauthorized
404Not found

Code samples for "Get the authenticated user"

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

status: 200

{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456",
"name": "Gregor Kiczales",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg",
"email": "gregork@example.com",
"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"],
"home": "Vancouver, BC",
"currentlyAt": "UBC",
"settings": {
"accountLimitedDeals": true,
"accountNewsletterNotifications": false,
"privateAccount": true
},
"experience": {
"accommodationBudget": {
"lo": 0,
"hi": 1000
},
"activities": [],
"activitiesBudget": {
"lo":0,
"hi": 1000
},
"ageRange": 20,
"climateAndWeather": [],
"connectivityNeeds": "No connectivity needed",
"culture": [],
"dining": [],
"diningBudget": {
"lo": 0,
"hi": 1000
},
"healthAndAccessibility": "",
"language": "Comfortable with different language",
"occupation": "Employed",
"passports": [],
"safety": "",
"tosAgreement": false,
"transportPreferences": [],
"travelFrequency": "2-4 times a year",
"travelStyle": [],
"tripDuration": "",
"visas": []
},
"trips": ["389c6c16-1094-4901-a062-ab71e14398e5", "389c6c16-1094-4901-a062-ab71e14398e0"]
}

Get authenticated user's settings

GET /api/v1/users/settings

Get all the settings for the currently authenticated user

Parameters

Header

token stringThe user access token

Response Codes

Status codeDescription
200OK
401Unauthorized
404Not found

Code samples for "Get authenticated user settings"

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

status: 200

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

Create a new user with Auth0

POST /api/v1/users/fetch-user

Creates a new user

Parameters

Header

token stringThe user access token

Body

sub stringThe new user's Auth0 subtoken
name stringThe new user's display name
email stringThe new user's Auth0 login email
image stringThe link to the user's default Auth0-provided profile picture

Response Codes

Status codeDescription
200OK
400Bad request
401Unauthorized

Code samples for "Create a new user"

POST /api/v1/users/fetch-user
curl -L \
-X POST \
http://localhost:3000/api/v1/users/fetch-user \
-d '{"sub": "auth0|abcdefg123456", "name": "Gregor",
"email": "gregork@example.com", "image": "https://s.gravatar.com/avatar/gregork_picture"}'

status: 200

{
"_id": "a87sdhf-9h3iuhfsd-i923hie"
"sub": "auth0|abcdefg123456",
"name": "Gregor",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"email": "gregork@example.com"
"settings": {
"accountLimitedDeals": true,
"accountNewsletterNotifications": true,
"privateAccount": false
},
"experience": {
"accommodationBudget": {
"lo": 0,
"hi": 1000
},
"activities": [],
"activitiesBudget": {
"lo": 0,
"hi": 1000
},
"ageRange": 18,
"climateAndWeather": [],
"connectivityNeeds": "",
"culture": [],
"dining": [],
"diningBudget": {
"lo": 0,
"hi": 1000
},
"healthAndAccessibility": "",
"language": "",
"occupation": "",
"passports": [],
"safety": "",
"tosAgreement": false,
"transportPreferences": [],
"travelFrequency": "",
"travelStyle": [],
"tripDuration": "",
"visas": []
},
"trips": []
}

Update a user's settings

PUT /api/v1/users/:subtoken/settings

Update the settings of a user with specified username

Parameters

Header

token stringThe user access token

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Body

accountLimitedDeals booleanEmail for limited deals toggle
accountNewsletterNotifications booleanEmail for newsletter toggle
privateAccount booleanSetting for whether the account is private or not

Response Codes

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

Code samples for "Update a user's settings"

PUT /api/v1/users/:subtoken/settings
curl -L \
-X PUT \
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/users/auth0|abcdefg123456/settings \
-d '{"accountLimitedDeals": true}'

status: 200

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

Edit a user's experience data for the chatbot

PUT /api/v1/users/:subtoken/experience

Edits a user's profile information

Parameters

Header

token stringThe user access token

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Body

accommodationBudget {lo: number, hi: number}The budget range the user has for their accomodation
activities Array<string>The activities the user enjoys
activitiesBudget {lo: number, hi: number}The budget range the user has for activities
ageRange numberThe approximate age of the user
climateAndWeather Array<string>The climate preferences of the user
connectivityNeeds string (enum)The connectivity needs of the user
culture Array<string>The cultural preferences of the user
dining Array<string>The dining preferences of the user
diningBudget {lo: number, hi: number}The budget range the user has for their dining options
healthAndAccessibility stringThe user's health and accessibility needs
language string (enum)The user's language preferences
occupation string (enum)The user's employment status
passports Array<string>The passports the user has
safety stringThe user's safety preferences
tosAgreement booleanIf the user consents to the use of their information in the chatbot
transportPreferences Array<string>The user's preferences in terms of transportation methods
travelFrequency string (enum)The user's travel frequency
travelStyle Array<string>The user's preferred travel style
tripDuration stringThe user's preferred trip duration
visas Array<string>The visas the user has access to

Response Codes

Status codeDescription
200OK
400Bad request
401Unauthorized
404Not found

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

PUT /api/v1/users/:subtoken/picture
curl -L \
-X PUT
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/users/auth0|abcdefg123456/experience \
-d '{"language": "Prefer English-speaking countries" }'

status: 200

{
"accommodationBudget": {
"lo": 0,
"hi": 1000
},
"activities": [],
"activitiesBudget": {
"lo": 0,
"hi": 1000
},
"ageRange": 18,
"climateAndWeather": [],
"connectivityNeeds": "",
"culture": [],
"dining": [],
"diningBudget": {
"lo": 0,
"hi": 1000
},
"healthAndAccessibility": "",
"language": "",
"occupation": "",
"passports": [],
"safety": "",
"tosAgreement": false,
"transportPreferences": [],
"travelFrequency": "",
"travelStyle": [],
"tripDuration": "",
"visas": []
}

Edit a user's user-uploaded profile picture

PUT /api/v1/users/:subtoken/picture

Edits a user's profile picture

Parameters

Header

token stringThe user access token

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Body

accommodationBudgetThe image file corresponding to the new profile picture

Response Codes

Status codeDescription
200OK
400Bad request
401Unauthorized
404Not found

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

PUT /api/v1/users/:subtoken/picture
curl -L \
-X PUT
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/users/auth0|abcdefg123456 \
-d '{"uploadedProfilePicture": ... }'

status: 200

{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456",
"name": "Gregor Kiczales",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg",
"email": "gregork@example.com",
"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"],
"home": "Vancouver, BC",
"currentlyAt": "UBC",
"settings": {
"accountLimitedDeals": true,
"accountNewsletterNotifications": false,
"privateAccount": true
},
"experience": {
"accommodationBudget": {
"lo": 0,
"hi": 1000
},
"activities": [],
"activitiesBudget": {
"lo":0,
"hi": 1000
},
"ageRange": 20,
"climateAndWeather": [],
"connectivityNeeds": "No connectivity needed",
"culture": [],
"dining": [],
"diningBudget": {
"lo": 0,
"hi": 1000
},
"healthAndAccessibility": "",
"language": "Comfortable with different language",
"occupation": "Employed",
"passports": [],
"safety": "",
"tosAgreement": false,
"transportPreferences": [],
"travelFrequency": "2-4 times a year",
"travelStyle": [],
"tripDuration": "",
"visas": []
},
"trips": ["389c6c16-1094-4901-a062-ab71e14398e5", "389c6c16-1094-4901-a062-ab71e14398e0"]
}

Edit a user's profile

PUT /api/v1/users/:subtoken

Edits a user's profile information

Parameters

Header

token stringThe user access token

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Body

name stringThe new name of the user
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
home stringThe user's area of residence
currentlyAt stringThe user's approximate current location
trips Array<ObjectID>The list of trips the user is an owner of

Response Codes

Status codeDescription
200OK
400Bad request
401Unauthorized
404Not found

Code samples for "Edit a user's profile"

PUT /api/v1/users/:subtoken
curl -L \
-X PUT
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/users/auth0|abcdefg123456 \
-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

{
"_id": "1234567asdfghjkl",
"sub": "auth0|abcdefg123456",
"name": "Gregor Kiczales",
"username": "gregork",
"image": "https://s.gravatar.com/avatar/gregork_picture",
"uploadedProfilePicture": "abcdefghijk",
"uploadedProfilePictureURL": "https://cpsc-455-trek-users.s3.us-east-2.amazonaws.com/12345678900.jpeg",
"email": "gregork@example.com",
"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"],
"home": "Vancouver, BC",
"currentlyAt": "UBC",
"settings": {
"accountLimitedDeals": true,
"accountNewsletterNotifications": false,
"privateAccount": true
},
"experience": {
"accommodationBudget": {
"lo": 0,
"hi": 1000
},
"activities": [],
"activitiesBudget": {
"lo":0,
"hi": 1000
},
"ageRange": 20,
"climateAndWeather": [],
"connectivityNeeds": "No connectivity needed",
"culture": [],
"dining": [],
"diningBudget": {
"lo": 0,
"hi": 1000
},
"healthAndAccessibility": "",
"language": "Comfortable with different language",
"occupation": "Employed",
"passports": [],
"safety": "",
"tosAgreement": false,
"transportPreferences": [],
"travelFrequency": "2-4 times a year",
"travelStyle": [],
"tripDuration": "",
"visas": []
},
"trips": ["389c6c16-1094-4901-a062-ab71e14398e5", "389c6c16-1094-4901-a062-ab71e14398e0"]
}

Delete a user

DELETE /api/v1/users/:subtoken

Deletes the user with the specified username

Parameters

Header

token stringThe user access token

Path

subtoken stringThe Auth0 subtoken associated with the given Trek user account

Response Codes

Status codeDescription
204No Content
401Unauthorized
404Not found

Code samples for "Delete a user"

DELETE /api/v1/users/:subtoken
curl -L \
-X DELETE
-H "Authorization: Bearer <YOUR-TOKEN>" \
http://localhost:3000/api/v1/users/auth0|abcdefg123456
  • No response body