Skip to main content
POST
/
rutas
/
sugerencias
curl -X POST https://api.tesisrutas.com/rutas/sugerencias \
  -H "Content-Type: application/json" \
  -d '{
    "actual": "507f1f77bcf86cd799439011",
    "seleccionados": [
      "507f1f77bcf86cd799439011",
      "507f1f77bcf86cd799439012"
    ],
    "limite": 5
  }'
{
  "actual": "507f1f77bcf86cd799439011",
  "seleccionados": [
    "507f1f77bcf86cd799439011",
    "507f1f77bcf86cd799439012"
  ],
  "sugerencias": [
    {
      "id": "507f1f77bcf86cd799439013",
      "nombre": "Palacio Municipal",
      "ubicacion": "Plaza de Armas, Centro Histórico",
      "importancia": "Sede del gobierno local",
      "anio_construccion": 1780,
      "funcion": "Administrativo",
      "coordenadas": {
        "latitud": -12.0464,
        "longitud": -77.0428
      },
      "multimedia": [
        "https://storage.example.com/palacio-municipal-1.jpg",
        "https://storage.example.com/palacio-municipal-2.jpg"
      ],
      "distancia_km": 0.15
    },
    {
      "id": "507f1f77bcf86cd799439014",
      "nombre": "Museo Histórico Regional",
      "ubicacion": "Calle del Comercio 234",
      "importancia": "Principal museo de la ciudad",
      "anio_construccion": 1650,
      "funcion": "Cultural",
      "coordenadas": {
        "latitud": -12.0470,
        "longitud": -77.0435
      },
      "multimedia": [
        "https://storage.example.com/museo-1.jpg"
      ],
      "distancia_km": 0.22
    },
    {
      "id": "507f1f77bcf86cd799439015",
      "nombre": "Casa de la Cultura",
      "ubicacion": "Avenida Cultural 567",
      "importancia": "Centro cultural municipal",
      "anio_construccion": 1920,
      "funcion": "Cultural",
      "coordenadas": {
        "latitud": -12.0480,
        "longitud": -77.0440
      },
      "multimedia": [],
      "distancia_km": 0.35
    }
  ]
}
Provides smart POI suggestions based on the current location and already selected POIs. This endpoint is designed for interactive route building interfaces where users add POIs one by one.

Authentication

No authentication required. This is a public endpoint.
actual
string
required
ID of the current POI (last selected or current position)
seleccionados
array
required
Array of POI IDs already selected in the route. Can be empty array for first suggestion.
limite
integer
default:"5"
Maximum number of suggestions to return (default: 5)

Suggestion Algorithm

The suggestion system uses intelligent filtering and proximity ranking:
  1. Current Position: Fetches coordinates of the current POI
  2. Filter Selected: Excludes all POIs already in seleccionados array
  3. Calculate Distances: Uses Haversine formula for all candidates
  4. Sort by Proximity: Orders by distance from current position
  5. Return Top N: Returns the closest unvisited POIs
See sugerir_pois_proximos.py:11-54 for implementation.
actual
string
Echo of the current POI ID from request
seleccionados
array
Echo of the selected POI IDs from request
sugerencias
array
Array of suggested POI objects, ordered by proximity
id
string
POI identifier
nombre
string
Name of the POI
ubicacion
string
Location description
importancia
string
Historical or cultural importance level
anio_construccion
integer
Year of construction
funcion
string
Original or current function of the site
coordenadas
object
Geographic coordinates
latitud
number
Latitude
longitud
number
Longitude
multimedia
array
Array of media URLs (images, videos)
distancia_km
number
Distance in kilometers from the current POI
curl -X POST https://api.tesisrutas.com/rutas/sugerencias \
  -H "Content-Type: application/json" \
  -d '{
    "actual": "507f1f77bcf86cd799439011",
    "seleccionados": [
      "507f1f77bcf86cd799439011",
      "507f1f77bcf86cd799439012"
    ],
    "limite": 5
  }'
{
  "actual": "507f1f77bcf86cd799439011",
  "seleccionados": [
    "507f1f77bcf86cd799439011",
    "507f1f77bcf86cd799439012"
  ],
  "sugerencias": [
    {
      "id": "507f1f77bcf86cd799439013",
      "nombre": "Palacio Municipal",
      "ubicacion": "Plaza de Armas, Centro Histórico",
      "importancia": "Sede del gobierno local",
      "anio_construccion": 1780,
      "funcion": "Administrativo",
      "coordenadas": {
        "latitud": -12.0464,
        "longitud": -77.0428
      },
      "multimedia": [
        "https://storage.example.com/palacio-municipal-1.jpg",
        "https://storage.example.com/palacio-municipal-2.jpg"
      ],
      "distancia_km": 0.15
    },
    {
      "id": "507f1f77bcf86cd799439014",
      "nombre": "Museo Histórico Regional",
      "ubicacion": "Calle del Comercio 234",
      "importancia": "Principal museo de la ciudad",
      "anio_construccion": 1650,
      "funcion": "Cultural",
      "coordenadas": {
        "latitud": -12.0470,
        "longitud": -77.0435
      },
      "multimedia": [
        "https://storage.example.com/museo-1.jpg"
      ],
      "distancia_km": 0.22
    },
    {
      "id": "507f1f77bcf86cd799439015",
      "nombre": "Casa de la Cultura",
      "ubicacion": "Avenida Cultural 567",
      "importancia": "Centro cultural municipal",
      "anio_construccion": 1920,
      "funcion": "Cultural",
      "coordenadas": {
        "latitud": -12.0480,
        "longitud": -77.0440
      },
      "multimedia": [],
      "distancia_km": 0.35
    }
  ]
}

Use Cases

Interactive Route Builder

Example: Building a route step by step
let selectedPOIs = [];
let currentPOI = null;

// User selects first POI
currentPOI = "507f1f77bcf86cd799439011";
selectedPOIs.push(currentPOI);

// Get suggestions for next POI
const response1 = await fetch('/rutas/sugerencias', {
  method: 'POST',
  body: JSON.stringify({
    actual: currentPOI,
    seleccionados: selectedPOIs
  })
});

const suggestions1 = await response1.json();
// Display suggestions1.sugerencias to user

// User selects second POI
currentPOI = suggestions1.sugerencias[0].id;
selectedPOIs.push(currentPOI);

// Get next suggestions
const response2 = await fetch('/rutas/sugerencias', {
  method: 'POST',
  body: JSON.stringify({
    actual: currentPOI,
    seleccionados: selectedPOIs
  })
});

// Continue until route is complete...

Mobile App “Next Stop” Feature

Example: Progressive route navigation
def get_next_suggestions(current_location, visited_pois):
    response = requests.post(
        'https://api.tesisrutas.com/rutas/sugerencias',
        json={
            'actual': current_location,
            'seleccionados': visited_pois,
            'limite': 3  # Show top 3 nearby
        }
    )
    return response.json()['sugerencias']

# User is at POI A, has visited A and B
suggestions = get_next_suggestions(
    current_location="POI_A",
    visited_pois=["POI_A", "POI_B"]
)

print("Where to go next:")
for poi in suggestions:
    print(f"{poi['nombre']} - {poi['distancia_km']} km away")

Important Notes

  • Suggestions are always sorted by distance (closest first)
  • Distance is calculated using the Haversine formula (great-circle distance)
  • POIs in seleccionados are automatically excluded
  • The actual POI can be in the seleccionados array
  • Returns empty array if no suggestions available
  • Includes full POI details for immediate display

Validation

  • actual field is required (returns error if missing)
  • seleccionados must be an array (returns error otherwise)
  • Empty seleccionados array is valid for first suggestion
  • Invalid POI IDs are silently ignored

Performance

  • Calculates distances for all active POIs in database
  • Optimized for databases with hundreds of POIs
  • For thousands of POIs, consider caching or spatial indexing

Build docs developers (and LLMs) love