FlightRadarAPI 1.3.25__tar.gz → 1.3.26__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,3 +5,4 @@ dist
5
5
  .idea/
6
6
  venv/
7
7
  node_modules/
8
+ .env
@@ -13,7 +13,7 @@ https://www.flightradar24.com/terms-and-conditions
13
13
  """
14
14
 
15
15
  __author__ = "Jean Loui Bernard Silva de Jesus"
16
- __version__ = "1.3.25"
16
+ __version__ = "1.3.26"
17
17
 
18
18
  from .api import FlightRadar24API, FlightTrackerConfig
19
19
  from .entities import Airport, Entity, Flight
@@ -333,6 +333,30 @@ class FlightRadar24API(object):
333
333
  """
334
334
  return dataclasses.replace(self.__flight_tracker_config)
335
335
 
336
+ def get_history_data(self, flight: Flight, file_type: str, timestamp: int) -> Dict:
337
+ """
338
+ Download historical data of a flight.
339
+
340
+ :param flight: A Flight instance
341
+ :param file_type: Must be "CSV" or "KML"
342
+ :param timestamp: A Unix timestamp
343
+ """
344
+ if not self.is_logged_in():
345
+ raise LoginError("You must log in to your account.")
346
+
347
+ file_type = file_type.lower()
348
+
349
+ if file_type not in ["csv", "kml"]:
350
+ raise ValueError(f"File type '{file_type}' is not supported. Only CSV and KML are supported.")
351
+
352
+ response = APIRequest(
353
+ Core.historical_data_url.format(flight.id, file_type, timestamp),
354
+ headers=Core.json_headers, cookies=self.__login_data["cookies"],
355
+ )
356
+
357
+ content = response.get_content()
358
+ return str(content.decode("utf-8"))
359
+
336
360
  def get_login_data(self) -> Dict[Any, Any]:
337
361
  """
338
362
  Return the user data.
@@ -23,6 +23,9 @@ class Core(ABC):
23
23
  real_time_flight_tracker_data_url = data_cloud_base_url + "/zones/fcgi/feed.js"
24
24
  flight_data_url = data_live_base_url + "/clickhandler/?flight={}"
25
25
 
26
+ # Historical data URL.
27
+ historical_data_url = flightradar_base_url + "/download/?flight={}&file={}&trailLimit=0&history={}"
28
+
26
29
  # Airports data URLs.
27
30
  api_airport_data_url = api_flightradar_base_url + "/airport.json"
28
31
  airport_data_url = flightradar_base_url + "/airports/traffic-stats/?airport={}"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: FlightRadarAPI
3
- Version: 1.3.25
3
+ Version: 1.3.26
4
4
  Summary: SDK for FlightRadar24
5
5
  Project-URL: Homepage, https://github.com/JeanExtreme002/FlightRadarAPI
6
6
  Author-email: Jean Loui Bernard Silva de Jesus <jeanextreme002@gmail.com>
@@ -32,7 +32,8 @@ See more information at: https://www.flightradar24.com/terms-and-conditions
32
32
  [![License](https://img.shields.io/pypi/l/FlightRadarAPI)](https://github.com/JeanExtreme002/FlightRadarAPI)
33
33
  [![Python Version](https://img.shields.io/badge/python-3.7+-8A2BE2)](https://pypi.org/project/FlightRadarAPI/)
34
34
  [![Npm](https://img.shields.io/npm/v/flightradarapi?logo=npm&color=red)](https://www.npmjs.com/package/flightradarapi)
35
- [![Downloads](https://static.pepy.tech/personalized-badge/flightradarapi?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/FlightRadarAPI/)
35
+ [![downloads](https://static.pepy.tech/personalized-badge/flightradarapi?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/FlightRadarAPI/)
36
+ [![Frequency](https://img.shields.io/pypi/dm/flightradarapi?style=flat&label=frequency)](https://pypi.org/project/FlightRadarAPI/)
36
37
 
37
38
  ## Installing FlightRadarAPI:
38
39
  ```
@@ -126,6 +127,20 @@ distance = flight.get_distance_from(airport)
126
127
  print(f"The flight is {distance} km away from the airport.")
127
128
  ```
128
129
 
130
+ ## Downloading Flight Data
131
+ *Note*: This requires a premium subscription and for you to be logged in.
132
+
133
+ ```py
134
+ history_data = fr_api.get_history_data(flight, file_type="csv", time=1706529600)
135
+
136
+ with open("history_data.csv", "w") as file:
137
+ file.write(history_data)
138
+ ```
139
+
140
+ `flight_id` - The ID of the flight. Can be gotten from any other function that returns flight details.
141
+ `file_type` - Either CSV or KML.
142
+ `time` - The STD/scheduled time of deperature in UTC of the flight as a Unix timestamp. Putting an invalid time will return a blank document.
143
+
129
144
  ## Setting and getting Real-time Flight Tracker parameters:
130
145
  Set it by using the `set_flight_tracker_config(...)` method. It receives a `FlightTrackerConfig` dataclass instance, but
131
146
  you can also use keyword arguments directly to the method.
@@ -9,7 +9,8 @@ See more information at: https://www.flightradar24.com/terms-and-conditions
9
9
  [![License](https://img.shields.io/pypi/l/FlightRadarAPI)](https://github.com/JeanExtreme002/FlightRadarAPI)
10
10
  [![Python Version](https://img.shields.io/badge/python-3.7+-8A2BE2)](https://pypi.org/project/FlightRadarAPI/)
11
11
  [![Npm](https://img.shields.io/npm/v/flightradarapi?logo=npm&color=red)](https://www.npmjs.com/package/flightradarapi)
12
- [![Downloads](https://static.pepy.tech/personalized-badge/flightradarapi?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/FlightRadarAPI/)
12
+ [![downloads](https://static.pepy.tech/personalized-badge/flightradarapi?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads)](https://pypi.org/project/FlightRadarAPI/)
13
+ [![Frequency](https://img.shields.io/pypi/dm/flightradarapi?style=flat&label=frequency)](https://pypi.org/project/FlightRadarAPI/)
13
14
 
14
15
  ## Installing FlightRadarAPI:
15
16
  ```
@@ -103,6 +104,20 @@ distance = flight.get_distance_from(airport)
103
104
  print(f"The flight is {distance} km away from the airport.")
104
105
  ```
105
106
 
107
+ ## Downloading Flight Data
108
+ *Note*: This requires a premium subscription and for you to be logged in.
109
+
110
+ ```py
111
+ history_data = fr_api.get_history_data(flight, file_type="csv", time=1706529600)
112
+
113
+ with open("history_data.csv", "w") as file:
114
+ file.write(history_data)
115
+ ```
116
+
117
+ `flight_id` - The ID of the flight. Can be gotten from any other function that returns flight details.
118
+ `file_type` - Either CSV or KML.
119
+ `time` - The STD/scheduled time of deperature in UTC of the flight as a Unix timestamp. Putting an invalid time will return a blank document.
120
+
106
121
  ## Setting and getting Real-time Flight Tracker parameters:
107
122
  Set it by using the `set_flight_tracker_config(...)` method. It receives a `FlightTrackerConfig` dataclass instance, but
108
123
  you can also use keyword arguments directly to the method.
@@ -17,7 +17,7 @@ classifiers = [
17
17
  "Programming Language :: Python :: 3.10",
18
18
  "Programming Language :: Python :: 3.11"
19
19
  ]
20
- exclude = ["tests"]
20
+ exclude = ["tests", ".flake8"]
21
21
  requires-python = ">=3.7"
22
22
  dependencies = [
23
23
  "Brotli",
File without changes
File without changes