Flight Schedules for Beijing Capital International Airport (PEK)
You need reliable, machine-readable flight schedules for Beijing Capital’s PEK to power arrival boards, trigger delay alerts, or sync daily ops. By the end of this guide you’ll query PEK schedules with FlightLabs, parse the fields that matter, and decide when to augment schedules with real-time status or future flights for better coverage.
Why developers track Beijing Capital (PEK)
Beijing Capital International Airport serves China’s capital and uses IATA code PEK and ICAO code ZBAA. It’s a major long-haul hub with busy domestic and international banks, which makes accurate schedule data essential for traveler apps, airport displays, corporate travel tools, and logistics workflows.
Endpoint to retrieve PEK schedules
FlightLabs provides a schedules endpoint you can call with an airport IATA code and a schedule type. For PEK, use iataCode=PEK and choose type to focus on departures or arrivals.
- Base: https://api.goflightlabs.com
- Schedules: /flights-schedules?iataCode=&type=
Authentication is via API key. If you need an API key, sign up on the FlightLabs site (see the Register link below). For parameter coverage and field details, refer to the official docs.
Example: arrivals for PEK (curl)
curl -s 'https://api.goflightlabs.com/flights-schedules?iataCode=PEK&type=arrival&api_key=YOUR_API_KEY'
Replace YOUR_API_KEY with your key. Responses are JSON. Timestamps are ISO 8601; when a "Z" suffix is present, they’re UTC.
Official sample response structure
The schedules payload below shows field shapes you’ll also see when querying PEK. Use it to design your parser and UI bindings.
{
"success": true,
"data": {
"schedules": [
{
"flight_number": "UA456",
"departure": {
"airport": "SFO",
"scheduled": "2024-03-20T08:00:00Z",
"terminal": "3"
},
"arrival": {
"airport": "ORD",
"scheduled": "2024-03-20T14:15:00Z",
"terminal": "1"
},
"aircraft": {
"type": "Boeing 787-9",
"registration": "N123UA"
},
"airline": {
"name": "United Airlines",
"iata": "UA"
}
}
]
}
}
What matters for PEK schedule apps:
- flight_number: Pair with airline.iata to form a unique commercial identifier (e.g., UA456). For codeshares, use your business rules to display the operating or marketing carrier; both can be inferred by the airline and number you choose to show.
- departure.airport and arrival.airport: IATA codes; use PEK when filtering for schedules tied to Beijing Capital.
- departure.scheduled and arrival.scheduled: UTC timestamps; convert to Asia/Shanghai for local boards.
- departure.terminal and arrival.terminal: Assign passengers to terminals; vital for signage and curbside pickup logic.
- aircraft.type and aircraft.registration: Useful for seat maps and aircraft-specific services; optional for most boards.
- airline.name and airline.iata: Display brand and build “UA456” or similar composite IDs.
PEK schedules in Python
This snippet calls the schedules endpoint for PEK arrivals and normalizes a subset of fields for an arrivals board. It also shows how you’d later merge in real-time status from the tracking endpoint when you need gates, updates, or delay states.
import os
import requests
from datetime import datetime, timezone
import pytz # If not available, convert timestamps manually
API_KEY = os.getenv("FLIGHTLABS_KEY", "YOUR_API_KEY")
BASE_URL = "https://api.goflightlabs.com"
def to_local_time(iso_utc, tz_name="Asia/Shanghai"):
if not iso_utc:
return None
# Expecting ISO 8601 "Z" UTC timestamps from schedules
dt = datetime.fromisoformat(iso_utc.replace("Z", "+00:00"))
local_tz = pytz.timezone(tz_name)
return dt.astimezone(local_tz).strftime("%Y-%m-%d %H:%M")
def get_pek_arrivals():
url = f"{BASE_URL}/flights-schedules"
params = {
"iataCode": "PEK",
"type": "arrival",
"api_key": API_KEY
}
r = requests.get(url, params=params, timeout=20)
r.raise_for_status()
payload = r.json()
if not payload.get("success"):
raise RuntimeError("API response indicates failure")
return payload["data"].get("schedules", [])
def normalize_schedule(item):
airline_iata = (item.get("airline") or {}).get("iata")
flight_num = item.get("flight_number")
flight_id = f"{airline_iata}{flight_num}" if airline_iata and flight_num else (flight_num or "")
arrival = item.get("arrival") or {}
departure = item.get("departure") or {}
return {
"flight": flight_id,
"airline": (item.get("airline") or {}).get("name"),
"from": departure.get("airport"),
"to": arrival.get("airport"),
"arr_scheduled_local": to_local_time(arrival.get("scheduled")),
"dep_scheduled_local": to_local_time(departure.get("scheduled")),
"arr_terminal": arrival.get("terminal"),
"dep_terminal": departure.get("terminal"),
"aircraft_type": (item.get("aircraft") or {}).get("type"),
"registration": (item.get("aircraft") or {}).get("registration")
}
if __name__ == "__main__":
schedules = get_pek_arrivals()
rows = [normalize_schedule(s) for s in schedules]
# Example: print first 5 arrivals
for r in rows[:5]:
print(f"{r['arr_scheduled_local']} {r['flight']:8} {r['from']} → {r['to']} T{r['arr_terminal']}")
Notes:
- Times are parsed as UTC and displayed in Asia/Shanghai. Keep UTC internally for sorting across time zones.
- Combine airline.iata with flight_number for a stable commercial identifier. This helps disambiguate codeshares.
- For live gates, delay states, or diversions, call the real-time endpoint and join on airline+flight_number or other IDs your workflow standardizes.
Comparing FlightLabs endpoints for PEK use cases
Most production PEK boards blend multiple endpoints. Here’s a quick comparison of where each fits. The table emphasizes technical purpose and the fields you’ll actually read, not vendor claims.
| Endpoint | Primary purpose | Key fields you’ll use | Typical call pattern at PEK |
|---|---|---|---|
| /flights-schedules | Plan-of-day arrivals/departures for PEK | flight_number, airline.iata/name, departure/arrival.airport, scheduled, terminal, aircraft.type | Cache for 5–15 minutes; refresh on bank changes or hourly |
| Real-time Flight Tracking | Live status, gates, and progress | status, departure.actual/gate/terminal, arrival.estimated/gate/terminal, position | Poll active flights every 30–90 seconds; back off when status is final |
| Future Flights | Look ahead beyond plan-of-day | Future schedule equivalents to scheduled times and identifiers | Refresh daily or when publishing next schedule period |
| Flight History | Backfill and analytics | Past scheduled/actual times; supports ETL and SLA reviews | Batch nightly; cache long-term |
| Flight Delay Predictions | Proactive alerting | Predicted delay insights; pair with schedules and status | Call when creating alerts; re-check as departure nears |
You can browse these capabilities on the FlightLabs site and test calls from the MCP console.
Designing PEK arrivals and departures boards
For screens and apps centered on PEK, start with /flights-schedules to establish the day’s manifest. Then enrich live flights with the tracking endpoint for status, estimated times, and gates.
- Schedule layer: Render flight_number, airline.iata/name, scheduled times, and terminal for PEK. Convert scheduled UTC to Asia/Shanghai to avoid confusion at the airport.
- Live overlay: When a flight is within your active window (for example, within 6 hours of scheduled), fetch real-time status and merge fields like status, departure.actual, arrival.estimated, and gates. If status indicates “cancelled” or “diverted,” suppress schedule-only times to avoid misguiding travelers.
- Caching: Cache schedules for at least a few minutes; treat tracking data as short-lived and re-poll on an exponential schedule when status stops changing.
PEK-specific use cases you can ship today
1) Arrivals board for PEK terminals
Fields to use:
- arrival.scheduled (UTC) → convert to Asia/Shanghai
- arrival.terminal for terminal grouping
- airline.iata + flight_number for unique flight labels
Augment with real-time arrival.estimated and arrival.gate to cut missed connections. If the real-time status differs significantly from schedules, prefer the latest arrival.estimated for UI display and keep the schedule time as “scheduled” for context.
2) Delay alerts for corporate travelers
Start with the PEK schedule, but your alert logic should read live status updates. Compare arrival.estimated to arrival.scheduled or departure.actual to departure.scheduled from the real-time endpoint sample to compute deltas. Trigger push/email if deltas cross your SLA thresholds. If status shows “cancelled,” escalate to rebooking workflows immediately.
3) Daily schedule sync for dispatch and logistics
At midnight local time (or an hour before the first bank), fetch all PEK arrivals and departures and load them into your planning system. Use airline.iata + flight_number as the external ID and the scheduled timestamps as the plan-of-record. Reconcile updates by periodically refreshing schedules and reconciling with any real-time changes as push windows approach.
Time zones, UTC, and sorting at PEK
- Schedules return ISO 8601 timestamps with Z for UTC, like 2024-03-20T14:15:00Z. Store and sort in UTC to avoid issues spanning midnight or daylight shifts elsewhere.
- For UI at PEK, convert to Asia/Shanghai and display the local time alongside a UTC hover or “Scheduled (UTC)” label for power users.
- When jumping between airports, normalize everything to UTC for internal logic and choose a display time zone per screen.
Polling, caching, and merging data
- Schedules polling: Every 5–15 minutes is sufficient for most boards. Aggressive polling won’t improve freshness significantly and may increase costs.
- Real-time polling: Poll actively departing or arriving flights every 30–90 seconds. When status is terminal (e.g., landed, cancelled), reduce polling and cache results longer.
- Conflict resolution: If schedule says arrival.scheduled=17:10 but real-time arrival.estimated=17:55 with status=en-route, prefer the real-time estimate for display while retaining scheduled time for context.
Handling cancelled or diverted flights
Schedules provide the plan-of-day and may not reflect last-minute events. To handle exceptions:
- Join with real-time status when flights are near departure/arrival windows. The tracking sample includes status plus “actual” and “estimated” timestamps.
- If status is “cancelled,” highlight in UI and remove gates/terminals to reduce confusion. If “diverted,” indicate the new arrival context and suppress the scheduled destination gate.
- Retry strategy: After a cancellation or diversion, back off polling but keep periodic checks in case of reinstatement or rerouting updates.
Pagination and large schedule pulls
When querying PEK’s busy banks, the response may span many flights. If the endpoint paginates results, read the pagination instructions in the Documentation and iterate pages until exhausted. Cache each page as you go to avoid partial updates if a retry occurs mid-run. Keep your own idempotency keys keyed by airline.iata + flight_number + scheduled date to safely upsert records.
Developer ergonomics and testing
- Test console: Use the MCP to explore endpoints and sample responses quickly.
- Field stability: Build tolerant parsers. Some nested objects (aircraft, terminals) may be absent; always default missing fields.
- Localization: For PEK-facing UIs, default to Asia/Shanghai and render airline names in Latin script unless your user base requires localization.
Security, quotas, and pricing
Authenticate each request with your API key. Keep keys server-side and avoid embedding in client apps. If you’re just getting started, the entry plan is Starter at $24.99/month, and there’s a trial (7 days or 50 requests) to validate your integration before going live. For full endpoint coverage and quota details, consult the docs and your account dashboard.
Working with real-time fields (for delays, gates, and statuses)
While schedules power your baseline for PEK, you’ll often merge real-time data to reflect the current reality. Here’s the official real-time tracking shape you’ll encounter when you add status and gates to your PEK boards:
{
"success": true,
"data": {
"flight": {
"iata": "AA123",
"icao": "AAL123",
"number": "123",
"status": "en-route",
"departure": {
"airport": "JFK",
"scheduled": "2024-03-20T10:00:00Z",
"actual": "2024-03-20T10:05:00Z",
"terminal": "8",
"gate": "B12"
},
"arrival": {
"airport": "LAX",
"scheduled": "2024-03-20T13:15:00Z",
"estimated": "2024-03-20T13:20:00Z",
"terminal": "4",
"gate": "45A"
},
"position": {
"latitude": 39.8729,
"longitude": -98.7372,
"altitude": 35000,
"speed": 495,
"heading": 270
}
}
}
}
Use cases:
- status: Drive UI banners like “Boarding,” “En-route,” “Cancelled,” “Landed.”
- departure.actual vs departure.scheduled: Compute departure delays.
- arrival.estimated vs arrival.scheduled: Compute arrival delays and ETAs.
- gate/terminal: Show gates on boards; prefer live terminal/gate over schedule terminal if they differ.
- position: Optional map overlays for en-route flights to/from PEK.
Putting it together for PEK
- Fetch /flights-schedules with iataCode=PEK and type=arrival or type=departure.
- Persist the returned schedules as your plan-of-day baseline.
- As flights approach, enrich with real-time status and live timestamps.
- Trigger notifications when delays exceed thresholds derived from scheduled vs actual/estimated time comparisons.
- Use Future Flights to pre-fill the next period and Flight History for audits and reporting.
You can find more details and schemas on the FlightLabs site. If you don’t have an account yet, use the link below to get your API key and start calling the PEK schedules endpoint in minutes.
FAQ
How often should I refresh PEK schedules?
Schedules don’t change second-by-second. Refreshing every 5–15 minutes is typically sufficient; rely on the real-time endpoint for minute-level updates.
Are schedule timestamps in local time or UTC?
The samples use ISO 8601 with Z (UTC). Convert to Asia/Shanghai for PEK display while retaining UTC for sorting and comparisons.
How do I detect delays?
Compare real-time actual or estimated timestamps with scheduled ones. For example, departure.actual minus departure.scheduled indicates a departure delay; arrival.estimated minus arrival.scheduled indicates an arrival delay.
What about codeshares?
Use airline.iata + flight_number as your displayed identifier and apply your business logic to show marketing vs operating carriers. When codeshares are present, ensure consistent deduping across your UI.
How do I handle pagination for heavy banks at PEK?
Iterate through pages as described in the Documentation, upserting items by a stable key (airline.iata + flight_number + date) to avoid duplicates.
Ready to build PEK boards and alerts with real data? Get your API key and start testing today: Register. Explore schemas, examples, and setup guides in the Documentation, and try live calls in the MCP console.