Skip to content

Users API

Andrew Maclean edited this page Jun 23, 2024 · 3 revisions

This section describes the actions you can take on users with the Sunday Peak api.

Login a User

To login a user, you can pass an email and password to the login API endpoint. This will return a user object and an auth token that you can use in your session to complete further requests.

The login API doesn't require an auth token because it is a token-generating-request. Information about the user such as password hashes are hidden, since this isn't needed or usefull information.

Login endpoint

https://api.sundaypeak.com/users/login

Content-Type: "application/json"
HTTP Method: POST

Request Body:

{
    email: String,
    password: String,
    native: Boolean
}
Key Type Description
email String formatted with an @ separating an indentifier and a domain
password String Note: This request is secured with a TLS certificate so any data passed over https will be encrypted
native Boolean telling the backend whether this login is happening on a native app or a webapp

Response

{
    data: {
        user: User,
        token: String
    },
    status_code: Int,
    timestamp: Int
}

The user object is described below
token is a jwt used to identify the session as unique

Error Response:

{
    error: {
        message: String,
        handled: Boolean,
        request_body: Object,
        code_error: String | Object
    },
    status_code: Int
}
Key Type Description
message String The text sent back describing what went wrong
handled Boolean Describes whether the error was described and caught before the final return or not
request_body RequestBody
code_error Object gives the iternal description of the error if it was handled. Can give more context to the error
status_code Int The code of the returned error

Object Breakdowns

User

The User object contains all the relevant data about a given user. When a login, signup, or getOtherUser call is made, the User object is returned as part of the response object

user: {
    first_name: String
    last_name: String
    email: String
    bio: String
    city: String
    id: Number
    phone: String
    user_site: String
    profile_picture_url: String
    email_opt_out: Boolean
    friends: Friend[]
    images: String[]
    completed_adventures: CompletedAdventure[]
    todo_adventures: TodoAdventure[]
}
Key Type Description
first_name String
last_name String
email String
bio String
city String
id Int
phone String
user_site String A url string depecting any website the user wishes to post in conjunction with their profile
profile_picture_url String A url string pointing to the Sunday Peak CDN
email_opt_out Boolean Describing whether the user has opted out of marketing emails
friends Friend[]
images String[]
completed_adventures Completed Adventure[]
todo_adventures Todo Adventure[]

Friend

The friend object is a modified subset of the User object.

friend: {
    user_id: Number
    display_name: String
    first_name: String
    profile_picture_url: String
    email: String
    email_opt_out: Boolean
}
Key Type Description
user_id Int Referencing the id of the friend user
display_name String A user's first and last name concatenated into one string
first_name String Just the user's first name for when a shorter name field is required
profile_picture_url String A url string pointing to the Sunday Peak CDN
email String
email_opt_out Boolean Describing whether the user has opted out of marketing emails

Completed Adventure

The completed adventure is a modified subset of the Adventure object.

completed_adventure: {
    adventure_name: String
    adventure_type: String
    nearest_city: String
    adventure_id: Number
}
Key Type Description
adventure_name String
adventure_type AdventureType
nearest_city String Formatted as "city, state"
adventure_id Int

Todo Adventure

The todo adventure is a modified subset of the Adventure object.

todo_adventure: {
    adventure_name: String
    adventure_type: String
    nearest_city: String
    adventure_id: Number
}
Key Type Description
adventure_name String
adventure_type AdventureType
nearest_city String Formatted as "city, state"
adventure_id Int

Request Body

The body sent with the request. Usually delivered as a proerty of an error response. This will include all the properties sent. If the request was altered in sanitization when it reached the server, this will include the sanitized body.

Clone this wiki locally