Skip to main content

Flightradar client library.

Project description

python-flightradar-client

Build Status codecov PyPi Version

This library provides convenient access to a local Flightradar24 feed.

Installation

pip install flightradar-client

Usage

This library currently support two different flavour of flight data, provided by the fr24feed and dump1090-mutability services that are automatically installed when building your own Pi24 ADS-B receiver.

For each flavour the library provides two modes of access. The *Feed class fetches data once when calling update and transforms it into FeedEntry objects. The *FeedAggregator class keeps a bit of history and with each subsequent update call it tries to fill in any gaps (coordinates and callsign at the moment) missing in the latest data set fetched.

Flightradar Feed

The Flightradar Feed mode uses the JSON data made available by the fr24feed service (normally under http://localhost:8754/flights.json).

FlightradarFlightsFeed and FlightradarFlightsFeedAggregator support the same parameters:

Name Type Description
home_coordinates required, tuple of latitude and longitude Used to calculate the distance to each aircraft.
websession required, a aiohttp.ClientSession() session for retrieving data
filter_radius optional, float value in kilometres, default: don't filter by distance Only aircrafts within this radius around the home coordinates are included in the result set.
url optional, full url to access the Pi24 ADS-B receiver JSON, default: construct with hostname and port Define if you have customised access to Pi24 ADS-B receiver or use HTTPS for example.
hostname optional, hostname of the Pi24 ADS-B receiver, default: localhost Define if you are not running this library on your Pi24 ADS-B receiver.
port optional, port of the Pi24 ADS-B receiver's flights service, default: 8754 Define if you have configured a different port on your Pi24 ADS-B receiver.

Feed

import asyncio
from aiohttp import ClientSession
from flightradar_client.fr24feed_flights import FlightradarFlightsFeed
async def main() -> None:
    async with ClientSession() as websession:
        # Home Coordinates: Latitude: -33.5, Longitude: 151.5
        feed = FlightradarFlightsFeed((-33.5, 151.5), websession)
        status, entries = await feed.update()
        print(status)
        print(entries)
asyncio.get_event_loop().run_until_complete(main())

Feed Aggregator

import asyncio
from aiohttp import ClientSession
from flightradar_client.fr24feed_flights import FlightradarFlightsFeedAggregator
async def main() -> None:
    async with ClientSession() as websession:
        # Home Coordinates: Latitude: -33.5, Longitude: 151.5
        feed = FlightradarFlightsFeedAggregator((-33.5, 151.5), websession)
        status, entries = await feed.update()
        print(status)
        print(entries)
asyncio.get_event_loop().run_until_complete(main())

Dump1090 Feed

The Dump1090 Feed mode uses the JSON data made available by the dump1090-mutability service (normally under http://localhost:8888/data/aircraft.json).

Dump1090AircraftsFeed and Dump1090AircraftsFeedAggregator support the same parameters:

Name Type Description
home_coordinates required, tuple of latitude and longitude Used to calculate the distance to each aircraft.
websession required, a aiohttp.ClientSession() session for retrieving data
filter_radius optional, float value in kilometres, default: don't filter by distance Only aircrafts within this radius around the home coordinates are included in the result set.
url optional, full url to access the Pi24 ADS-B receiver JSON, default: construct with hostname and port Define if you have customised access to Pi24 ADS-B receiver or use HTTPS for example.
hostname optional, hostname of the Pi24 ADS-B receiver, default: localhost Define if you are not running this library on your Pi24 ADS-B receiver.
port optional, port of the Pi24 ADS-B receiver's dump1090 service, default: 8888 Define if you have configured a different port on your Pi24 ADS-B receiver.

Feed

import asyncio
from aiohttp import ClientSession
from flightradar_client.dump1090_aircrafts import Dump1090AircraftsFeed
async def main() -> None:
    async with ClientSession() as websession:
        # Home Coordinates: Latitude: -33.5, Longitude: 151.5
        feed = Dump1090AircraftsFeed((-33.5, 151.5), websession)
        status, entries = await feed.update()
        print(status)
        print(entries)
asyncio.get_event_loop().run_until_complete(main())

Feed Aggregator

import asyncio
from aiohttp import ClientSession
from flightradar_client.dump1090_aircrafts import Dump1090AircraftsFeedAggregator
async def main() -> None:
    async with ClientSession() as websession:
        # Home Coordinates: Latitude: -33.5, Longitude: 151.5
        feed = Dump1090AircraftsFeedAggregator((-33.5, 151.5), websession)
        status, entries = await feed.update()
        print(status)
        print(entries)
asyncio.get_event_loop().run_until_complete(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flightradar_client-0.9.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

flightradar_client-0.9-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file flightradar_client-0.9.tar.gz.

File metadata

  • Download URL: flightradar_client-0.9.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.6

File hashes

Hashes for flightradar_client-0.9.tar.gz
Algorithm Hash digest
SHA256 b39bea55c1e815f1aff8d2cd6ac2dc4ed2bb5337ccafdc537b18a47499701a3d
MD5 0f31397e6a58030bc6b6c54f342111aa
BLAKE2b-256 d35e6126b05973b745edfb77c3dee8b3ce914d7ff4aa91e12e7a0f441cf5f20d

See more details on using hashes here.

File details

Details for the file flightradar_client-0.9-py3-none-any.whl.

File metadata

  • Download URL: flightradar_client-0.9-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.6

File hashes

Hashes for flightradar_client-0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 f5663964e038d0f3cda9a2a7cefe3597f2d49a01589d6c93866e3817dbc9376d
MD5 8818ed7fb6c9d3eb4536b4b6ef4a9367
BLAKE2b-256 df9c9d0de5b7362f2619300e3d8b5e5395517fc86a64301761f51a0cd376de4d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page