Megabus APImegabus.com ↗
Search Megabus UK coach trips, compare fares, check seat availability, and retrieve stop lists and price calendars via a structured REST API.
What is the Megabus API?
The Megabus UK API covers 5 endpoints for querying coach trips, stop data, route guides, fare calendars, and seat vacancy across the Megabus UK network. The search_trips endpoint returns trip-level detail including departure and arrival times, duration in seconds, seats remaining, and cheapest price in pence — all keyed by Distribusion city codes such as GBLON and GBMAN.
curl -X GET 'https://api.parse.bot/scraper/7adc06ab-d9ba-4cbc-b019-293f47442dc3/search_trips?pax=1&origin=GBLON&destination=GBMAN&departure_date=2026-07-21' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace megabus-com-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""Walkthrough: Megabus UK SDK — search trips, check prices, list stops and routes."""
from parse_apis.megabus_uk_api import Megabus, FareClass, TripNotFound
megabus = Megabus()
# Search trips from London to Manchester, capped at 3 results
for trip in megabus.trips.search(origin="GBLON", destination="GBMAN", departure_date="2026-06-26", limit=3):
print(trip.id, trip.departure_time, trip.cheapest_price_pence, trip.total_seats_left)
for fare in trip.fares:
print(f" {fare.fare_class.name}: {fare.price_pence}p")
# Check cheapest prices across dates for a route
calendar = megabus.pricecalendars.check(
origin="GBLON",
destination="GBMAN",
departure_dates='["2026-06-26","2026-06-27"]',
)
print(calendar.prices)
# Check vacancy for a specific connection using the FareClass enum
try:
vacancy = megabus.vacancies.check(
carrier_code="NEXP",
departure_station="GBLONVSA",
arrival_station="GBMANCBS",
departure_date="2026-06-26",
departure_time="02:00",
arrival_date="2026-06-26",
arrival_time="07:35",
fare_class=FareClass.STANDARD,
)
print(vacancy.id, vacancy.vacant, vacancy.total_price, vacancy.currency)
except TripNotFound as exc:
print(f"Trip not found: {exc}")
# List first 5 stops
for stop in megabus.stops.list(limit=5):
print(stop.name, stop.code, stop.latitude, stop.longitude)
# List first 3 route guides
for guide in megabus.routeguides.list(limit=3):
print(guide.title, guide.services, guide.timetable_url)
print("exercised: trips.search / pricecalendars.check / vacancies.check / stops.list / routeguides.list")
Search for available coach trips between two cities on a specific date. Returns detailed trip info including times, duration, prices, and seat availability. Uses Distribusion city codes (e.g. GBLON, GBMAN). Each trip includes fares with fare class details and carrier name.
| Param | Type | Description |
|---|---|---|
| pax | integer | Number of passengers (1-9). |
| originrequired | string | Origin Distribusion city code (e.g. GBLON for London, GBMAN for Manchester, GBEDIN for Edinburgh). |
| destinationrequired | string | Destination Distribusion city code (e.g. GBLON for London, GBMAN for Manchester, GBEDIN for Edinburgh). |
| departure_daterequired | string | Departure date in YYYY-MM-DD format. Must be a current or future date. |
{
"type": "object",
"fields": {
"trips": "array of trip objects with id, departure_time, arrival_time, duration_seconds, total_seats_left, booked_out, cheapest_price_pence, fares, and carrier_name"
},
"sample": {
"data": {
"trips": [
{
"id": "NEXP-GBLONVSA-GBMANAIR-2026-06-20T02:00-2026-06-20T07:15",
"fares": [
{
"id": "NEXP-GBLONVSA-GBMANAIR-2026-06-20T02:00-2026-06-20T07:15-FARE-2",
"fare_class": {
"code": "FARE-2",
"name": "Restricted Fare",
"journey_type": "single",
"iata_category": null
},
"price_pence": 2390
}
],
"booked_out": false,
"arrival_time": "2026-06-20T07:15",
"carrier_name": "National Express",
"departure_time": "2026-06-20T02:00",
"duration_seconds": 18900,
"total_seats_left": 22,
"cheapest_price_pence": 2390
}
]
},
"status": "success"
}
}About the Megabus API
Trip Search and Fare Data
The search_trips endpoint accepts an origin and destination as Distribusion city codes (e.g. GBLON for London, GBEDIN for Edinburgh), a departure_date in YYYY-MM-DD format, and an optional pax count. It returns an array of trip objects, each carrying departure_time, arrival_time, duration_seconds, total_seats_left, a booked_out flag, and cheapest_price_pence. This is the primary endpoint for building trip search or fare comparison tools.
Price Calendars and Vacancy Checks
get_cheapest_prices_calendar accepts the same origin/destination city codes and a JSON array of dates, returning only dates that have service — dates with no trips are omitted entirely. Each returned date maps to a price object with fractional (price in pence) and currency. For deeper fare inspection, get_trip_vacancy checks a specific connection by departure and arrival station codes (e.g. GBLONVSA, GBMANCBS), date, time, and carrier code. It returns a vacancy response including vacant, total_price, and original_price attributes, and optionally filters by fare class (FARE-1 Standard, FARE-2 Restricted, FARE-3 Fully Flexible).
Stops and Route Guides
get_stops_list returns the full catalogue of UK Megabus stops with name, friendlyName, code, longitude, latitude, information, stopGroupExtFlag, and ssrs fields. Note that these numeric stop codes are distinct from the Distribusion city codes used in trip search — they apply specifically to the get_trip_vacancy station parameters. get_route_guides returns all published route guides, including title, services, departures, destinations, timetableUrl, and seasonal timetableTabs data, making it useful for building timetable browsers or route discovery features.
The Megabus API is a managed, monitored endpoint for megabus.com — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when megabus.com changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official megabus.com API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a coach fare comparison tool using cheapest_price_pence from search_trips across multiple routes
- Display a monthly price calendar for a London–Edinburgh route using get_cheapest_prices_calendar
- Check real-time seat availability and fare class pricing for a specific departure via get_trip_vacancy
- Render an interactive stop map using latitude/longitude coordinates from get_stops_list
- Generate a timetable directory from route guides including service numbers and timetableUrl links
- Alert users when low-cost seats appear on a route by polling search_trips for total_seats_left
- Cross-reference Distribusion station codes with stop metadata before submitting a vacancy query
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.