Please help fix my code - python search flights

Hi Friends,

Novice coder here.

I am trying to retrieve historical flight details on a flight and I cannot make the code work (Python).

Is anybody able to please tell me what I’m doing wrong?

Using ipython.


I am trying to
from aeroapi_python.AeroAPI import AeroAPI

api_key = ‘’
aero_api = AeroAPI(api_key)

def search_flights(self, operators: self, ident_or_reg=EVY15, start=2022-0o7-0o1, end=2022-0o7-0o):
self.api_caller.get(self.api_caller._build_path(self.endpoint, search, query))

I would remove your key from the code :wink:

omg thank you so silly of me

We deactivated the leaked key fyi. We’ll get back to you on your question though. I do wonder about the “o”s in your dates

1 Like

Fun! Those are being interpreted as octal constants, and then it’s being interpreted as an expression. Wouldn’t work if there was anything more than a 7 in there…

$ python3
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0o7
>>> 2022-0o7-0o1

quote those strings, lose the os.

I’m still confused! (cries into hands)

You’ll need to explain what you’re trying to do, how it fails, and provide a complete example of your code (without API keys)

Try this:

from aeroapi_python.AeroAPI import AeroAPI

api_key = ‘your_api_key_here’
aero_api = AeroAPI(api_key)

def search_flights(operators, ident_or_reg=‘EVY15’, start=‘2022-07-01’, end=‘2022-07-10’):
query = {
‘operators’: operators,
‘ident_or_reg’: ident_or_reg,
‘start’: start,
‘end’: end
return aero_api.api_caller.get(aero_api._build_path(‘your_endpoint_here’, ‘search’, query))