OpenSky's Open API

An Open Source Ode to OpenSky Network

Recently on this blog, I’ve been testing out new open source strategies (custom scripts, interference swaths, etc). Today, I want to introduce another: how to use OpenSky Network’s extremely open and user-friendly API to track aircraft (including those that may not want to be tracked…) and learn interesting things about their behavior.

Earlier this week, flight tracking guru Steffan Watkins noticed something interesting. A strange aircraft with registration number N9191 popped up several times over the South China Sea during the month of December.

What was it doing there? Something fairly boring like ferrying cargo and personnel? Or something more interesting like keeping an eye on merchant shipping? Or something downright sensitive like tracking Chinese or Russian military activity in one of the world’s most strategic locations?

Popular flight tracking websites like FlightAware or Flightradar24 do not track aircraft like N9191, which means we can’t use these sites to answer our questions or gain any insights from this aircraft’s behavior.

But one site, OpenSky Network, is far more, um, home brewed than the others. It relies on a network of receivers maintained by volunteers and academic and research centers to identify, download, and transmit information from aircraft flying all over the world. Because of the site’s grassroots nature, it does track aircraft like N9191. Even better, it has an extremely open and user-friendly data structure, allowing interested parties to build and use rich tables of historical flight data. This can all be done with an absolute minimum of coding knowledge, meaning neophytes like me can figure it out.

So let’s get back to the military airplane. Using Steffan’s insights, let’s ask the data some questions. First, a simple one. Just how active was N9191 in December?

OpenSky Network’s API documentation shows that we can query the site’s data by individual aircraft. The example query they give (below) is somewhat helpful but, believe it or not, is actually a little too complicated for our purposes.

$ curl -s "https://USERNAME:PASSWORD@opensky-network.org/api/flights/aircraft?icao24=3c675a&begin=1517184000&end=1517270400" | python -m json.tool 

To really simplify things, we really only need the section in quotes:

https://USERNAME:PASSWORD@opensky-network.org/api/flights/aircraft?icao24=3c675a&begin=1517184000&end=1517270400

This query essentially asks OpenSky Network’s database to show us all activity of a certain ICAO number (which is an identification code unique to any particular aircraft) between two times (which are represented by Unix timestamps - machine readable counts of seconds since January 1, 1970).

I signed up for an OpenSky-Network account and added my username and password to the relevant sections in the code. I then added N9191’s ICAO code (acba95 - remember to use lower case!) and used a Unix timestamp converter to find the time stamps for the beginning of December (1606780800) and the current time (1609177181). Here’s the query I came up with:

https://myusername:mypassword@opensky-network.org/api/flights/aircraft?icao24=acba95&begin=1606780800&end=1609177181

I plugged that into a Google Chrome URL bar (yes, it is that easy) and was presented with a colossal table:

While that’s all well and good, the format isn’t exactly the best. To make it look better, I saved the file as a JSON and found an easy JSON to CSV file converter online (you may not want to use that for anything sensitive but it works for our purposes). I converted the file to a CSV and opened it in Google Sheets:

Look at that! We’ve transformed a hunch about a US military aircraft to a table chock full of important information about the aircraft. For instance, during the month of December, N9191 exclusively flew from airports with codes RPLC and RPUF, which correspond to Cesar Basa Air Base and Clark Air Base - both of which are Philippines military installations.

As a quick example to show what we can learn from the data in this table, I added a few columns to convert the weird Unix timestamps to normal, human-readable dates and also calculated the average flight times (based on the average difference between the firstSeen and lastSeen columns):

I found that the aircraft was active on 13 unique days so far in December, with an average flight time of just over 40 minutes. We can use this average flight time to draw a radius in Google Maps and make educated guesses about the aircraft’s range and area of operations.

Let’s assume that on an average trip, the aircraft spends 20 minutes flying out and 20 minutes flying back from either airport and doesn’t stop to refuel. N9191’s cruising speed is 550mph, which means it can travel about 183 miles in the 20 minutes before it turns around. With the aircraft’s maximum recorded flight time (60 minutes - assuming it spends 30 minutes going out and 30 minutes coming back), the aircraft could fly for 275 miles before turning back.

What’s within 275 and 183 miles of either airport the aircraft was recorded flying from? Scarborough Shoal - an extremely strategic pair of rocks near a shoal disputed by the Philippines, China, and Taiwan in the middle of the South China Sea.

Important caveat: these averages do not account for takeoffs and landings from different air bases. In other words, for flights we don’t have a takeoff or landing airport for, N9191 may have extended her range dramatically by flying from, say, Japan to the Philippines, rather than both taking off from and landing at the same airport in the Philippines. Nonetheless, the data pulled from OpenSky Network seems to show that the N9191 aircraft was highly active in Philippine coastal waters, including near the Scarborough Shoal, throughout December.

So what was N9191 doing while flying over the Philippines and South China Sea? Luckily, the US Army itself gave us the answer in an August Facebook post. They confirmed the aircraft was “deployed to U.S. Indo-Pacific Command” to provide “high-altitude sensing capabilities against near peer adversaries” and bridge “gaps in the Multi Domain Operations mission”. Despite the jargon, it sounds like the aircraft basically does reconnaissance against China.

The army also said the plane is “contractor-owned, contractor operated”. The briefest of searches on OpenSky Network and the FAA website shows that N9191’s registered owner is Tenax Aerospace LLC and the aircraft’s operator is Bear Defense.

So there you have it: a tiny bit of plug-and-play coding and OpenSky Network’s API revealed that the US military contracted a pair of companies to operate a reconnaissance aircraft that was active from two military bases in the Philippines to conduct surveillance in the South China Sea. While we obviously don’t know all the details of the aircraft’s range, bases, or surveillance targets, I hope the OpenSky Network method can at least shine some light on certain aircraft where other platforms may be limited.