openskynetwork / opensky-api

Python and Java bindings for the OpenSky Network REST API
GNU General Public License v3.0
345 stars 126 forks source link

state vector REST returns extra field #42

Closed espinielli closed 1 year ago

espinielli commented 2 years ago

The states returned by the REST API for state vector contain 18 fields instead of 17 as stated in the documentation [1], see table below, or in the (Python) code [2].

Screen Shot 2022-01-31 at 18 11 05

(Also FLARM value in position_source in the source [2] is not reflected in the online documentation [1]...which probably needs to be refreshed/republished)

[1] https://opensky-network.org/apidoc/rest.html#response [2] https://github.com/openskynetwork/opensky-api/blob/master/python/opensky_api.py#L37-L56

I executed the following request:

$ curl -k "https://opensky-network.org/api/states/all?lomin=17.893604&lamin=59.62179&lomax=17.989391&lamax=59.671582"

which returned (Note that each state contains 18 fields):

{
    "time": 1643648227,
    "states": [
        [
            "3c65d7",
            "DLH5HR  ",
            "Germany",
            1643647989,
            1643647996,
            17.9293,
            59.6533,
            null,
            true,
            0.51,
            101.25,
            null,
            null,
            null,
            "5201",
            false,
            0,
            0
        ],
        [
            "4aca0a",
            "NSZ15S  ",
            "Sweden",
            1643648197,
            1643648213,
            17.9281,
            59.6497,
            7795.26,
            false,
            0,
            354.38,
            null,
            null,
            null,
            null,
            false,
            0,
            0
        ],
        [
            "4aca50",
            "NSZ3212 ",
            "Sweden",
            1643648226,
            1643648226,
            17.9223,
            59.6533,
            null,
            true,
            3.6,
            109.69,
            null,
            null,
            null,
            "0422",
            false,
            0,
            0
        ],
        [
            "484559",
            "KLM82W  ",
            "Kingdom of the Netherlands",
            1643648225,
            1643648226,
            17.9286,
            59.6422,
            null,
            true,
            4.37,
            163.12,
            null,
            null,
            null,
            "3513",
            false,
            0,
            1
        ],
        [
            "4bb287",
            "THY6RK  ",
            "Turkey",
            1643647940,
            1643647949,
            17.9351,
            59.6548,
            106.68,
            true,
            0,
            75.94,
            null,
            null,
            null,
            "5357",
            false,
            0,
            0
        ],
        [
            "4afb7a",
            "AVI2    ",
            "Sweden",
            1643648130,
            1643648130,
            17.9542,
            59.6579,
            null,
            true,
            4.37,
            165.94,
            null,
            null,
            null,
            null,
            false,
            0,
            0
        ],
        [
            "47a185",
            "NOZ820  ",
            "Norway",
            1643647935,
            1643647935,
            17.926,
            59.6505,
            99.06,
            false,
            0,
            0,
            0,
            null,
            53.34,
            "0243",
            false,
            0,
            0
        ],
        [
            "48c232",
            "RYR467E ",
            "Poland",
            1643648213,
            1643648225,
            17.9268,
            59.6505,
            null,
            true,
            0,
            11.25,
            null,
            null,
            null,
            "2000",
            false,
            0,
            0
        ]
    ]
}
espinielli commented 2 years ago

In fact if you are authenticated you do not get the extra last field in each state vector record.

For example:

$ curl -k -u "$OPENSKY_USERNAME:$OPENSKY_PASSWORD" \
   "https://opensky-network.org/api/states/all?lomin=17.893604&lamin=59.62179&lomax=17.989391&lamax=59.671582"
{
    "time": 1643708306,
    "states": [
        [
            "5001ac",
            "VAJ91B  ",
            "San Marino",
            1643708306,
            1643708306,
            17.925,
            59.6559,
            null,
            true,
            5.66,
            163.12,
            null,
            null,
            null,
            "1145",
            false,
            0
        ],
        [
            "4afbb0",
            "BRV3    ",
            "Sweden",
            1643708305,
            1643708305,
            17.9473,
            59.6599,
            null,
            true,
            11.32,
            255.94,
            null,
            null,
            null,
            null,
            false,
            0
        ],
        [
            "4afb8a",
            "BRV 4   ",
            "Sweden",
            1643708305,
            1643708305,
            17.9472,
            59.6598,
            null,
            true,
            11.32,
            255.94,
            null,
            null,
            null,
            null,
            false,
            0
        ],
        [
            "4afb03",
            "139     ",
            "Sweden",
            1643708305,
            1643708305,
            17.9303,
            59.6558,
            null,
            true,
            12.86,
            253.12,
            null,
            null,
            null,
            null,
            false,
            0
        ]
    ]
}

I would suggest to document the behaviour or make the payload, state vector, the same in both cases. (my preference goes to the latter where the state vector payload stays at the same number of fields)

masorx commented 2 years ago

We did some changes on this a while ago; is this consistent now with your expectations?

jaluebbe commented 1 year ago

I just created a pull request for an updated version of the Python API. The magic seems to be in the request parameter "extended=true".

espinielli commented 1 year ago
curl -k -u "$OPENSKY_USERNAME:$OPENSKY_PASSWORD" \
   "https://opensky-network.org/api/states/all?lomin=17.893604&lamin=59.62179&lomax=17.989391&lamax=59.671582"

Yes. Well done. BUT just by querying for a while I only see 0 values for category (field 17)...is it really computed in the LIVE API?

jaluebbe commented 1 year ago

II just tried repeatedly curl -k -u "$OPENSKY_USERNAME:$OPENSKY_PASSWORD" \ "https://opensky-network.org/api/states/all?extended=true&lomin=17.893604&lamin=59.62179&lomax=17.989391&lamax=59.671582" I see the non zero category sometimes for some aircraft. When I tried it on all states without filter, I found some 3, 4 and 6 besides a lot of zeros.

The responses the above query were: {"time":1671882206,"states":[["4b1806","SWR7ZP ","Switzerland",1671882203,1671882205,17.9293,59.6533,null,true,0,101.25,null,null,null,null,false,0,0],["4b1808","SWR5139 ","Switzerland",1671882197,1671882202,17.9314,59.6537,null,true,0,219.38,null,null,null,null,false,0,0],["885104","THA961 ","Thailand",1671882198,1671882204,17.9361,59.6529,null,true,0,101.25,null,null,null,null,false,0,0]]} {"time":1671882218,"states":[["4b1806","SWR7ZP ","Switzerland",1671882214,1671882218,17.9293,59.6533,null,true,0,101.25,null,null,null,null,false,0,0],["4b1808","SWR5139 ","Switzerland",1671882208,1671882218,17.9314,59.6537,null,true,0,219.38,null,null,null,null,false,0,0],["885104","THA961 ","Thailand",1671882198,1671882216,17.9361,59.6529,null,true,0,101.25,null,null,null,null,false,0,6]]} {"time":1671882384,"states":[["4b1806","SWR7ZP ","Switzerland",1671882382,1671882382,17.9293,59.6533,null,true,0,101.25,null,null,null,null,false,0,0],["4b1808","SWR5139 ","Switzerland",1671882382,1671882382,17.9314,59.6537,null,true,0,219.38,null,null,null,null,false,0,0],["885104","THA961 ","Thailand",1671882358,1671882358,17.9361,59.6529,null,true,0,101.25,null,null,null,null,false,0,6]]}

espinielli commented 1 year ago

Great. Thanks Jannis for testing further