# SAS-PRICES-PY: Python Package for Fetching SAS Flight Prices
## Overview
**SAS-PRICES-PY** is a Python package designed to interact with SAS (Scandinavian Airlines) flight pricing APIs. It provides functionality to fetch and process flight data, including round-trip prices for specified origins, destinations, regions, and durations. The package enables efficient data retrieval with support for asynchronous requests and custom filtering.
---
## Features
- **Cheapest Round Trips**:
- Fetch the cheapest round-trip prices for specific destinations or entire regions.
- Support for filtering by origin, destination, and trip start date.
- **Monthly Prices**:
- Retrieve monthly outbound and inbound prices for specific origin-destination pairs.
- Calculate combined round-trip prices for given months.
- **Trips by Length**:
- Identify the cheapest trips of a specified duration (e.g., 2-day trips).
- Option to search across all destinations or specific regions.
- **Batch Request Optimization**:
- Simultaneous fetching of prices for multiple destinations using asynchronous requests for improved performance.
- **Error Handling**:
- Gracefully handles API failures, empty responses, and invalid data.
---
## Installation
To install SAS-PRICES-PY, clone the repository and ensure the required dependencies are installed:
```bash
git clone https://github.com/alexechoi/sas-py.git
cd sas-py
pip install -r requirements.txt
```
---
## Usage
### 1. **Initialize the SAS Client**
```python
from sas.api import SAS
sas = SAS(market="gb-en") # Default market: "gb-en"
```
### 2. **Fetch Cheapest Round Trips**
```python
trips = sas.get_cheapest_round_trips(region="Europe", origin="LHR", start_date="2025-01-01")
print(trips)
```
### 3. **Fetch Monthly Round Trip Prices**
```python
monthly_trips = sas.get_monthly_round_trips(origin="LHR", destination="CPH", year_month="202501,202501")
print(monthly_trips)
```
### 4. **Fetch Cheapest Trips by Length**
```python
trips = sas.get_cheapest_trips_by_length(origin="LHR", destination="CPH", year_month="202501,202501", trip_length=2)
print(trips)
```
### 5. **Fetch Cheapest Trips Across All Destinations**
```python
trips = sas.get_cheapest_trips_by_length_all_destinations(
origin="LHR", year_month="202501,202501", trip_length=2
)
print(trips)
```
---
## Code Structure
- **`sas/api.py`**:
- Main interface for fetching data from the SAS API.
- Provides methods for cheapest trips, monthly prices, and filtering by length.
- **`sas/sas_monthly.py`**:
- Contains logic to fetch and process monthly round-trip prices.
- **`sas/sas_cheapest.py`**:
- Implements fetching the cheapest round trips for multiple destinations.
- **`sas/data.py`**:
- Defines available regions and their respective destinations.
- **`tests/test_api.py`**:
- Unit tests to validate package functionality.
---
## Example Test Run
To run tests:
```bash
python -m unittest discover tests
```
Example output:
```
.....
----------------------------------------------------------------------
Ran 5 tests in 0.300s
OK
```
---
## Dependencies
- `requests`
- `aiohttp`
- `brotli`
- `unittest`
Install them using:
```bash
pip install -r requirements.txt
```
---
## Development Notes
### Key Features
1. **Batch Requests**:
- Optimized with asynchronous requests to reduce API call latency.
2. **Dynamic Filtering**:
- Supports filtering by region, origin, destination, and trip duration.
3. **Customizable Markets**:
- Set the market during initialization (`gb-en`, `us-en`, etc.).
### Known Limitations
- The API may return empty responses if no flights are available.
- Network-related errors can slow down or fail batch requests; retry mechanisms may be necessary.
---
## License
This project is licensed under the MIT License. See the LICENSE file for details.
NOTE THAT THIS PROJECT IS IN NO WAY AFFILIATED WITH SCANDINAVIAN AIRLINES
---
## Contributions
Contributions are welcome! Please submit issues or pull requests via the [GitHub repository](https://github.com/alexechoi/sas-py).
---
## Author
Created by **Alex Choi**, November 2024.
Raw data
{
"_id": null,
"home_page": "https://github.com/alexechoi/sas-py",
"name": "sas-prices-py",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Alex Choi",
"author_email": "alexchoidev@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/3d/aa/9c50743aadd7209ebe8e1407adfe2cbe377141e1fd06327e71e0afedf4b4/sas_prices_py-0.1.1.tar.gz",
"platform": null,
"description": "# SAS-PRICES-PY: Python Package for Fetching SAS Flight Prices\n\n## Overview\n\n**SAS-PRICES-PY** is a Python package designed to interact with SAS (Scandinavian Airlines) flight pricing APIs. It provides functionality to fetch and process flight data, including round-trip prices for specified origins, destinations, regions, and durations. The package enables efficient data retrieval with support for asynchronous requests and custom filtering.\n\n---\n\n## Features\n\n- **Cheapest Round Trips**:\n - Fetch the cheapest round-trip prices for specific destinations or entire regions.\n - Support for filtering by origin, destination, and trip start date.\n\n- **Monthly Prices**:\n - Retrieve monthly outbound and inbound prices for specific origin-destination pairs.\n - Calculate combined round-trip prices for given months.\n\n- **Trips by Length**:\n - Identify the cheapest trips of a specified duration (e.g., 2-day trips).\n - Option to search across all destinations or specific regions.\n\n- **Batch Request Optimization**:\n - Simultaneous fetching of prices for multiple destinations using asynchronous requests for improved performance.\n\n- **Error Handling**:\n - Gracefully handles API failures, empty responses, and invalid data.\n\n---\n\n## Installation\n\nTo install SAS-PRICES-PY, clone the repository and ensure the required dependencies are installed:\n\n```bash\ngit clone https://github.com/alexechoi/sas-py.git\ncd sas-py\npip install -r requirements.txt\n```\n\n---\n\n## Usage\n\n### 1. **Initialize the SAS Client**\n```python\nfrom sas.api import SAS\n\nsas = SAS(market=\"gb-en\") # Default market: \"gb-en\"\n```\n\n### 2. **Fetch Cheapest Round Trips**\n```python\ntrips = sas.get_cheapest_round_trips(region=\"Europe\", origin=\"LHR\", start_date=\"2025-01-01\")\nprint(trips)\n```\n\n### 3. **Fetch Monthly Round Trip Prices**\n```python\nmonthly_trips = sas.get_monthly_round_trips(origin=\"LHR\", destination=\"CPH\", year_month=\"202501,202501\")\nprint(monthly_trips)\n```\n\n### 4. **Fetch Cheapest Trips by Length**\n```python\ntrips = sas.get_cheapest_trips_by_length(origin=\"LHR\", destination=\"CPH\", year_month=\"202501,202501\", trip_length=2)\nprint(trips)\n```\n\n### 5. **Fetch Cheapest Trips Across All Destinations**\n```python\ntrips = sas.get_cheapest_trips_by_length_all_destinations(\n origin=\"LHR\", year_month=\"202501,202501\", trip_length=2\n)\nprint(trips)\n```\n\n---\n\n## Code Structure\n\n- **`sas/api.py`**:\n - Main interface for fetching data from the SAS API.\n - Provides methods for cheapest trips, monthly prices, and filtering by length.\n\n- **`sas/sas_monthly.py`**:\n - Contains logic to fetch and process monthly round-trip prices.\n\n- **`sas/sas_cheapest.py`**:\n - Implements fetching the cheapest round trips for multiple destinations.\n\n- **`sas/data.py`**:\n - Defines available regions and their respective destinations.\n\n- **`tests/test_api.py`**:\n - Unit tests to validate package functionality.\n\n---\n\n## Example Test Run\n\nTo run tests:\n\n```bash\npython -m unittest discover tests\n```\n\nExample output:\n\n```\n.....\n----------------------------------------------------------------------\nRan 5 tests in 0.300s\n\nOK\n```\n\n---\n\n## Dependencies\n\n- `requests`\n- `aiohttp`\n- `brotli`\n- `unittest`\n\nInstall them using:\n\n```bash\npip install -r requirements.txt\n```\n\n---\n\n## Development Notes\n\n### Key Features\n1. **Batch Requests**:\n - Optimized with asynchronous requests to reduce API call latency.\n\n2. **Dynamic Filtering**:\n - Supports filtering by region, origin, destination, and trip duration.\n\n3. **Customizable Markets**:\n - Set the market during initialization (`gb-en`, `us-en`, etc.).\n\n### Known Limitations\n- The API may return empty responses if no flights are available.\n- Network-related errors can slow down or fail batch requests; retry mechanisms may be necessary.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\nNOTE THAT THIS PROJECT IS IN NO WAY AFFILIATED WITH SCANDINAVIAN AIRLINES\n\n---\n\n## Contributions\n\nContributions are welcome! Please submit issues or pull requests via the [GitHub repository](https://github.com/alexechoi/sas-py).\n\n--- \n\n## Author\n\nCreated by **Alex Choi**, November 2024.\n",
"bugtrack_url": null,
"license": null,
"summary": "Python package for fetching SAS flight prices",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/alexechoi/sas-py"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f8480b30c0c9a56d51421afc8ebcf9e6dd3deae919343d8d4540f7d8b138e871",
"md5": "3949410951814755ccb1c0f36f224b25",
"sha256": "4c55446e42fae164e3fd362943d198c414f1f79ab1f874dccce5154b44f80198"
},
"downloads": -1,
"filename": "sas_prices_py-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3949410951814755ccb1c0f36f224b25",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 12489,
"upload_time": "2024-11-27T18:54:16",
"upload_time_iso_8601": "2024-11-27T18:54:16.698532Z",
"url": "https://files.pythonhosted.org/packages/f8/48/0b30c0c9a56d51421afc8ebcf9e6dd3deae919343d8d4540f7d8b138e871/sas_prices_py-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3daa9c50743aadd7209ebe8e1407adfe2cbe377141e1fd06327e71e0afedf4b4",
"md5": "7746718dca165ba1c9d635a2a2fe09e1",
"sha256": "0fac79ca607ba1a44605a763303ac0eb4879dc9d67e8b68b7b5bc3a5a97a7b97"
},
"downloads": -1,
"filename": "sas_prices_py-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "7746718dca165ba1c9d635a2a2fe09e1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 11218,
"upload_time": "2024-11-27T18:54:17",
"upload_time_iso_8601": "2024-11-27T18:54:17.838342Z",
"url": "https://files.pythonhosted.org/packages/3d/aa/9c50743aadd7209ebe8e1407adfe2cbe377141e1fd06327e71e0afedf4b4/sas_prices_py-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-27 18:54:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "alexechoi",
"github_project": "sas-py",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
},
{
"name": "brotli",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "aiohttp",
"specs": [
[
"==",
"3.11.7"
]
]
}
],
"lcname": "sas-prices-py"
}