Skip to content

Add OpenSky-Network API example #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 18, 2023
Merged

Add OpenSky-Network API example #133

merged 8 commits into from
Jun 18, 2023

Conversation

DJDevon3
Copy link
Contributor

Free public limit is 100 calls per day and maximum of 60 seconds each or you'll get temp banned. You get 4000 calls if you login but I haven't figured out how with a microcontroller yet. They have no token system and their API is primarily built for python & curl. It's a foot in the door for public access to flight data.

DJDevon3 added 4 commits May 29, 2023 04:04
Free public limit is 100 calls per day and maximum of 60 seconds each or you'll get temp banned. You get 4000 calls if you login but I haven't figured out how with a microcontroller yet. They have no token system and their API is primarily built for python & curl. It's a foot in the door for public access to flight data.
i forget every single time
Website login required, uses circuitpython_base64 library for encoding. Allows for 4000 calls per day on any active available transponder in their network (about 40K aircraft). This was a somewhat requested API I took on.. and succeeded.
@DJDevon3
Copy link
Contributor Author

DJDevon3 commented May 29, 2023

Figured out how to authenticate a login. It was not easy and there was almost no documentation. Authentication via REST GET is undocumented. Just figured it out from hints reading their forums. Added a public & private API. There's huge difference in the amount of calls per day and rate limiting if you're authenticated or not.

DJDevon3 added 2 commits May 29, 2023 06:39
rearranged imports to make pylint happy
Shows all flight traffic in a lat/lon area. This one is really neat!
@DJDevon3
Copy link
Contributor Author

The private_area example is while being authenticated (use website login credentials) and shows all air traffic in a lat/lon geographic area. You're going to want to review this on an S2 or S3. It will return a good amount of data depending on how large of a geographic area you select. The default area I put in is the Orlando airport area so there's always bound to be some traffic happening.

OpenSky_Area_API

Comment on lines 33 to 34
timezone = os.getenv("timezone")
tz_offset_seconds = os.getenv("timezone_offset")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two timezone related variables get created, but don't seem to be used anywhere that I can tell. Is it possible to remove them or are they necessary for some reason?

Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested all 3 examples successfully on a feather esp32-s3.

I did a test run without those timezone variables and it was able to run and fetch data successfully. I think we can remove those in order to avoid any confusion of someone thinking they will have some impact on the results.

Everything beyond that seems good to me. Thanks for the new examples @DJDevon3!

@DJDevon3
Copy link
Contributor Author

DJDevon3 commented Jun 13, 2023

Oops yes. About halfway through became unsure if everything should be in 0 UTC or add the option for timezone offsets. I think all flight times are returned as 0 UTC because flights can easily cross multiple timezones. Also if a geographic area is large enough it's possible for the area itself to span multiple time zones. The example in their API is the entire country of Switzerland. No way you'd want to do the entire USA it would crash the microcontroller due to lack of ram allocation. Easier keep everything in 0 UTC and also recommend a small area. If a user wants to add the timezone for a lat/lon area that will be up to them. Will clean it up. Nice catch. Thank you.

DJDevon3 added 2 commits June 13, 2023 11:18
Removed unused timezone vars and assorted script clean up. Changed var for base64cred to be more obvious that a base64 encode is required in the request header.
Copy link
Contributor

@FoamyGuy FoamyGuy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you @DJDevon3!

@FoamyGuy FoamyGuy merged commit 1259b73 into adafruit:main Jun 18, 2023
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants