ClickBus place autocomplete
Bus places (cities and terminals) matching a name, as the ClickBus search box suggests them: id, name, slug (the value /clickbus/v1/trips takes), whether the slug covers every terminal in the city, city name and id. Or the places near a point with lat, lon and radius_km.
Every response includes credits_used: the credits this call cost.
Part of the ClickBus API: 9 endpoints with prices, use cases and example responses.
Parameters
| name | type | description |
|---|---|---|
q | string | City or terminal name, 2+ characters, e.g. campinas, rio de janeiro. Give q or lat and lon. Example: campinas |
lat | number | Latitude for places near a point. |
lon | number | Longitude for places near a point. |
radius_km | integer | Search radius for lat/lon, 1-300 km (default 30). |
limit | integer | Results, 1-50 (default 10). |
Every endpoint also takes fresh, raw, fields (see lean responses and caching).
Example
curl "https://api.api.sh/clickbus/v1/places?q=campinas" \
-H "x-api-key: $APISH_KEY" import os, requests
res = requests.get(
"https://api.api.sh/clickbus/v1/places",
params={"q": "campinas"},
headers={"x-api-key": os.environ["APISH_KEY"]},
timeout=120,
)
res.raise_for_status()
data = res.json() const url = new URL("https://api.api.sh/clickbus/v1/places");
url.searchParams.set("q", "campinas");
const res = await fetch(url, { headers: { "x-api-key": process.env.APISH_KEY } });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json(); Response
A JSON object with the fields described above, plus raw (the source's own data), cached, fetched_at and credits_used. Errors return {"success": false, "error": "…"} with the HTTP status (see errors). A lookup that ran but found nothing (404) costs the price above; refused calls and errors on our side are free (what's charged).
Example response (real call, trimmed: lists cut to 2 items, long text shortened, raw left out)
{"query": "campinas","count": 10,"places": [{"id": 78764,"name": "Campinas, SP - TODOS","slug": "campinas-sp-todos","all_terminals_in_city": true,"city": "Campinas","city_id": 721,"distance_km": null,"latitude": null,"longitude": null},{"id": 2505,"name": "Campinas, SP","slug": "campinas-sp","all_terminals_in_city": false,"city": "Campinas","city_id": 721,"distance_km": null,"latitude": null,"longitude": null},"… 8 more"],"cached": false,"credits_used": 1}