How to access aircraft information?

The traffic library provides access to the OpenSky aircraft database by default.

Keeping a legal up to date version of such a database being an arduous task, traffic lets you easily switch database to a file you would be able to provide.

class traffic.data.basic.aircraft.Aircraft(data=None)

By default, the OpenSky aircraft database is downloaded from https://opensky-network.org/aircraft-database

>>> from traffic.data import aircraft

The database can be manually downloaded or upgraded (the operation can take up to five minutes with a slow Internet connection), with download_opensky()

Basic requests can be made by the bracket notation, they return a subset of the database, even if the result is unique

>>> aircraft["F-GFKY"]  
  icao24   registration   typecode   model             operator     owner
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  391558   F-GFKY         A320       Airbus A320 211   Air France   Air France
>>> aircraft["391558"]  
  icao24   registration   typecode   model             operator   owner
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  391558   F-GFKY         A320       Airbus A320 211   Air France   Air France

Only get() returns a Tail object.

>>> aircraft.get("F-GFKY")
Tail(icao24='391558', registration='F-GFKY', typecode='A320', flag='🇫🇷')

Tip

Different custom databases may also be used as a replacement if you provide a path in the configuration file.

You may set the path to any file that pandas can open (.csv, .pickle, etc.).
Required columns for the library are:
  • icao24: the hexadecimal transponder identifier

  • registration: the tail number of the aircraft

  • typecode: the short identifier for the type of aircraft

  • model: the full name of the aircraft

For example, you may download and uncompress Junzi’s deprecated database from https://junzis.com/adb/ then edit the configuration file:

[aircraft]

database = /home/xo/Downloads/aircraft_db/aircraft_db.csv

icao24 = icao
registration = regid
typecode = mdl
model = type
download_opensky()

Downloads the latest version of the OpenSky aircraft database.

Reference: https://opensky-network.org/aircraft-database

Return type:

None

get(name)

Returns information about an aircraft based on its icao24 or registration information as a dictionary. Only the first aircraft matching the pattern passed in parameter is returned.

Country information are based on the icao24 identifier, category information are based on the registration information.

Parameters:

name (str) – the icao24 identifier or the tail number of the aircraft

Return type:

None | Tail

>>> from traffic.data import aircraft
>>> aircraft.get("F-GFKY")
Tail(icao24='391558', registration='F-GFKY', typecode='A320', flag='🇫🇷')
model(name)

Requests an aircraft by model or typecode (fuzzy match).

Parameters:

name (str) – the model or the typecode of the aircraft

Return type:

Optional[TypeVar(T, bound= Aircraft)]

>>> aircraft.model("A320")  
  icao24   registration   typecode   model         operator   owner
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  38005a   F-WWBA         A320       Airbus A320   Airbus     Airbus
  38009a   F-WWDA         A20N       Airbus A320   Airbus     Airbus
  38019a   F-WWIA         A20N       Airbus A320   Airbus     Airbus
  3801ba   F-WWIB         A20N       Airbus A320   Airbus     Airbus
  3801da   F-WWIC         A20N       Airbus A320   Airbus     Airbus
  3801fa   F-WWID         A20N       Airbus A320   Airbus     Airbus
  380d5a   F-WWBB         A20N       Airbus A320   Airbus     Airbus
  380d7a   F-WWBC         A20N       Airbus A320   Airbus     Airbus
  380d9a   F-WWBD         A20N       Airbus A320   Airbus     Airbus
  380dba   F-WWBF         A20N       Airbus A320   Airbus     Airbus
  ... (7021 more entries)
operator(name)

Requests an aircraft by owner or operator (fuzzy match).

Parameters:

name (str) – the owner or operator of the aircraft

Return type:

Optional[TypeVar(T, bound= Aircraft)]

>>> aircraft.operator("British Antarctic")  
  icao24   registration   typecode   model   operator
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  4241f4   VP-FBB         DHC6               British Antarctic Survey
  4241f5   VP-FBL         DHC6               British Antarctic Survey
  4241f6   VP-FAZ         DHC6               British Antarctic Survey
  43be5b   VP-FBQ         DHC7               British Antarctic Survey
query(query_str='', *args, **kwargs)

Combines several requests.

Parameters:
  • query_str (str) – (default: empty) if non empty, is passed to the query() method

  • kwargs (Any) – all keyword arguments correspond to the name of other methods which are chained if query_str is non empty

Return type:

Optional[TypeVar(T, bound= Aircraft)]

>>> aircraft.query(registration="^F-ZB", model="EC45")  
  icao24   registration   typecode   model                     operator
 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  3b780f   F-ZBQB         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b49   F-ZBQL         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b4a   F-ZBQK         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b50   F-ZBQI         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b51   F-ZBQH         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b52   F-ZBQG         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b8b   F-ZBQF         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b8c   F-ZBQF         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b8d   F-ZBQD         EC45       Airbus Helicopters H145   French Securite Civile
  3b7b8e   F-ZBQC         EC45       Airbus Helicopters H145   French Securite Civile
  ... (19 more entries)
registration(name)

Requests an aircraft by registration (fuzzy match).

Parameters:

name (str) – the tail number of the aircraft

Return type:

Optional[TypeVar(T, bound= Aircraft)]

stats(name)

Computes stats of owned or operated aircraft (fuzzy match).

Parameters:

name (str) – the owner or operator of the aircraft

Return type:

None | DataFrame

>>> aircraft.stats("Air France")  
                            model  icao24
typecode
A318              Airbus A318-111      16
A319              Airbus A319-113      37
A320              Airbus A320-214      48
A321              Airbus A321-212      20
A332              Airbus A330-203      15
...