# Traffic

Get road congestion and closures inside a box, marked by staff or seen from our taxis' GPS.

`GET /v2/traffic`. Auth: API key.

This call needs a key. There is no keyless trial for it.

## Parameters

| Parameter | Required | Description |
|---|---|---|
| `bbox` | Yes | `minLng,minLat,maxLng,maxLat`. At most 0.5° wide and 0.5° high. |

## Example

```bash
curl -s -H "X-API-Key: $QUADRUPER_KEY" \
  'https://quadruper.com/v2/traffic?bbox=122.50,10.65,122.62,10.75'
```

This is an example response:

```json schema=traffic-response
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "id": "5b0c1c9e-8d2f-4f7a-9a51-2f4f0f6d1a10",
      "geometry": { "type": "LineString", "coordinates": [[122.56, 10.7], [122.565, 10.702], [122.57, 10.704]] },
      "properties": {
        "level": "heavy",
        "source": "staff",
        "road_name": "Diversion Road",
        "confidence": null,
        "updated_at": "2026-11-05T08:10:00Z",
        "expires_at": "2026-11-05T09:10:00Z"
      }
    },
    {
      "type": "Feature",
      "id": "9a7e3d21-4c6b-4f0e-8b52-1d3c5e7f9a04",
      "geometry": { "type": "LineString", "coordinates": [[122.5642, 10.6968], [122.5631, 10.6995], [122.5619, 10.7021]] },
      "properties": {
        "level": "moderate",
        "source": "gps",
        "road_name": "Benigno Aquino Avenue",
        "confidence": "high",
        "updated_at": "2026-11-05T08:11:00Z",
        "expires_at": "2026-11-05T08:16:00Z"
      }
    }
  ],
  "generated_at": "2026-11-05T08:12:03Z",
  "attribution": [{ "source": "osm", "text": "© OpenStreetMap contributors", "license": "ODbL-1.0" }]
}
```

## Response fields

Each feature is one stretch of road. Its line runs in the direction of travel. An answer has at most 500 features,
staff stretches first, then newest first, and may be cached for 30 seconds. A box with nothing in it returns an empty `features` list.

| Field | Description |
|---|---|
| `properties.level` | How bad it is. See the levels below. |
| `properties.source` | `staff`: a person marked it by hand. `gps`: our taxis' positions show it. |
| `properties.road_name` | The road's name, or `null` |
| `properties.confidence` | For `gps`: `high` when at least 5 different taxis drove every part of it lately, `medium` when the weakest part had 3 or 4. "Lately" is the last 3 minutes when enough taxis drove then, otherwise the last 10, so a busy road can still show `medium`. `null` for `staff`. Older answers may leave it out. |
| `properties.updated_at` | When it was last marked, changed or confirmed |
| `properties.expires_at` | When it stops showing unless staff extend it or taxis confirm it again |

| Level | Meaning |
|---|---|
| `moderate` | Slower than usual |
| `heavy` | Slow going |
| `standstill` | Traffic is barely moving |
| `closed` | The road is shut. Only staff mark this; `gps` never does. |

Where staff and taxis see the same road, the staff stretch is shown and the `gps` one is not.

A `gps` stretch shows a few minutes after traffic slows: it needs at least 3 taxis and two checks a minute apart. It
goes a few minutes after traffic moves again. Staff names, notes, speeds and taxi counts are never included.

## What it is not

Route times and route choice don't use traffic yet. Present it as a map layer. It covers Iloilo City and its
neighbours Oton, Pavia and Leganes, and only roads that staff marked, or main roads (trunk to tertiary) that our taxis drove in the last 10 minutes.

## Errors

| Status | `code` | When |
|---|---|---|
| 400 | `invalid_request` | `bbox` is missing, malformed, has min above max, or is wider or higher than 0.5°. The last two carry `details.field` = `bbox`; a missing or malformed `bbox` has no `details`. |
| 501 | `capability_unavailable` | This deployment doesn't offer traffic (`details.capability` is `traffic`) |
| 503 | `traffic_unavailable` | "Traffic is unavailable right now." Retry later. Routes are not affected. |

A missing or wrong key, and the other gateway errors, are in [Errors](errors.md).
