fr24sdk


Namefr24sdk JSON
Version 0.1.0 PyPI version JSON
download
home_pageNone
SummaryPython SDK for the Flightradar24 API
upload_time2025-08-04 13:43:57
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2025 Flightradar24 AB Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fr24 api aviation flightradar24 sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Flightradar24 Python SDK

Official Python SDK for the [Flightradar24 API](https://fr24api.flightradar24.com).

## Features

- Access to all Flightradar24 API v1 endpoints.
- Intuitive client interface: `client.airports.get_full("WAW")`
- Typed responses.
- Robust error handling with custom exceptions.
- Synchronous client (async coming soon).
- Lightweight input validation for common parameters.

## Installation

### Release Version
**Using uv:**
```bash
uv pip install fr24sdk
```

**Using pip:**
```bash
pip install fr24sdk
```

## SDK Usage Guide

This guide provides a comprehensive overview of how to use the `fr24sdk` to interact with the Flightradar24 API.

### 1. Client Initialization

The `Client` is your main entry point to the API.

**Using Environment Variable:**

Ensure your API token is set as an environment variable `FR24_API_TOKEN`.
```bash
export FR24_API_TOKEN="your_actual_token_here" # On Linux/macOS
# set FR24_API_TOKEN=your_actual_token_here # On Windows Command Prompt
# $Env:FR24_API_TOKEN="your_actual_token_here" # On Windows PowerShell
```

Then, initialize the client:
```python
from fr24sdk.client import Client

client = Client()
```

**Passing Token Directly:**
You can also pass the API token directly during client initialization.
```python
client = Client(api_token="your_actual_token_here")
```

**Using as a Context Manager:**
This ensures the underlying HTTP client is closed properly.
```python
from fr24sdk.client import Client

with Client() as client:
    client.flight_summary(flight_ids="")
    pass
```

### 2. Accessing API Resources

The client provides access to different API resources as attributes. For example:

- `client.airlines`: Fetch airline details.
- `client.airports`: Fetch airport details.
- `client.live`: Get live flight data, including flights within specific geographical bounds.
- `client.historic`: Query historic flight information.
- `client.flight_summary`: Retrieve summaries for specific flights.
- `client.flight_tracks`: Access flight track data.
- `client.usage`: Check your API usage statistics.

Each resource object then has methods to fetch data related to that resource.

### 3. Resource Examples

The SDK provides intuitive access to various API resources. Here's how you can typically interact with them:

**a. Fetching Airport Details**

This example demonstrates fetching detailed information for an airport (e.g., Warsaw Chopin Airport - WAW) and accessing its attributes.

```python
from fr24sdk.client import Client
from fr24sdk.exceptions import ApiError

# Initialize client (ensure FR24_API_TOKEN is set or pass api_token="your_token")
client = Client()

airport_iata = "WAW"
print(f"Fetching full details for airport: {airport_iata}")

airport_details = client.airports.get_full(airport_iata)

if airport_details:
    print(f"  Name: {airport_details.name}")
    print(f"  ICAO: {airport_details.icao}")
    print(f"  City: {airport_details.city}")
    print(f"  Country: {airport_details.country_name}")
    print(f"  Latitude: {airport_details.lat}")
    print(f"  Longitude: {airport_details.lon}")
```

**b. Other Available Resources**

The client provides access to a comprehensive set of Flightradar24 API resources, including but not limited to:

-   `client.airlines`: Fetch airline details.
-   `client.live`: Get live flight data, including flights within specific geographical bounds.
-   `client.flight_summary`: Retrieve summaries for specific flights.
-   `client.flight_tracks`: Access flight track data.
-   `client.historic`: Query historic flight information.
-   `client.usage`: Check your API usage statistics.

Each of these resources offers methods to interact with the corresponding API endpoints. For example, you might use `client.live.get_flights(...)` or `client.airlines.get_by_iata(...)`. Please refer to the SDK's source code or future detailed documentation for specific method signatures and parameters.

### 4. Handling Responses

API methods return Python objects that represent the JSON response from the API. You can access data using dot notation, as shown in the examples.

```python
# Example with AirportFull object
# waw_full = client.airports.get_full("WAW")
# print(waw_full.name)
# print(waw_full.timezone_name)
```

### 5. Error Handling

The SDK uses custom exceptions to indicate errors. The base exception is `Fr24SdkError`. More specific errors like `ApiError`, `AuthenticationError`, `RateLimitError`, etc., inherit from it.

```python
import os
from fr24sdk.client import Client
from fr24sdk.exceptions import ApiError, AuthenticationError, Fr24SdkError # Import relevant exceptions

# Assumes FR24_API_TOKEN is set, or pass it to Client()
try:
    with Client() as client:
        # Example: Intentionally try to get a non-existent airport
        airport = client.airports.get_full("INVALID_IATA")
        if airport:
            print(airport.name)

except AuthenticationError:
    print("Authentication failed. Please check your API token.")
except ApiError as e:
    print(f"API Error occurred: Status {e.status}, Message: {e.message}")
    print(f"Request URL: {e.request_url}")
    if e.body:
        print(f"Response body: {e.body}")
except Fr24SdkError as e:
    print(f"An SDK-specific error occurred: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
```

### 6. Closing the Client

If you are not using the client as a context manager (`with Client() as client:`), you should explicitly close it to release resources:

```python
client = Client()
# ... use client ...
client.close()
```

## Contributing

Contributions are welcome! Please see `CONTRIBUTING.md` for guidelines.

## License

This project is licensed under the MIT License - see the `LICENSE` file for details. 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fr24sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "FR24, api, aviation, flightradar24, sdk",
    "author": null,
    "author_email": "Damian Szumski <damian.szumski@fr24.com>",
    "download_url": "https://files.pythonhosted.org/packages/0c/40/dff9a4f1a710417aca0178cc64ea9231a53ceb7e2bfff7e5877f143bd88e/fr24sdk-0.1.0.tar.gz",
    "platform": null,
    "description": "# Flightradar24 Python SDK\n\nOfficial Python SDK for the [Flightradar24 API](https://fr24api.flightradar24.com).\n\n## Features\n\n- Access to all Flightradar24 API v1 endpoints.\n- Intuitive client interface: `client.airports.get_full(\"WAW\")`\n- Typed responses.\n- Robust error handling with custom exceptions.\n- Synchronous client (async coming soon).\n- Lightweight input validation for common parameters.\n\n## Installation\n\n### Release Version\n**Using uv:**\n```bash\nuv pip install fr24sdk\n```\n\n**Using pip:**\n```bash\npip install fr24sdk\n```\n\n## SDK Usage Guide\n\nThis guide provides a comprehensive overview of how to use the `fr24sdk` to interact with the Flightradar24 API.\n\n### 1. Client Initialization\n\nThe `Client` is your main entry point to the API.\n\n**Using Environment Variable:**\n\nEnsure your API token is set as an environment variable `FR24_API_TOKEN`.\n```bash\nexport FR24_API_TOKEN=\"your_actual_token_here\" # On Linux/macOS\n# set FR24_API_TOKEN=your_actual_token_here # On Windows Command Prompt\n# $Env:FR24_API_TOKEN=\"your_actual_token_here\" # On Windows PowerShell\n```\n\nThen, initialize the client:\n```python\nfrom fr24sdk.client import Client\n\nclient = Client()\n```\n\n**Passing Token Directly:**\nYou can also pass the API token directly during client initialization.\n```python\nclient = Client(api_token=\"your_actual_token_here\")\n```\n\n**Using as a Context Manager:**\nThis ensures the underlying HTTP client is closed properly.\n```python\nfrom fr24sdk.client import Client\n\nwith Client() as client:\n    client.flight_summary(flight_ids=\"\")\n    pass\n```\n\n### 2. Accessing API Resources\n\nThe client provides access to different API resources as attributes. For example:\n\n- `client.airlines`: Fetch airline details.\n- `client.airports`: Fetch airport details.\n- `client.live`: Get live flight data, including flights within specific geographical bounds.\n- `client.historic`: Query historic flight information.\n- `client.flight_summary`: Retrieve summaries for specific flights.\n- `client.flight_tracks`: Access flight track data.\n- `client.usage`: Check your API usage statistics.\n\nEach resource object then has methods to fetch data related to that resource.\n\n### 3. Resource Examples\n\nThe SDK provides intuitive access to various API resources. Here's how you can typically interact with them:\n\n**a. Fetching Airport Details**\n\nThis example demonstrates fetching detailed information for an airport (e.g., Warsaw Chopin Airport - WAW) and accessing its attributes.\n\n```python\nfrom fr24sdk.client import Client\nfrom fr24sdk.exceptions import ApiError\n\n# Initialize client (ensure FR24_API_TOKEN is set or pass api_token=\"your_token\")\nclient = Client()\n\nairport_iata = \"WAW\"\nprint(f\"Fetching full details for airport: {airport_iata}\")\n\nairport_details = client.airports.get_full(airport_iata)\n\nif airport_details:\n    print(f\"  Name: {airport_details.name}\")\n    print(f\"  ICAO: {airport_details.icao}\")\n    print(f\"  City: {airport_details.city}\")\n    print(f\"  Country: {airport_details.country_name}\")\n    print(f\"  Latitude: {airport_details.lat}\")\n    print(f\"  Longitude: {airport_details.lon}\")\n```\n\n**b. Other Available Resources**\n\nThe client provides access to a comprehensive set of Flightradar24 API resources, including but not limited to:\n\n-   `client.airlines`: Fetch airline details.\n-   `client.live`: Get live flight data, including flights within specific geographical bounds.\n-   `client.flight_summary`: Retrieve summaries for specific flights.\n-   `client.flight_tracks`: Access flight track data.\n-   `client.historic`: Query historic flight information.\n-   `client.usage`: Check your API usage statistics.\n\nEach of these resources offers methods to interact with the corresponding API endpoints. For example, you might use `client.live.get_flights(...)` or `client.airlines.get_by_iata(...)`. Please refer to the SDK's source code or future detailed documentation for specific method signatures and parameters.\n\n### 4. Handling Responses\n\nAPI methods return Python objects that represent the JSON response from the API. You can access data using dot notation, as shown in the examples.\n\n```python\n# Example with AirportFull object\n# waw_full = client.airports.get_full(\"WAW\")\n# print(waw_full.name)\n# print(waw_full.timezone_name)\n```\n\n### 5. Error Handling\n\nThe SDK uses custom exceptions to indicate errors. The base exception is `Fr24SdkError`. More specific errors like `ApiError`, `AuthenticationError`, `RateLimitError`, etc., inherit from it.\n\n```python\nimport os\nfrom fr24sdk.client import Client\nfrom fr24sdk.exceptions import ApiError, AuthenticationError, Fr24SdkError # Import relevant exceptions\n\n# Assumes FR24_API_TOKEN is set, or pass it to Client()\ntry:\n    with Client() as client:\n        # Example: Intentionally try to get a non-existent airport\n        airport = client.airports.get_full(\"INVALID_IATA\")\n        if airport:\n            print(airport.name)\n\nexcept AuthenticationError:\n    print(\"Authentication failed. Please check your API token.\")\nexcept ApiError as e:\n    print(f\"API Error occurred: Status {e.status}, Message: {e.message}\")\n    print(f\"Request URL: {e.request_url}\")\n    if e.body:\n        print(f\"Response body: {e.body}\")\nexcept Fr24SdkError as e:\n    print(f\"An SDK-specific error occurred: {e}\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\n```\n\n### 6. Closing the Client\n\nIf you are not using the client as a context manager (`with Client() as client:`), you should explicitly close it to release resources:\n\n```python\nclient = Client()\n# ... use client ...\nclient.close()\n```\n\n## Contributing\n\nContributions are welcome! Please see `CONTRIBUTING.md` for guidelines.\n\n## License\n\nThis project is licensed under the MIT License - see the `LICENSE` file for details. \n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 Flightradar24 AB  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Python SDK for the Flightradar24 API",
    "version": "0.1.0",
    "project_urls": {
        "Changelog": "https://github.com/flightradar24/fr24api-sdk-python/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/flightradar24/fr24api-sdk-python/blob/main/docs/README.md",
        "Homepage": "https://github.com/flightradar24/fr24api-sdk-python",
        "Repository": "https://github.com/flightradar24/fr24api-sdk-python"
    },
    "split_keywords": [
        "fr24",
        " api",
        " aviation",
        " flightradar24",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cc7a8e5cac6becf3ad63a23b91e966ea724819ccca82b3f7b95f343262bc2dab",
                "md5": "4101cb2ab895f1b518b1cf20968a75c3",
                "sha256": "5cab0c7ade7efe07a73728a1a31631e7645eb2be98cf7f926dcd38be8e243bb6"
            },
            "downloads": -1,
            "filename": "fr24sdk-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4101cb2ab895f1b518b1cf20968a75c3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 26747,
            "upload_time": "2025-08-04T13:43:56",
            "upload_time_iso_8601": "2025-08-04T13:43:56.512408Z",
            "url": "https://files.pythonhosted.org/packages/cc/7a/8e5cac6becf3ad63a23b91e966ea724819ccca82b3f7b95f343262bc2dab/fr24sdk-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0c40dff9a4f1a710417aca0178cc64ea9231a53ceb7e2bfff7e5877f143bd88e",
                "md5": "f54945c3bfd33208752c93ee5a8fc555",
                "sha256": "0590aa6f0bcfdd30d6aad2e1dd66b50dcb36d72801bbd2ba66c38d8fee456619"
            },
            "downloads": -1,
            "filename": "fr24sdk-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f54945c3bfd33208752c93ee5a8fc555",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 119813,
            "upload_time": "2025-08-04T13:43:57",
            "upload_time_iso_8601": "2025-08-04T13:43:57.915668Z",
            "url": "https://files.pythonhosted.org/packages/0c/40/dff9a4f1a710417aca0178cc64ea9231a53ceb7e2bfff7e5877f143bd88e/fr24sdk-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-04 13:43:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "flightradar24",
    "github_project": "fr24api-sdk-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fr24sdk"
}
        
Elapsed time: 1.20978s