Developer guide · Python · HTTP

Fetch Chinese airport METAR with Python

Use low-latency REST access to query METAR/SPECI from Chinese airports. This Python example requests Beijing Capital (ZBAA) and Shanghai Pudong (ZSPD) and explains report timing. For active updates without polling, follow the linked WebSocket push guide.

1. Download and prepare

Use Python 3.11 or later. Download the complete HTTP example script, install httpx, and set your trial key in the environment. Keep the key on your server or local machine; do not embed it in browser code, public repositories, or URLs.

Shell
python -m pip install httpx
export SKYVIEWOR_API_KEY="YOUR_API_KEY"
python china_metar_http.py --airports ZBAA,ZSPD

The script defaults to ZBAA and ZSPD. You can pass other supported four-letter ICAO codes with --airports; check the airport coverage table before using a code.

2. Read the response

The request uses GET /v1/metar with mode=raw. Each observation includes its ICAO code, original report, observation time and arrival time. The JSON below illustrates the response shape using a fixed documentation example; it is not a live reading.

Illustrative response
{
  "data": [
    {
      "icao": "ZBAA",
      "raw_metar": "METAR ZBAA 101700Z 06001MPS CAVOK 13/12 Q1021 NOSIG=",
      "obs_time": "2026-10-10T17:00:00+00:00",
      "report_type": "METAR",
      "arrived_at": "2026-10-10T17:00:46+00:00"
    }
  ]
}

Use obs_time to identify when the airport observation was made and arrived_at to identify when Skyviewor received it. A successful request does not mean every selected airport produced a new report at that moment. For parsed weather fields, change the script to mode=parsed after checking the HTTP reference.

3. Handle missing or rejected requests

The script uses a 15-second timeout and exits with an HTTP status if the request is rejected. A 401 or 403 usually means that the key or access status needs attention. A 429 means the per-key request limit was reached; slow down rather than sending more requests immediately. Never send an API key to support.

Ready for push updates? Follow the WebSocket reconnect guide. For complete parameters, limits and fields, use the METAR API reference.