Skip to main content
Manage the relationship between users and their interests in MayTravel. Users can have multiple interests that help personalize their travel experience.

Get User Interests

Retrieve all interests associated with a specific user.

Request

id
integer
required
The unique identifier of the user
curl --location 'https://api.maytravel.com/users/1/interests' \
  --header 'Content-Type: application/json'

Response

Returns a structured object with user information and their interests.
user_id
integer
The user’s unique identifier
username
string
The user’s username
email
string
The user’s email address
interests
array
Array of interest objects associated with the user
{
  "user_id": 1,
  "username": "johndoe",
  "email": "johndoe@example.com",
  "interests": [
    {
      "interest_id": 5,
      "interest_name": "Beach"
    },
    {
      "interest_id": 12,
      "interest_name": "History"
    },
    {
      "interest_id": 8,
      "interest_name": "Adventure"
    }
  ]
}

Add User Interests

Attach one or more interests to a user.

Request

id
integer
required
The unique identifier of the user
interests_id
array
required
Array of interest IDs to attach to the user
curl --location 'https://api.maytravel.com/users/1/interests' \
  --header 'Content-Type: application/json' \
  --data '{
    "interests_id": [5, 12, 8]
  }'

Response

message
string
Success message confirming interests were attached
{
  "message": "interests attached to the user correctly"
}

Error Responses

error
string
Error message describing what went wrong

Status Codes

  • 200 - Success: Operation completed successfully
  • 500 - Server Error: Internal server error occurred

Notes

  • When no interests are found for a user, an empty array is returned
  • The interests_id array can contain multiple interest IDs to attach in a single request
  • Ensure the interest IDs exist in the interests table before attempting to attach them
  • This endpoint can be used to display user profiles with their preferences

Build docs developers (and LLMs) love