Metro APImetro.istanbul ↗
Access Istanbul Metro lines, stations, real-time service disruptions, ticket prices, and network maps via 6 structured JSON endpoints.
What is the Metro API?
The Metro Istanbul API covers all 6 data categories published by metro.istanbul — lines, stations, line detail, live service status, ticket fares, and network maps — in structured JSON. The get_service_status endpoint returns active disruptions alongside fault counts for elevators, escalators, moving walkways, and other station equipment. The get_all_lines endpoint includes RGB color codes for every line type in the network, including metro, tramway, funicular, and cable car.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/c9026794-8ccd-456e-a6fb-d85c5e313a38/get_all_lines' \ -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 metro-istanbul-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: Metro Istanbul SDK — check service status, browse lines, and view fares."""
from parse_apis.metro_istanbul_api import MetroIstanbul, LineCode, LineNotFound
client = MetroIstanbul()
# Check real-time service status (disruptions + equipment faults).
status = client.servicestatuses.get()
print(f"Faulty elevators: {status.faulty_elevators}, escalators: {status.faulty_escalators}")
for d in status.disruptions[:2]:
print(f" Disruption (line {d.line_id}): {d.description[:80]}")
# List all transit lines; limit caps total items fetched.
for line in client.lines.list(limit=5):
print(f"{line.code}: {line.display_name}")
# Get detailed info for a specific line using the LineCode enum.
try:
detail = client.linedetails.get(line_code=LineCode.M2)
print(f"{detail.title} — {len(detail.stations)} stations")
print(f" First: {detail.stations[0]}, Last: {detail.stations[-1]}")
except LineNotFound as exc:
print(f"Line not found: {exc}")
# Browse fares.
fare = client.fares.list(limit=3).first()
if fare:
print(f"Fare: {fare.category} / {fare.type} — {fare.price}")
# List network maps.
for m in client.networkmaps.list(limit=3):
print(f"Map: {m.title} -> {m.url}")
print("Exercised: servicestatuses.get / lines.list / linedetails.get / fares.list / networkmaps.list")
Get all transit lines operated by Metro Istanbul. Returns line codes, display names, IDs, and RGB color codes for each line in the network (metro, tramway, funicular, cable car).
No input parameters required.
{
"type": "object",
"fields": {
"items": "array of line objects with METROISTHATID, HATADI (line code), HATTANIM (internal name), EKTANIM (display name), RENKR/RENKG/RENKB (RGB color)"
},
"sample": {
"data": {
"items": [
{
"RENKB": "88",
"RENKG": "115",
"RENKR": "124",
"HATADI": "F1",
"EKTANIM": "Taksim-Kabataş Füniküler Hattı",
"HATTANIM": "F1 ISLETME",
"METROISTHATID": 4
},
{
"RENKB": "68",
"RENKG": "153",
"RENKR": "0",
"HATADI": "M2",
"EKTANIM": "Yenikapı-Seyrantepe-Hacıosman Metro Hattı",
"HATTANIM": "M2 ISLETME",
"METROISTHATID": 1
}
]
},
"status": "success"
}
}About the Metro API
Lines and Stations
get_all_lines returns every transit line operated by Metro Istanbul, including internal fields like METROISTHATID, the line code (HATADI), display name (EKTANIM), and per-line RGB values (RENKR, RENKG, RENKB) useful for rendering colored route maps. get_all_stations covers the full network: each station object carries a station_id, name, display_name, associated line_id and line_name, ordering position within its line (order), and a sap_code for cross-referencing operational data.
Line Detail
get_line_detail accepts a required line_code parameter (e.g., M2, T1, F1) and returns a full profile for that line: a title, a details object with operating metrics such as line length, station count, vehicle count, journey time, operating hours, and daily ridership, an ordered stations array with station names in sequence, and a transfers array describing connections to other lines. Thirteen line codes are currently accepted, spanning metro, tramway, and funicular services.
Service Status and Fares
get_service_status is the real-time endpoint. The seferDurumlari array lists active service disruptions; an empty array means normal service. Alongside disruption status, the response returns string counts for faulty station equipment: elevators (arizaliAsansor), escalators (arizaliYuruyenMerdiven), moving walkways (arizaliYuruyenBant), restrooms (arizaliTuvalet), baby rooms (arizaliBebekOdasi), and prayer rooms (arizaliMescid). get_ticket_prices returns current fares grouped by card category — Anonim Kart, Mavi Kart, and Elektronik Kart — with each entry specifying a category, type description, and price in Turkish Lira.
Network Maps
get_network_map returns a list of objects each containing a title and url pointing to map image resources, covering metro, tramway, and construction maps. These URLs can be embedded directly in transit planning interfaces.
The Metro API is a managed, monitored endpoint for metro.istanbul — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when metro.istanbul 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 metro.istanbul 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?+
- Display color-coded line routes using the RGB values from
get_all_linesin a custom transit map. - Build a full Istanbul Metro station search by indexing the
name,display_name, andsap_codefields fromget_all_stations. - Show real-time service disruption banners in a commuter app using
seferDurumlarifromget_service_status. - Surface accessibility alerts by monitoring elevator and escalator fault counts from
get_service_status. - Calculate fare estimates for different card types using the
categoryandpricefields fromget_ticket_prices. - Render a station-by-station route view for a given line using the
stationsarray and operating metrics fromget_line_detail. - Embed up-to-date network map images using the URLs returned by
get_network_map.
| 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.
Does metro.istanbul offer an official developer API?+
What does `get_service_status` return when there are no disruptions?+
seferDurumlari returns an empty array during normal service. The response still includes equipment fault counts — strings representing the number of faulty elevators, escalators, moving walkways, restrooms, baby rooms, and prayer rooms across the network, regardless of train service status.Which line codes are accepted by `get_line_detail`?+
Does the API return real-time train arrival predictions or timetables?+
Are stations filterable by line directly, or do I need to filter client-side?+
get_all_stations returns all stations across all lines in a single response; there is no line_code filter parameter on that endpoint. Each station object includes line_id and line_name fields, so filtering by line is straightforward client-side. Alternatively, get_line_detail returns a stations array for a specific line when you supply a line_code. You can fork this API on Parse and revise it to add a filtered station endpoint if you need server-side filtering.