Skip to content

Conversation

@mdavis-xyz
Copy link

@mdavis-xyz mdavis-xyz commented Oct 17, 2025

This PR adds a few things.

  • adds OAuth support, since the basic auth support is being deprecated. Add OAuth identification #67
  • Improves detection and documentation of invalid timespans, as per Is there a two day constraint? #76
  • Raises Python exception in the case of an HTTP error. Previous behavior was to just return None. This is a breaking change I suppose (though not covered by unit tests, I think). But returning None instead of an error makes this library extremely difficult to use. see Calling example returns None #72
  • Document how to display logs to the Python logger
  • Use a requests.Session(), so that the TLS and TCP connection is re-used across multiple requests, for performance reasons, and to simplify authentication handling
  • rename the url_post argument to an internal function, because it's for a GET request, so the name was misleading
  • the tests can now be run with just python test*.py (At first I thought the tests were passing, then I realised that they weren't actually being run.)

Note that all the get_state tests fail for me, even on the master branch. I think I don't have sufficiently privileged auth credentials.

And now I'm getting 503 errors for most calls, so I can't be sure this is correct. That's why I've marked this PR as Draft. (I'm still uploading it so you can see, because I might not have time to get back to this for another week.)

@jkua
Copy link

jkua commented Oct 23, 2025

User report here - thanks for this! I've been using the Python client for the last few days.

It mostly works, but I occasionally get:

File "/Users/jkua/projects/XXXXX/.venv/lib/python3.13/site-packages/opensky_api.py", line 316, in __init__
   raise ValueError("Authentication Failure (OAuth token generation)") from ex

NameError: name 'ex' is not defined. Did you mean: 'hex'?

Certainly, ex doesn't exist, but it also appears that I'm occasionally getting token generation issues.

@mdavis-xyz
Copy link
Author

I've pushed a fix now, to the same branch.

@mdavis-xyz
Copy link
Author

Just FYI, it seems like the maintainers of this repo don't respond to many pull requests, so I don't expect this to be merged.

I've made a fork with this and several other improvements here:

https://github.com/mdavis-xyz/opensky-api/tree/fork

Install it with:

pip install git+https://github.com/mdavis-xyz/opensky-api.git@fork

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