FlightRadarAPI 1.3.24__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.
- flightradarapi-1.3.26/.flake8 +11 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/.gitignore +1 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/__init__.py +1 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/api.py +50 -26
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/core.py +3 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/entities/airport.py +5 -5
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/entities/entity.py +1 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/entities/flight.py +5 -5
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/errors.py +1 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/request.py +3 -3
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/PKG-INFO +18 -3
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/README.md +16 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/pyproject.toml +1 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/tests/package.py +2 -1
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/tests/test_api.py +14 -14
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/FlightRadar24/entities/__init__.py +0 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/LICENSE +0 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/requirements.txt +0 -0
- {flightradarapi-1.3.24 → flightradarapi-1.3.26}/tests/util.py +0 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[flake8]
|
|
2
|
+
|
|
3
|
+
max-line-length = 130
|
|
4
|
+
ignore = W503, E701, E722
|
|
5
|
+
|
|
6
|
+
per-file-ignores =
|
|
7
|
+
# __init__.py files are allowed to have unused imports and lines-too-long
|
|
8
|
+
*/__init__.py:F401
|
|
9
|
+
|
|
10
|
+
# Unused imports are allowed in the tests/package.py module and they must come after setting the current working directory.
|
|
11
|
+
tests/package.py:F401, E402
|
|
@@ -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.
|
|
16
|
+
__version__ = "1.3.26"
|
|
17
17
|
|
|
18
18
|
from .api import FlightRadar24API, FlightTrackerConfig
|
|
19
19
|
from .entities import Airport, Entity, Flight
|
|
@@ -54,7 +54,7 @@ class FlightRadar24API(object):
|
|
|
54
54
|
"""
|
|
55
55
|
Return a list with all airlines.
|
|
56
56
|
"""
|
|
57
|
-
response = APIRequest(Core.airlines_data_url, headers
|
|
57
|
+
response = APIRequest(Core.airlines_data_url, headers=Core.json_headers)
|
|
58
58
|
return response.get_content()["rows"]
|
|
59
59
|
|
|
60
60
|
def get_airline_logo(self, iata: str, icao: str) -> Optional[Tuple[bytes, str]]:
|
|
@@ -62,11 +62,11 @@ class FlightRadar24API(object):
|
|
|
62
62
|
Download the logo of an airline from FlightRadar24 and return it as bytes.
|
|
63
63
|
"""
|
|
64
64
|
iata, icao = iata.upper(), icao.upper()
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
first_logo_url = Core.airline_logo_url.format(iata, icao)
|
|
67
67
|
|
|
68
68
|
# Try to get the image by the first URL option.
|
|
69
|
-
response = APIRequest(first_logo_url, headers
|
|
69
|
+
response = APIRequest(first_logo_url, headers=Core.image_headers, exclude_status_codes=[403,])
|
|
70
70
|
status_code = response.get_status_code()
|
|
71
71
|
|
|
72
72
|
if not str(status_code).startswith("4"):
|
|
@@ -75,7 +75,7 @@ class FlightRadar24API(object):
|
|
|
75
75
|
# Get the image by the second airline logo URL.
|
|
76
76
|
second_logo_url = Core.alternative_airline_logo_url.format(icao)
|
|
77
77
|
|
|
78
|
-
response = APIRequest(second_logo_url, headers
|
|
78
|
+
response = APIRequest(second_logo_url, headers=Core.image_headers)
|
|
79
79
|
status_code = response.get_status_code()
|
|
80
80
|
|
|
81
81
|
if not str(status_code).startswith("4"):
|
|
@@ -90,7 +90,7 @@ class FlightRadar24API(object):
|
|
|
90
90
|
"""
|
|
91
91
|
if 4 < len(code) or len(code) < 3:
|
|
92
92
|
raise ValueError(f"The code '{code}' is invalid. It must be the IATA or ICAO of the airport.")
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
if details:
|
|
95
95
|
airport = Airport()
|
|
96
96
|
|
|
@@ -99,13 +99,13 @@ class FlightRadar24API(object):
|
|
|
99
99
|
|
|
100
100
|
return airport
|
|
101
101
|
|
|
102
|
-
response = APIRequest(Core.airport_data_url.format(code), headers
|
|
102
|
+
response = APIRequest(Core.airport_data_url.format(code), headers=Core.json_headers)
|
|
103
103
|
content = response.get_content()
|
|
104
|
-
|
|
104
|
+
|
|
105
105
|
if not content or not isinstance(content, dict) or not content.get("details"):
|
|
106
106
|
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
107
107
|
|
|
108
|
-
return Airport(info
|
|
108
|
+
return Airport(info=content["details"])
|
|
109
109
|
|
|
110
110
|
def get_airport_details(self, code: str, flight_limit: int = 100, page: int = 1) -> Dict:
|
|
111
111
|
"""
|
|
@@ -138,16 +138,16 @@ class FlightRadar24API(object):
|
|
|
138
138
|
if errors.get("limit"):
|
|
139
139
|
raise ValueError(errors["limit"]["notBetween"])
|
|
140
140
|
|
|
141
|
-
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.", errors)
|
|
142
|
-
|
|
141
|
+
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.", errors)
|
|
142
|
+
|
|
143
143
|
result = content["result"]["response"]
|
|
144
144
|
|
|
145
145
|
# Check whether it received data of an airport.
|
|
146
146
|
data = result.get("airport", dict()).get("pluginData", dict())
|
|
147
147
|
|
|
148
|
-
if
|
|
149
|
-
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
150
|
-
|
|
148
|
+
if "details" not in data and len(data.get("runways", [])) == 0 and len(data) <= 3:
|
|
149
|
+
raise AirportNotFoundError(f"Could not find an airport by the code '{code}'.")
|
|
150
|
+
|
|
151
151
|
# Return the airport details.
|
|
152
152
|
return result
|
|
153
153
|
|
|
@@ -155,19 +155,19 @@ class FlightRadar24API(object):
|
|
|
155
155
|
"""
|
|
156
156
|
Return airport disruptions.
|
|
157
157
|
"""
|
|
158
|
-
response = APIRequest(Core.airport_disruptions_url, headers
|
|
158
|
+
response = APIRequest(Core.airport_disruptions_url, headers=Core.json_headers)
|
|
159
159
|
return response.get_content()
|
|
160
160
|
|
|
161
161
|
def get_airports(self) -> List[Airport]:
|
|
162
162
|
"""
|
|
163
163
|
Return a list with all airports.
|
|
164
164
|
"""
|
|
165
|
-
response = APIRequest(Core.airports_data_url, headers
|
|
165
|
+
response = APIRequest(Core.airports_data_url, headers=Core.json_headers)
|
|
166
166
|
|
|
167
167
|
airports: List[Airport] = list()
|
|
168
168
|
|
|
169
169
|
for airport_data in response.get_content()["rows"]:
|
|
170
|
-
airport = Airport(basic_info
|
|
170
|
+
airport = Airport(basic_info=airport_data)
|
|
171
171
|
airports.append(airport)
|
|
172
172
|
|
|
173
173
|
return airports
|
|
@@ -184,7 +184,7 @@ class FlightRadar24API(object):
|
|
|
184
184
|
|
|
185
185
|
cookies = self.__login_data["cookies"]
|
|
186
186
|
|
|
187
|
-
response = APIRequest(Core.bookmarks_url, headers
|
|
187
|
+
response = APIRequest(Core.bookmarks_url, headers=headers, cookies=cookies)
|
|
188
188
|
return response.get_content()
|
|
189
189
|
|
|
190
190
|
def get_bounds(self, zone: Dict[str, float]) -> str:
|
|
@@ -257,11 +257,11 @@ class FlightRadar24API(object):
|
|
|
257
257
|
"""
|
|
258
258
|
flag_url = Core.country_flag_url.format(country.lower().replace(" ", "-"))
|
|
259
259
|
headers = Core.image_headers.copy()
|
|
260
|
-
|
|
260
|
+
|
|
261
261
|
if "origin" in headers:
|
|
262
262
|
headers.pop("origin") # Does not work for this request.
|
|
263
263
|
|
|
264
|
-
response = APIRequest(flag_url, headers
|
|
264
|
+
response = APIRequest(flag_url, headers=headers)
|
|
265
265
|
status_code = response.get_status_code()
|
|
266
266
|
|
|
267
267
|
if not str(status_code).startswith("4"):
|
|
@@ -273,7 +273,7 @@ class FlightRadar24API(object):
|
|
|
273
273
|
|
|
274
274
|
:param flight: A Flight instance
|
|
275
275
|
"""
|
|
276
|
-
response = APIRequest(Core.flight_data_url.format(flight.id), headers
|
|
276
|
+
response = APIRequest(Core.flight_data_url.format(flight.id), headers=Core.json_headers)
|
|
277
277
|
return response.get_content()
|
|
278
278
|
|
|
279
279
|
def get_flights(
|
|
@@ -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.
|
|
@@ -346,21 +370,21 @@ class FlightRadar24API(object):
|
|
|
346
370
|
"""
|
|
347
371
|
Return the most tracked data.
|
|
348
372
|
"""
|
|
349
|
-
response = APIRequest(Core.most_tracked_url, headers
|
|
373
|
+
response = APIRequest(Core.most_tracked_url, headers=Core.json_headers)
|
|
350
374
|
return response.get_content()
|
|
351
375
|
|
|
352
376
|
def get_volcanic_eruptions(self) -> Dict:
|
|
353
377
|
"""
|
|
354
378
|
Return boundaries of volcanic eruptions and ash clouds impacting aviation.
|
|
355
379
|
"""
|
|
356
|
-
response = APIRequest(Core.volcanic_eruption_data_url, headers
|
|
380
|
+
response = APIRequest(Core.volcanic_eruption_data_url, headers=Core.json_headers)
|
|
357
381
|
return response.get_content()
|
|
358
382
|
|
|
359
383
|
def get_zones(self) -> Dict[str, Dict]:
|
|
360
384
|
"""
|
|
361
385
|
Return all major zones on the globe.
|
|
362
386
|
"""
|
|
363
|
-
response = APIRequest(Core.zones_data_url, headers
|
|
387
|
+
response = APIRequest(Core.zones_data_url, headers=Core.json_headers)
|
|
364
388
|
zones = response.get_content()
|
|
365
389
|
|
|
366
390
|
if "version" in zones:
|
|
@@ -372,7 +396,7 @@ class FlightRadar24API(object):
|
|
|
372
396
|
"""
|
|
373
397
|
Return the search result.
|
|
374
398
|
"""
|
|
375
|
-
response = APIRequest(Core.search_data_url.format(query, limit), headers
|
|
399
|
+
response = APIRequest(Core.search_data_url.format(query, limit), headers=Core.json_headers)
|
|
376
400
|
results = response.get_content().get("results", [])
|
|
377
401
|
stats = response.get_content().get("stats", {})
|
|
378
402
|
|
|
@@ -407,7 +431,7 @@ class FlightRadar24API(object):
|
|
|
407
431
|
"type": "web"
|
|
408
432
|
}
|
|
409
433
|
|
|
410
|
-
response = APIRequest(Core.user_login_url, headers
|
|
434
|
+
response = APIRequest(Core.user_login_url, headers=Core.json_headers, data=data)
|
|
411
435
|
status_code = response.get_status_code()
|
|
412
436
|
content = response.get_content()
|
|
413
437
|
|
|
@@ -431,7 +455,7 @@ class FlightRadar24API(object):
|
|
|
431
455
|
cookies = self.__login_data["cookies"]
|
|
432
456
|
self.__login_data = None
|
|
433
457
|
|
|
434
|
-
response = APIRequest(Core.user_login_url, headers
|
|
458
|
+
response = APIRequest(Core.user_login_url, headers=Core.json_headers, cookies=cookies)
|
|
435
459
|
return str(response.get_status_code()).startswith("2")
|
|
436
460
|
|
|
437
461
|
def set_flight_tracker_config(
|
|
@@ -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={}"
|
|
@@ -37,8 +37,8 @@ class Airport(Entity):
|
|
|
37
37
|
Initialize instance with basic information about the airport.
|
|
38
38
|
"""
|
|
39
39
|
super().__init__(
|
|
40
|
-
latitude
|
|
41
|
-
longitude
|
|
40
|
+
latitude=basic_info["lat"],
|
|
41
|
+
longitude=basic_info["lon"]
|
|
42
42
|
)
|
|
43
43
|
self.altitude = basic_info["alt"]
|
|
44
44
|
|
|
@@ -53,8 +53,8 @@ class Airport(Entity):
|
|
|
53
53
|
Initialize instance with extra information about the airport.
|
|
54
54
|
"""
|
|
55
55
|
super().__init__(
|
|
56
|
-
latitude
|
|
57
|
-
longitude
|
|
56
|
+
latitude=info["position"]["latitude"],
|
|
57
|
+
longitude=info["position"]["longitude"]
|
|
58
58
|
)
|
|
59
59
|
self.altitude = info["position"]["altitude"]
|
|
60
60
|
|
|
@@ -154,7 +154,7 @@ class Airport(Entity):
|
|
|
154
154
|
|
|
155
155
|
self.average_rating = self.__get_info(ratings.get("avg"))
|
|
156
156
|
self.total_rating = self.__get_info(ratings.get("total"))
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
# Weather information.
|
|
159
159
|
self.weather = self.__get_info(airport.get("weather"), dict())
|
|
160
160
|
|
|
@@ -16,8 +16,8 @@ class Flight(Entity):
|
|
|
16
16
|
:param info: Dictionary with received data from FlightRadar24
|
|
17
17
|
"""
|
|
18
18
|
super().__init__(
|
|
19
|
-
latitude
|
|
20
|
-
longitude
|
|
19
|
+
latitude=self.__get_info(info[1]),
|
|
20
|
+
longitude=self.__get_info(info[2])
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
self.id = flight_id
|
|
@@ -34,7 +34,7 @@ class Flight(Entity):
|
|
|
34
34
|
self.number = self.__get_info(info[13])
|
|
35
35
|
self.airline_iata = self.__get_info(info[13][:2])
|
|
36
36
|
self.on_ground = self.__get_info(info[14])
|
|
37
|
-
self.vertical_speed =self.__get_info(info[15])
|
|
37
|
+
self.vertical_speed = self.__get_info(info[15])
|
|
38
38
|
self.callsign = self.__get_info(info[16])
|
|
39
39
|
self.airline_icao = self.__get_info(info[18])
|
|
40
40
|
|
|
@@ -62,9 +62,9 @@ class Flight(Entity):
|
|
|
62
62
|
comparison_functions = {"max": max, "min": min}
|
|
63
63
|
|
|
64
64
|
for key, value in info.items():
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
# Separate the comparison prefix if it exists.
|
|
67
|
-
prefix, key = key.split("_", maxsplit
|
|
67
|
+
prefix, key = key.split("_", maxsplit=1) if key[:4] == "max_" or key[:4] == "min_" else (None, key)
|
|
68
68
|
|
|
69
69
|
# Check if the value is greater than or less than the attribute value.
|
|
70
70
|
if prefix and key in self.__dict__:
|
|
@@ -53,12 +53,12 @@ class APIRequest(object):
|
|
|
53
53
|
request_method = requests.get if data is None else requests.post
|
|
54
54
|
|
|
55
55
|
if params: url += "?" + "&".join(["{}={}".format(k, v) for k, v in params.items()])
|
|
56
|
-
self.__response = request_method(url, headers
|
|
56
|
+
self.__response = request_method(url, headers=headers, cookies=cookies, data=data)
|
|
57
57
|
|
|
58
58
|
if self.get_status_code() == 520:
|
|
59
59
|
raise CloudflareError(
|
|
60
|
-
message
|
|
61
|
-
response
|
|
60
|
+
message="An unexpected error has occurred. Perhaps you are making too many calls?",
|
|
61
|
+
response=self.__response
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
if self.get_status_code() not in exclude_status_codes:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: FlightRadarAPI
|
|
3
|
-
Version: 1.3.
|
|
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
|
[](https://github.com/JeanExtreme002/FlightRadarAPI)
|
|
33
33
|
[](https://pypi.org/project/FlightRadarAPI/)
|
|
34
34
|
[](https://www.npmjs.com/package/flightradarapi)
|
|
35
|
-
[](https://pypi.org/project/FlightRadarAPI/)
|
|
36
|
+
[](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
|
[](https://github.com/JeanExtreme002/FlightRadarAPI)
|
|
10
10
|
[](https://pypi.org/project/FlightRadarAPI/)
|
|
11
11
|
[](https://www.npmjs.com/package/flightradarapi)
|
|
12
|
-
[](https://pypi.org/project/FlightRadarAPI/)
|
|
13
|
+
[](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.
|
|
@@ -15,34 +15,34 @@ fr_api = FlightRadar24API()
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
@repeat_test(**repeat_test_config)
|
|
18
|
-
def test_get_airlines(expect
|
|
18
|
+
def test_get_airlines(expect=100):
|
|
19
19
|
results = fr_api.get_airlines()
|
|
20
20
|
assert len(results) >= expect
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
@repeat_test(**repeat_test_config)
|
|
24
|
-
def test_get_airport(airports
|
|
24
|
+
def test_get_airport(airports=["ATL", "LAX", "DXB", "DFW"]):
|
|
25
25
|
for airport in airports:
|
|
26
26
|
assert fr_api.get_airport(airport).iata == airport
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
@repeat_test(**repeat_test_config)
|
|
30
|
-
def test_get_airport_details(airports
|
|
30
|
+
def test_get_airport_details(airports=["ATL", "LAX", "DXB", "DFW"]):
|
|
31
31
|
data = ["airport", "airlines", "aircraftImages"]
|
|
32
32
|
|
|
33
33
|
for airport in airports:
|
|
34
|
-
details = fr_api.get_airport_details(airport, flight_limit
|
|
34
|
+
details = fr_api.get_airport_details(airport, flight_limit=1)
|
|
35
35
|
assert all([key in details for key in data]) and details["airport"]["pluginData"]["details"]
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
@repeat_test(**repeat_test_config)
|
|
39
|
-
def test_get_airports(expect
|
|
39
|
+
def test_get_airports(expect=1000):
|
|
40
40
|
results = fr_api.get_airports()
|
|
41
41
|
assert len(results) >= expect
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
@repeat_test(**repeat_test_config)
|
|
45
|
-
def test_get_zones(expect
|
|
45
|
+
def test_get_zones(expect=5):
|
|
46
46
|
results = fr_api.get_zones()
|
|
47
47
|
|
|
48
48
|
assert len(results) >= expect
|
|
@@ -52,7 +52,7 @@ def test_get_zones(expect = 5):
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
@repeat_test(**repeat_test_config)
|
|
55
|
-
def test_get_flights(expect
|
|
55
|
+
def test_get_flights(expect=100):
|
|
56
56
|
results = fr_api.get_flights()
|
|
57
57
|
assert len(results) >= expect
|
|
58
58
|
|
|
@@ -72,11 +72,11 @@ def test_get_flight_details():
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
@repeat_test(**repeat_test_config)
|
|
75
|
-
def test_get_flights_by_airline(airlines
|
|
75
|
+
def test_get_flights_by_airline(airlines=["SWA", "GLO", "AZU", "UAL", "THY"], expect=3):
|
|
76
76
|
count = 0
|
|
77
77
|
|
|
78
78
|
for airline in airlines:
|
|
79
|
-
flights = fr_api.get_flights(airline
|
|
79
|
+
flights = fr_api.get_flights(airline=airline)
|
|
80
80
|
|
|
81
81
|
for flight in flights:
|
|
82
82
|
assert flight.airline_icao == airline
|
|
@@ -87,14 +87,14 @@ def test_get_flights_by_airline(airlines = ["SWA", "GLO", "AZU", "UAL", "THY"],
|
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
@repeat_test(**repeat_test_config)
|
|
90
|
-
def test_get_flights_by_bounds(target_zones
|
|
90
|
+
def test_get_flights_by_bounds(target_zones=["northamerica", "southamerica"], expect=30):
|
|
91
91
|
zones = fr_api.get_zones()
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
for zone in target_zones:
|
|
94
94
|
zone = zones[zone]
|
|
95
95
|
bounds = fr_api.get_bounds(zone)
|
|
96
96
|
|
|
97
|
-
flights = fr_api.get_flights(bounds
|
|
97
|
+
flights = fr_api.get_flights(bounds=bounds)
|
|
98
98
|
|
|
99
99
|
for flight in flights:
|
|
100
100
|
assert zone["tl_y"] >= flight.latitude >= zone["br_y"]
|
|
@@ -104,7 +104,7 @@ def test_get_flights_by_bounds(target_zones = ["northamerica", "southamerica"],
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
@repeat_test(**repeat_test_config)
|
|
107
|
-
def test_get_airline_logo(airlines
|
|
107
|
+
def test_get_airline_logo(airlines=[["WN", "SWA"], ["G3", "GLO"], ["AD", "AZU"], ["AA", "AAL"], ["TK", "THY"]]):
|
|
108
108
|
expected = len(airlines) * 0.8
|
|
109
109
|
found = 0
|
|
110
110
|
|
|
@@ -116,7 +116,7 @@ def test_get_airline_logo(airlines = [["WN", "SWA"], ["G3", "GLO"], ["AD", "AZU"
|
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
@repeat_test(**repeat_test_config)
|
|
119
|
-
def test_get_country_flag(countries
|
|
119
|
+
def test_get_country_flag(countries=["United States", "Brazil", "Egypt", "Japan", "South Korea", "Canada"]):
|
|
120
120
|
expected = len(countries) * 0.8
|
|
121
121
|
found = 0
|
|
122
122
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|