ADS-B Exchange!

Despite some turbulence within the ADS-B Exchange community after their API policy change, owner James Stanford kindly sent me a key for the new REST API 🙂

In exchange for feeding ADSBx, non-commercial users may use the API for free. Your key needs to be included in the header of each (https) API request.

The following code is at the top of my new What’s Up? sketch for monitoring all aircraft within a distance of 25 nautical miles from my location (latitude- and longitude filters have not (yet) been implemented in the new API, so they need to be applied on the query results programmatically).

Then, inside loop(), I create an instance of WiFiClientSecure and send the API request over https, including my API key in the header:

The json response can now be processed as usual by reading from the stream ‘client’. Although the key names of the new API differ from the old ones, I didn’t have to make any changes to the json streaming parser that I wrote for earlier ADS-B projects because it takes these names from a global array that now looks like:

Some keys from the old API do not (yet) have an equivalent in the new json response. As a temporary solution, I now host a local API on my webserver, returning aircraft model and flight operator for an icao or opicao code. It’s powered by a MySQL database, imported from json files found at https://github.com/Mictronics/readsb.

A further change in the new json reponse forced me to rewrite my function for character decoding. The new API uses Unicode code points instead of multi-byte utf-8 for encoding special characters. When using GFX-based graphic libraries, these need to be converted to Extended Ascii Code page 850 (“Latin-1”), or to ‘romanized’ cyrillic characters.

It all works OK, although responses from the new ADBSx API show more drop outs then before. Also, jumps between consecutive position updates seem larger, making the so arduously conquered flicker free icon movements less striking.

I expect to post a video of my new (and hopefully final) ESP32 version of What’s Up? in one of the next posts. In order to use the code, you’ll either have to be (or become) an ADSBx feeder, or buy a key. I went for the first option (with two feeders) and made a donation as well, despite my strong aversion to PayPal.