Hat Yai Transit API
Every route, stop, departure and fare in Hat Yai Transit, as a free JSON API. Use it without a key at the keyless limits, or get a free key for higher limits and the journey planner.
Quick start
Base URL: https://hatyaitransit.techmavie.digital. Every response is JSON. Names come in Thai, English and Malay ({ "th", "en", "ms" }) and times are Thailand time (Asia/Bangkok, GMT+7).
Without a key:
curl https://hatyaitransit.techmavie.digital/api/stops/SRT_HAT_YAI/departuresWith your key (header X-API-Key):
curl -H "X-API-Key: hyt_your_key_here" https://hatyaitransit.techmavie.digital/api/routes/HY3Plan a journey (needs a key):
curl -X POST https://hatyaitransit.techmavie.digital/api/journey/plan \
-H "X-API-Key: hyt_your_key_here" -H "Content-Type: application/json" \
-d '{"origin":{"stopId":"HY3_19"},"destination":{"stopId":"SRT_HAT_YAI"},"options":{"language":"en"}}'Keys and rate limits
A key is optional. Without one you can use every data endpoint at a lower limit; a free key raises the limits and unlocks the journey planner. Keys are free, and we email them to you.
| Without a key | With a free key | |
|---|---|---|
| Requests per minute | 60 per IP address | 300 per key |
| Requests per day | No daily cap | 10,000 per key |
| Journey planner | Not available | 30 a minute, 500 a day |
| Place search | Only in the Hat Yai Transit app | Only in the Hat Yai Transit app |
Sending your key: put it in the X-API-Key header (best). Authorization: Bearer <key> and ?api_key= work too. A wrong or revoked key gets HTTP 401; it doesn’t fall back to the keyless limit.
Limit headers: every response says which tier you’re on (X-API-Tier) and how much is left (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset in seconds; with a key also X-RateLimit-Limit-Day and X-RateLimit-Remaining-Day). Over a limit you get HTTP 429 with a Retry-After header. Daily limits reset at midnight Thailand time.
Your key: check it with GET /api/developer/key; if it leaks, revoke it with DELETE /api/developer/keys (send the key) and request a new one. Up to 2 active keys per email address.
CORS: GET endpoints and POST /api/journey/plan send Access-Control-Allow-Origin: *. Keep your key on a server where you can: a key in browser code can be copied.
Endpoints
| Endpoint | What it returns |
|---|---|
GET/api/routes |
All routes with fares, operating hours, directions and data-confidence notes.
|
GET/api/routes/{id} |
One route and all of its stops.
|
GET/api/routes/{id}/geometry |
Route lines as encoded polylines (Google format, precision 5). Optional ?direction=0|1.
|
GET/api/routes/{id}/departures?direction=&stopId= |
Upcoming departures on a route. Optional direction (0/1) and stopId.
|
GET/api/stops |
Every stop with Thai, English and Malay names, coordinates and the routes serving it.
|
GET/api/stops/search?q= |
Search stops by name in any of the three languages (up to 20 results).
|
GET/api/stops/nearby?lat=&lon=&radius= |
Stops near a point. radius is in metres (default 800, max 5000).
|
GET/api/stops/{id} |
One stop.
|
GET/api/stops/{id}/departures |
Next departures from a stop (optional count, max 20, and routeId).
|
GET/api/fares?date=YYYY-MM-DD |
Fares in force on a date (Bangkok date, default today), including the EV City Loop free-trial period.
|
GET/api/meta |
Region info, today’s date, fare period, route list and the disclaimer text.
|
GET/api/sources |
The data sources listed on the Sources page (publishers, links, what each supports, last checked).
|
GET/api/gtfs/feeds |
GTFS feed index: versions, validity dates, sizes and SHA-256 checksums.
|
GET/api/gtfs/{feedId}/{file} |
One file from a GTFS feed as JSON rows (for example stops.txt or trips.txt).
feedId:
hatyai-ev-loop · hatyai-airport-minibus · srt-hatyai-padang-besar · ktm-mysawasdee |
POST/api/journey/plan Key needed |
Plan a trip. origin and destination can each be { lat, lng }, { stopId } or { text }. Options: language (th/en/ms), departAt (ISO time) and modes. Trips into Malaysia or Singapore return a hand-off to our sister apps.
|
GET/api/developer/key Key needed |
Your key’s tier, when it was made, when it was last used and its limits.
|
DELETE/api/developer/keys Key needed |
Revoke the key you send (for example if it leaked), then request a new one on this page.
|
Route IDs: HY3 EV City Loop (Route 3) · HY8299 Airport Minibus · SRT_741 / SRT_SE45 SRT trains to Padang Besar · KTM_MYSAWASDEE KTM MySawasdee (seasonal)
MCP server for AI assistants
Connect Claude, ChatGPT and other AI assistants that support the Model Context Protocol to Hat Yai Transit: they can look up routes, stops, departures and fares, and plan journeys. No key needed.
Server URL (Streamable HTTP):
https://mcp.techmavie.digital/hatyaitransit/mcpClient configuration:
{
"mcpServers": {
"hatyai-transit": {
"transport": "streamable-http",
"url": "https://mcp.techmavie.digital/hatyaitransit/mcp"
}
}
}Tools
| Tool | What it does |
|---|---|
get_service_info | What Hat Yai Transit covers, today's date and fare period, and the disclaimer. |
list_routes | All routes with fares, hours and directions. |
get_route | One route and its stops in order. |
get_route_departures | Upcoming departures on a route. |
get_route_geometry | A short summary of a route's line (the full line only when asked). |
search_stops | Find stops by name in Thai, English or Malay. |
get_stop | One stop and the routes that serve it. |
find_nearby_stops | Stops near a point or a place. |
get_stop_departures | Next departures from a stop. |
get_fares | Fares in force on a date, including the EV City Loop free trial. |
plan_journey | Plan a trip between stops, places or coordinates. |
search_places | Look up a place by name, to use in plan_journey. |
list_gtfs_feeds | The open GTFS downloads (ODbL), with versions and dates. |
get_sources | Where the data comes from, plus the disclaimer. |
Source code: github.com/hithereiamaliff/mcp-hatyaitransit.
Terms of use
- The API and keys are free. Hat Yai Transit is unofficial: data comes from public announcements and community reports, and times may be estimates. Don’t present it as official operator data.
- Credit “Hat Yai Transit (unofficial)” where you show the data, and cache responses instead of polling.
- Keep your key private. We may revoke keys that are abused, shared publicly or used to get around the limits.
- The API comes as is, with no guarantee of availability or accuracy. Limits and endpoints may change; we’ll note changes on this page.
- Bulk data? Download the open GTFS feeds (ODbL) on the Sources & Open Data page instead.