Skip to main content

Register Visited POI

Record that a user has visited a specific Point of Interest (POI).

Authentication

Requires JWT authentication. Users can track their own visits, or admins can track any user’s visits.
Authorization: Bearer <jwt_token>

Path Parameters

user_id
string
required
The user’s unique identifier (MongoDB ObjectId)

Query Parameters

poi_id
string
required
The POI identifier to mark as visited

Response

message
string
Success confirmation message
{
  "message": "POI registrado como visitado"
}

Code Examples

curl -X POST "https://api.tesisrutas.com/usuarios/507f1f77bcf86cd799439011/visitados?poi_id=507f191e810c19729de860ea" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Error Responses

403
error
Forbidden - User attempting to track another user’s visits
{
  "detail": "No autorizado"
}
400
error
Bad Request - Failed to register visit
{
  "detail": "No se pudo registrar el POI visitado."
}

Register Completed Route

Record that a user has completed a tourism route.

Authentication

Requires JWT authentication. Users can track their own routes, or admins can track any user’s routes.
Authorization: Bearer <jwt_token>

Path Parameters

user_id
string
required
The user’s unique identifier (MongoDB ObjectId)

Body Parameters

The request body should contain route completion data as a JSON object.
ruta_id
string
required
The unique identifier of the completed route
fecha
string
Completion date in ISO 8601 format (e.g., “2024-03-15T10:30:00Z”)
duracion
number
Time taken to complete the route in minutes
calificacion
number
User rating of the route (e.g., 1-5 stars)

Request Example

{
  "ruta_id": "507f191e810c19729de860ec",
  "fecha": "2024-03-15T10:30:00Z",
  "duracion": 120,
  "calificacion": 5
}

Response

message
string
Success confirmation message
{
  "message": "Ruta registrada correctamente"
}

Code Examples

curl -X POST "https://api.tesisrutas.com/usuarios/507f1f77bcf86cd799439011/rutasRegister" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -H "Content-Type: application/json" \
  -d '{
    "ruta_id": "507f191e810c19729de860ec",
    "fecha": "2024-03-15T10:30:00Z",
    "duracion": 120,
    "calificacion": 5
  }'

Error Responses

403
error
Forbidden - User attempting to track another user’s routes
{
  "detail": "No autorizado"
}
400
error
Bad Request - Failed to register route
{
  "detail": "No se pudo registrar la ruta recorrida."
}

Authorization Rules

  • Self-track: Users can track their own activity (visited POIs and completed routes)
  • Admin-track: Admins can track activity for any user
  • Restricted: Users cannot track activity for other users unless they are admins

Use Cases

Activity tracking enables:
  • Personalized recommendations based on user history
  • Gamification with achievements and progress tracking
  • Analytics to understand popular POIs and routes
  • User engagement metrics and retention analysis

Implementation Details

Visited POI Source: src/infrastructure/api/routers/usuario_router.py:159-178 Completed Route Source: src/infrastructure/api/routers/usuario_router.py:181-200 These endpoints use MongoDB operations:
  • Visited POIs: Uses $addToSet to prevent duplicate entries in the pois_visitados array
  • Completed Routes: Uses $push to append route completion data to the rutas_recorridas array, allowing multiple completions of the same route
The tracking data is stored directly in the user document for fast access and querying.

Build docs developers (and LLMs) love