FlightAware Discussions

Help with simple Python syntax for 'Search'

Hi there
Can someone please help me with my Python syntax - I am just trying to search on United Airlines 737s - but my syntax for the ‘Search’ is not correct - to do with the query - setting my syntax straight would be greatly appreciated …

import requests

username = “seq…”
apiKey = “84…”
fxmlUrl = “https://flightxml.flightaware.com/json/FlightXML2/

this_query = “-idents UAL* -type B73*”
response=requests.get(fxmlUrl + “Search”, query=this_query, auth=(username, apiKey))

if response.status_code == 200:
print(response.json())
else:
print(“Error executing request”)

I figured it after much grinding away. Hopefully this will be useful for someone else.
This works:

import requests

username = “seq…”
apiKey = “84…”
fxmlUrl = “https://flightxml.flightaware.com/json/FlightXML2/

payload = {‘query’:’-idents UAL* -type B73*’}
response=requests.get(fxmlUrl + “Search”, params=payload, auth=(username, apiKey))

if response.status_code == 200:
print(response.json())
else:
print(“Error executing request”)