pyflightdata API documentation

class pyflightdata.flightdata.FlightData(email=None, password=None)

Bases: pyflightdata.common.FlightMixin

FlightData class is the entry point to the API.

This class abstracts the data sources and provides convenient methods to get the various datapoints as JSON lists. At the moment flightradar24 is the only data source.

It is optional to pass in the email and password to login to the site at the time of creating the API object. The login method can be invoked at a later point in the code.

Parameters:
  • email (str) – optional email ID used to login to flightradar24
  • password (str) – password for the user ID

Example:

from pyflightdata import FlightData
f=FlightData()
f.login(myemail,mypassword)
clear_last_request()

The API maintains a simple state that lets you query further into the history of a given flight number or tail number. However this means that when you call multiple flight numbers in a loop, the state needs to be cleared in between. The API attempts to do this on its own, but also provides this method in case a user wants to call it.

Example:

from pyflightdata import FlightData
f=FlightData()
f.get_history_by_flight_number('AI176')
f.clear_last_request()
f.get_history_by_flight_number('AI101')
decode_metar(metar)

Simple method that decodes a given metar string.

Parameters:metar (str) – The metar data
Returns:The metar data in readable format

Example:

from pyflightdata import FlightData
f=FlightData()
f.decode_metar('WSSS 181030Z 04009KT 010V080 9999 FEW018TCU BKN300 29/22 Q1007 NOSIG')
get_airlines()

Returns a list of all the airlines in the world that are known on flightradar24

The return value is a list of dicts, one for each airline, with details like the airline code on flightradar24, call sign, codes etc. The airline code can be used to get the fleet and the flights from flightradar24

get_airport_arrivals(iata, page=1, limit=100, earlier_data=False)

Retrieve the arrivals at an airport

Given the IATA code of an airport, this method returns the arrivals information.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
  • earlier_data (boolean) – Default false, set to true to get data from earlier in time, mimics similar feature on the site
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_arrivals('HYD')
f.get_airport_arrivals('HYD',page=1,limit=10)
get_airport_departures(iata, page=1, limit=100, earlier_data=False)

Retrieve the departures at an airport

Given the IATA code of an airport, this method returns the departures information.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
  • earlier_data (boolean) – Default false, set to true to get data from earlier in time, mimics similar feature on the site
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_departures('HYD')
f.get_airport_departures('HYD',page=1,limit=10)
get_airport_details(iata, page=1, limit=100)

Retrieve the details of an airport

Given the IATA code of an airport, this method returns the detailed information like lat lon, full name, URL, codes etc.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_details('HYD')
f.get_airport_details('HYD',page=1,limit=10)
get_airport_metars(iata, page=1, limit=100)

Retrieve the metar data at the current time

Given the IATA code of an airport, this method returns the metar information.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

The metar data for the airport

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars('HYD')
get_airport_metars_hist(iata)

Retrieve the metar data for past 72 hours. The data will not be parsed to readable format.

Given the IATA code of an airport, this method returns the metar information for last 72 hours.

Parameters:iata (str) – The IATA code for an airport, e.g. HYD
Returns:The metar data for the airport

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_metars_hist('HYD')
get_airport_onground(iata, page=1, limit=100)

Retrieve the aircraft on ground at an airport

Given the IATA code of an airport, this method returns the aircraft on the ground at the airport.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_onground('HYD')
f.get_airport_onground('HYD',page=1,limit=10)
get_airport_reviews(iata, page=1, limit=100)

Retrieve the passenger reviews of an airport

Given the IATA code of an airport, this method returns the passenger reviews of an airport.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_reviews('HYD')
f.get_airport_reviews('HYD',page=1,limit=10)
get_airport_stats(iata, page=1, limit=100)

Retrieve the performance statistics at an airport

Given the IATA code of an airport, this method returns the performance statistics for the airport.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_stats('HYD')
f.get_airport_stats('HYD',page=1,limit=10)
get_airport_weather(iata, page=1, limit=100)

Retrieve the weather at an airport

Given the IATA code of an airport, this method returns the weather information.

Parameters:
  • iata (str) – The IATA code for an airport, e.g. HYD
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_airport_weather('HYD')
f.get_airport_weather('HYD',page=1,limit=10)
get_airports(country)

Returns a list of all the airports For a given country this returns a list of dicts, one for each airport, with information like the iata code of the airport etc

Parameters:country (str) – The country for which the airports will be fetched

Example:

from pyflightdata import FlightData
f=FlightData()
f.get_airports('India')
get_all_available_history_by_flight_number(flight_number, delay=1)

Fetch all the available history of a particular aircraft by its flight number.

This method can be used to get all the available history of a particular aircraft by its flight number. It checks the user authentication and returns the data accordingly.

Parameters:
  • flight_number (str) – The tail number, e.g. VT-ANL
  • delay (int) – Number of seconds delay between each check for new data, defaults to 1 second
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_all_available_history_by_flight_number('6E375',delay=2)
get_all_available_history_by_tail_number(tail_number, delay=1)

Fetch all the available history of a particular aircraft by its tail number.

This method can be used to get all the available history of a particular aircraft by its tail number. It checks the user authentication and returns the data accordingly.

Parameters:
  • tail_number (str) – The tail number, e.g. VT-ANL
  • delay (int) – Number of seconds delay between each check for new data, defaults to 1 second
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_all_available_history_by_tail_number('VT-ANL')
f.get_all_available_history_by_tail_number('VT-ANL',delay=2)
get_countries()

Returns a list of all countries This can be used to get the country name/code as it is known on flightradar24

get_fleet(airline_key)

Get the fleet for a particular airline.

Given a airline code form the get_airlines() method output, this method returns the fleet for the airline.

Parameters:airline_key (str) – The code for the airline on flightradar24
Returns:A list of dicts, one for each aircraft in the airlines fleet
Example::
from pyflightdata import FlightData f=FlightData() #optional login f.login(myemail,mypassword) f.get_fleet(‘ai-aic’)
get_flight_for_date(flight_number, date_str)

Fetch a flight by its number for a given date.

This method can be used to get a flight route by the number for a date. The date should be in the YYYYMMDD format. It checks the user authentication and returns the data accordingly.

Parameters:
  • flight_number (str) – The flight number, e.g. AI101
  • date_str (str) – The date, e.g. 20191116
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_history_by_flight_number('AI101','20191116')
get_flights(search_key)

Get the flights for a particular airline.

Given a full or partial flight number string, this method returns the first 100 flights matching that string.

Please note this method was different in earlier versions. The older versions took an airline code and returned all scheduled flights for that airline

Parameters:search_key (str) – Full or partial flight number for any airline e.g. MI47 to get all SilkAir flights starting with MI47
Returns:A list of dicts, one for each scheduled flight in the airlines network
Example::
from pyflightdata import FlightData f=FlightData() #optional login f.login(myemail,mypassword) f.get_flights(‘MI47’)
get_flights_from_to(origin, destination)

Get the flights for a particular origin and destination.

Given an origin and destination this method returns the upcoming scheduled flights between these two points. The data returned has the airline, airport and schedule information - this is subject to change in future.

Parameters:
  • origin (str) – The origin airport code
  • destination (str) – The destination airport code
Returns:

A list of dicts, one for each scheduled flight between the two points.

Example::
from pyflightdata import FlightData f=FlightData() #optional login f.login(myemail,mypassword) f.get_flights_from_to(‘SIN’,’HYD’)
get_history_by_flight_number(flight_number, page=1, limit=100)

Fetch the history of a flight by its number.

This method can be used to get the history of a flight route by the number. It checks the user authentication and returns the data accordingly.

You need to query page 1 first, and if there are more pages then increment page number until you get 0 results back. Limit has a max value of 100

Parameters:
  • flight_number (str) – The flight number, e.g. AI101
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_history_by_flight_number('AI101')
f.get_history_by_flight_number('AI101',page=1,limit=10)
get_history_by_tail_number(tail_number, page=1, limit=100)

Fetch the history of a particular aircraft by its tail number.

This method can be used to get the history of a particular aircraft by its tail number. It checks the user authentication and returns the data accordingly.

You need to query page 1 first, and if there are more pages then increment page number until you get 0 results back. Limit has a max value of 100

Parameters:
  • tail_number (str) – The tail number, e.g. VT-ANL
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_history_by_tail_number('VT-ANL')
f.get_history_by_tail_number('VT-ANL',page=1,limit=10)
get_images_by_tail_number(tail_number, page=1, limit=100)

Fetch the images of a particular aircraft by its tail number.

This method can be used to get the images of the aircraft. The images are in 3 sizes and you can use what suits your need.

Parameters:
  • tail_number (str) – The tail number, e.g. VT-ANL
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A dict with the images of the aircraft in various sizes

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_images_by_flight_number('VT-ANL')
f.get_images_by_flight_number('VT-ANL',page=1,limit=10)
get_info_by_tail_number(tail_number, page=1, limit=100)

Fetch the details of a particular aircraft by its tail number.

This method can be used to get the details of a particular aircraft by its tail number. Details include the serial number, age etc along with links to the images of the aircraft. It checks the user authentication and returns the data accordingly.

Parameters:
  • tail_number (str) – The tail number, e.g. VT-ANL
  • page (int) – Optional page number; for users who are on a plan with flightradar24 they can pass in higher page numbers to get more data
  • limit (int) – Optional limit on number of records returned
Returns:

A list of dicts with the data; one dict for each row of data from flightradar24

Example:

from pyflightdata import FlightData
f=FlightData()
#optional login
f.login(myemail,mypassword)
f.get_info_by_flight_number('VT-ANL')
f.get_info_by_flight_number('VT-ANL',page=1,limit=10)
is_authenticated()

Simple method to check if the user is authenticated to flightradar24

login(email, password)

Login to the flightradar24 session

The API currently uses flightradar24 as the primary data source. The site provides different levels of data based on user plans. For users who have signed up for a plan, this method allows to login with the credentials from flightradar24. The API obtains a token that will be passed on all the requests; this obtains the data as per the plan limits.

Parameters:
  • email (str) – The email ID which is used to login to flightradar24
  • password (str) – The password for the user ID

Example:

from pyflightdata import FlightData
f=FlightData()
f.login(myemail,mypassword)
logout()

Logout from the flightradar24 session.

This will reset the user token that was retrieved earlier; the API will return data visible to unauthenticated users