A weather API can answer in milliseconds and still return an observation made much earlier. For an airport dashboard, the useful question is not just “did the request succeed?” It is “when was this report observed, and how old was it when my application received it?”
Here is a small Python check for Beijing Capital (ZBAA) and Shanghai Pudong (ZSPD). I work on Skyviewor, the China airport METAR/SPECI API used below. The code makes one live request and prints the raw reports with their timestamps; the example does not claim a particular delivery latency.
python -m pip install httpx
export SKYVIEWOR_API_KEY='YOUR_API_KEY'
import os
from datetime import datetime, timezone
import httpx
airports = "ZBAA,ZSPD"
with httpx.Client(timeout=15.0) as client:
response = client.get(
"https://data.skyviewor.io/v1/metar",
params={"airports": airports, "mode": "raw"},
headers={"Authorization": f"Bearer {os.environ['SKYVIEWOR_API_KEY']}"},
)
response.raise_for_status()
received_at = datetime.now(timezone.utc)
reports = response.json().get("data", [])
for report in reports:
observed_at = datetime.fromisoformat(report["obs_time"].replace("Z", "+00:00"))
source_arrival = datetime.fromisoformat(report["arrived_at"].replace("Z", "+00:00"))
print(report["icao"], report["report_type"], report["raw_metar"])
print(" observation age:", received_at - observed_at)
print(" source arrival after observation:", source_arrival - observed_at)
if not reports:
print("No current report was returned for the selected airports.")
There are three different clocks here:
| Clock | What it tells you |
|---|---|
obs_time |
When the airport observation was made. |
arrived_at |
When the upstream data source received that report. |
received_at |
When this particular Python request finished. |
The first difference in the script is the age of the observation at your client. The second describes observation to source arrival. It is not a measurement of Skyviewor’s forwarding time or your network round trip. For precise client timing, also record the instant before client.get() and compare it with received_at. A single sample does not establish a latency percentile.
An HTTP 200 only means the query worked. It does not mean a new METAR was issued for every airport on that request. Keep both METAR and SPECI, and identify a report by (icao, obs_time, raw_metar) when storing results: a correction can share an observation time while changing the text. Treat an absent report as missing data, rather than inventing clear weather.
For a production service, log the request status and these timestamps separately. Handle 401/403 as a key or access problem and back off on 429; a tight retry loop will not make the airport issue reports faster. The complete HTTP guide and downloadable Python script include the response shape and an airport list. Skyviewor provides low-latency REST access for 55 supported Chinese airports.
If you want to run the request with your own key, start a Skyviewor trial. Trial eligibility and timing are shown during setup.
Top comments (0)