×

Notice

The forum is in read only mode.

OpenSkyApi.get_my_states

6 years 9 months ago #367 by stkm2017
Hi,

I try to use the OpenSkyApi in python to get the states vector for my receiver only.

Here is the code:

from opensky_api import OpenSkyApi
api = OpenSkyApi()
s = api.get_my_states(serials=1408237090)

I always get NONE as the result.

s = api.get_states() returns a valid state-list, which means that I can connect to the OpenSky api.

What do I do wrong?

Thanks.
6 years 9 months ago #371 by stkm2017
Replied by stkm2017 on topic OpenSkyApi.get_my_states
I solved the problem myself:

The initiation of the OpenSkyAPI must use the Username, Password.
The following user(s) said Thank You: moser2020
6 years 9 months ago - 6 years 9 months ago #372 by fuchs
Replied by fuchs on topic OpenSkyApi.get_my_states
Hi stkm2017,

I was in the process of writing the answer while you posted the solution. For the sake of completeness here is mine:

You can retrieve states for your own device only by providing login credentials. Just pass your username and password as constructor arguments:
api = OpenSkyApi("username", "password")

The library uses Python's built-in logging facilities. You can see what's going on under the hood as follows:
from opensky_api import OpenSkyApi
import logging
import sys

logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

api = OpenSkyApi()  # sic!
s = api.get_my_states(serials=[...])
print(s)

The output looks like this:
DEBUG:opensky_api:Blocking request: Authentication required
None

Hope that helps!

Cheers,
Markus
6 years 9 months ago - 6 years 9 months ago #374 by stkm2017
Replied by stkm2017 on topic OpenSkyApi.get_my_states
Thanks Markus!

Unless I missed it (reading the documentation) it might be worth to clarify/emphasize in the documentation that get_my_states requires authentication...
The following user(s) said Thank You: schaefer
Powered by Kunena Forum