File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 TransportError ,
1414 ApiError ,
1515 AuthenticationError ,
16+ NoApiKeyError ,
1617 RateLimitError ,
1718 PaymentRequiredError ,
1819 BadRequestError ,
2627 "TransportError" ,
2728 "ApiError" ,
2829 "AuthenticationError" ,
30+ "NoApiKeyError" ,
2931 "RateLimitError" ,
3032 "PaymentRequiredError" ,
3133 "BadRequestError" ,
Original file line number Diff line number Diff line change @@ -66,6 +66,21 @@ class AuthenticationError(ApiError):
6666 pass
6767
6868
69+ class NoApiKeyError (Fr24SdkError ):
70+ """Indicates that no API key was provided for authentication.
71+
72+ This is a specific type of authentication error that occurs when the SDK
73+ is used without providing an API token, either through the constructor
74+ or the FR24_API_TOKEN environment variable.
75+
76+ Unlike other ApiError subclasses, this error is raised before any HTTP
77+ request is made, so it doesn't include request/response context.
78+ """
79+
80+ def __init__ (self , message : str ):
81+ super ().__init__ (message )
82+
83+
6984class RateLimitError (ApiError ):
7085 """Indicates that the API rate limit has been exceeded (402 Payment Required or 429 Too Many Requests)."""
7186
Original file line number Diff line number Diff line change 1212from .exceptions import (
1313 ApiError ,
1414 AuthenticationError ,
15+ NoApiKeyError ,
1516 RateLimitError ,
1617 TransportError ,
1718 PaymentRequiredError ,
@@ -73,6 +74,14 @@ def request(
7374 ) -> httpx .Response :
7475 """Makes an HTTP request to the API."""
7576
77+ # Check if API token is available before making the request
78+ if not self .api_token :
79+ raise NoApiKeyError (
80+ "No API key provided. Please set the FR24_API_TOKEN environment variable "
81+ "or pass an api_token parameter when creating the Client. "
82+ "For more information, see https://fr24api.flightradar24.com/docs"
83+ )
84+
7685 request_headers = self ._get_default_headers ()
7786 if headers :
7887 request_headers .update (headers )
You can’t perform that action at this time.
0 commit comments