Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JorLOrT/rappi2/llms.txt

Use this file to discover all available pages before exploring further.

Rappi2 stores all GPS data in MongoDB, giving you millisecond-resolution location history per assignment, geospatial proximity queries over the active fleet, and polygon-based geofences for route compliance. All tracking endpoints live under /api/tracking and /api/geocercas.

Recording GPS pings

Send a ping every time a driver’s device reports its location. Each ping is stored as a GeoJSON Point in the gps_tracking collection and indexed with a 2dsphere index for geospatial queries. Required permission: tracking:write
curl -X POST https://api.rappi2.example/api/tracking/ping \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "asignacion_id": 55,
    "conductor_id": 7,
    "vehiculo_placa": "ABC-123",
    "lon": -77.0282,
    "lat": -12.1191,
    "speed_kmh": 38.5,
    "heading": 270.0,
    "accuracy_m": 4.2,
    "timestamp": "2025-06-01T10:22:00Z"
  }'
Response 201 Created:
{
  "id": "6659f3a2c1e4b200012f9a01",
  "asignacion_id": 55,
  "conductor_id": 7,
  "vehiculo_placa": "ABC-123",
  "location": {
    "type": "Point",
    "coordinates": [-77.0282, -12.1191]
  },
  "speed_kmh": 38.5,
  "heading": 270.0,
  "accuracy_m": 4.2,
  "timestamp": "2025-06-01T10:22:00Z"
}
FieldTypeRequiredNotes
asignacion_idintegerYesLinks the ping to an active assignment
conductor_idintegerYesIdentifies the driver
vehiculo_placastringYesVehicle plate
lonfloatYesLongitude, [-180, 180]
latfloatYesLatitude, [-90, 90]
speed_kmhfloatNoSpeed in km/h
headingfloatNoBearing in degrees, [0, 360]
accuracy_mfloatNoGPS accuracy radius in metres
timestampdatetimeNoDefaults to server UTC time if omitted
The gps_tracking collection carries a 2dsphere index on the location field, which powers all geospatial queries — proximity searches and $geoIntersects containment checks. Ping throughput is only limited by MongoDB write capacity; the index is created automatically on startup.

Querying tracking history

Retrieve all pings for a given assignment, optionally filtered to a time window. Results are returned newest-first, capped at limit documents. Required permission: tracking:read
curl "https://api.rappi2.example/api/tracking/asignacion/55\
?desde=2025-06-01T10:00:00Z\
&hasta=2025-06-01T11:00:00Z\
&limit=100" \
  -H "Authorization: Bearer $TOKEN"
ParameterTypeDefaultMaxNotes
asignacion_idintegerPath parameter
desdedatetimenoneISO 8601, filters timestamp >= desde
hastadatetimenoneISO 8601, filters timestamp <= hasta
limitinteger5002000Maximum pings returned
To fetch only the most recent ping for a quick location check:
curl "https://api.rappi2.example/api/tracking/asignacion/55/ultimo" \
  -H "Authorization: Bearer $TOKEN"

Finding nearby drivers

Search for drivers who have sent a ping within a configurable radius and time window. This is useful for dispatch UIs and auto-assignment workflows. Required permission: tracking:read
curl "https://api.rappi2.example/api/tracking/conductores-cerca\
?lon=-77.0282\
&lat=-12.1191\
&radio_m=3000\
&ventana_min=5" \
  -H "Authorization: Bearer $TOKEN"
Response 200 OK:
[
  {
    "conductor_id": 7,
    "asignacion_id": 55,
    "vehiculo_placa": "ABC-123",
    "location": {
      "type": "Point",
      "coordinates": [-77.0312, -12.1204]
    },
    "speed_kmh": 12.0,
    "timestamp": "2025-06-01T10:21:55Z",
    "distance_m": 347.2,
    "ultimo_ping_id": "6659f3a2c1e4b200012f9a01"
  }
]
ParameterTypeDefaultRangeNotes
lonfloat[-180, 180]Center longitude
latfloat[-90, 90]Center latitude
radio_minteger200010 – 50000Search radius in metres
ventana_mininteger51 – 60Only consider pings newer than this many minutes
Keep ventana_min small (3–5 minutes) to avoid including drivers whose device went offline. A driver whose last ping is 20 minutes old is likely not reachable even if they are inside the radius.

Trip statistics

Get aggregated metrics for a completed or in-progress assignment: total distance, elapsed time, and average speed computed from the stored pings. Required permission: tracking:read
curl "https://api.rappi2.example/api/tracking/asignacion/55/estadisticas" \
  -H "Authorization: Bearer $TOKEN"
Response 200 OK:
{
  "asignacion_id": 55,
  "pings": 142,
  "distancia_total_m": 8412.37,
  "distancia_total_km": 8.412,
  "duracion_segundos": 2820.0,
  "duracion_minutos": 47.0,
  "velocidad_promedio_kmh": 10.73,
  "primer_ping": "2025-06-01T10:15:02Z",
  "ultimo_ping": "2025-06-01T11:02:02Z"
}
Distance is calculated with the haversine formula across consecutive pings. If no pings exist for the assignment, all numeric fields return 0 or null.

Creating geofences

Geofences are GeoJSON Polygon documents stored in the geocercas collection. They can be associated with a route or an order and used to check whether a driver is within a defined zone. Required permission: geocercas:write
curl -X POST https://api.rappi2.example/api/geocercas \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ruta_id": 12,
    "orden_id": 1001,
    "tipo": "zona_entrega",
    "coordinates": [
      [
        [-77.0310, -12.1180],
        [-77.0290, -12.1180],
        [-77.0290, -12.1200],
        [-77.0310, -12.1200],
        [-77.0310, -12.1180]
      ]
    ],
    "tolerance_m": 50,
    "activa": true
  }'
Response 201 Created:
{
  "id": "6659f4b3c1e4b200012f9b02",
  "ruta_id": 12,
  "orden_id": 1001,
  "tipo": "zona_entrega",
  "geometry": {
    "type": "Polygon",
    "coordinates": [
      [
        [-77.0310, -12.1180],
        [-77.0290, -12.1180],
        [-77.0290, -12.1200],
        [-77.0310, -12.1200],
        [-77.0310, -12.1180]
      ]
    ]
  },
  "tolerance_m": 50,
  "activa": true,
  "created_at": "2025-06-01T10:00:00Z"
}
FieldTypeNotes
tipostringruta_buffer | zona_entrega | prohibida
coordinatesarrayGeoJSON Polygon ring: [[[lon, lat], ...]]. First and last point must be identical.
tolerance_mintegerInformational buffer, not enforced server-side
activabooleanOnly active geofences participate in containment queries

Checking geofence containment

Query which active geofences contain a given coordinate. The server uses $geoIntersects against the geometry field. Required permission: geocercas:read
curl "https://api.rappi2.example/api/geocercas/contiene\
?lon=-77.0300\
&lat=-12.1190" \
  -H "Authorization: Bearer $TOKEN"
Returns an array of all active GeocercaOut documents whose polygon contains the point. An empty array means the coordinate is outside all registered geofences.

Build docs developers (and LLMs) love