FlightAware Python示例中多机场代码的requests.get参数配置咨询
How to Specify Multiple Airport Codes in FlightXML3 AirportBoards Request
Hey there! Glad you asked—adjusting your FlightAware FlightXML3 request to include multiple airport codes is totally straightforward.
The key detail here is that the airport_code parameter accepts a comma-separated string of airport codes (no spaces between them) when you want to pull data for multiple airports at once.
Here's how you'd tweak your existing code to target KFSO, KMIA, and KMCO:
import requests username = "YOUR_USERNAME" apiKey = "YOUR_API_KEY" fxmlUrl = "https://flightxml.flightaware.com/json/FlightXML3/" # Update airport_code to a comma-separated string of your target airports payload = {'airport_code':'KFSO,KMIA,KMCO', 'type':'enroute', 'howMany':'10'} response = requests.get(fxmlUrl + "AirportBoards", params=payload, auth=(username, apiKey)) # Optional: Parse the response to check results if response.status_code == 200: data = response.json() print(data) else: print(f"Request failed with status code {response.status_code}")
A quick sanity check: make sure you're using English commas and no spaces between the airport codes—this is the exact format the API expects to correctly process multiple airports. All other parameters (like type and howMany) can stay exactly as you had them before.
内容的提问来源于stack exchange,提问作者gatorback




