Skip to main content

Here’s an updated version of your README tailored for a pip-distributed package:


SAS-PRICES-PY: Python Package for Fetching SAS Flight Prices

Overview

SAS-PRICES-PY is a Python package for interacting 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. Designed for efficiency, the package supports asynchronous requests and advanced filtering.

⚠️ Disclaimer: This package is in no way affiliated with Scandinavian Airlines.


Features

  • Cheapest Round Trips:

    • Fetch the cheapest round-trip prices for specific destinations or regions.
    • Filter results 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 selected months.
  • Trips by Length:

    • Find the cheapest trips of a specified duration (e.g., 2-day trips).
    • Search across all destinations or specific regions.
  • Batch Request Optimization:

    • Use asynchronous requests for faster data retrieval when fetching multiple destinations.
  • Error Handling:

    • Handle API failures, empty responses, and invalid data gracefully.

Installation

Install SAS-PRICES-PY via pip:

pip install sas-prices-py

Usage

1. Initialize the SAS Client

from sas_prices_py import SAS

sas = SAS(market="gb-en")  # Default market: "gb-en"

2. Fetch Cheapest Round Trips

trips = sas.get_cheapest_round_trips(region="Europe", origin="LHR", start_date="2025-01-01")
print(trips)

3. Fetch Monthly Round Trip Prices

monthly_trips = sas.get_monthly_round_trips(origin="LHR", destination="CPH", year_month="202501,202501")
print(monthly_trips)

4. Fetch Cheapest Trips by Length

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

trips = sas.get_cheapest_trips_by_length_all_destinations(
    origin="LHR", year_month="202501,202501", trip_length=2
)
print(trips)

Code Structure

  • sas_prices_py/api.py:

    • Main interface for interacting with SAS APIs.
    • Includes methods for fetching cheapest trips, monthly prices, and filtering by trip length.
  • sas_prices_py/sas_monthly.py:

    • Handles monthly round-trip price logic.
  • sas_prices_py/sas_cheapest.py:

    • Implements fetching the cheapest round trips.
  • sas_prices_py/data.py:

    • Defines regions and their destinations.
  • tests/test_api.py:

    • Unit tests for package functionality.

Example Test Run

To run tests:

python -m unittest discover tests

Example output:

.....
----------------------------------------------------------------------
Ran 5 tests in 0.300s

OK

Dependencies

The following dependencies are required and installed automatically with pip:

  • requests
  • aiohttp
  • brotli

Development Notes

Key Features

  1. Batch Requests:

    • Optimized with asynchronous requests to reduce API call latency.
  2. Dynamic Filtering:

    • Filter by region, origin, destination, and trip duration.
  3. Customizable Markets:

    • Set the market during initialization (gb-en, us-en, etc.).

Known Limitations

  • Empty responses may occur if no flights are available.
  • Network-related errors can slow or fail batch requests; retry mechanisms may improve performance.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Disclaimer: This project is in no way affiliated with Scandinavian Airlines.


Contributions

Contributions are welcome! Please submit issues or pull requests via the GitHub repository.


Author

Created by Alex Choi, November 2024.

Metadata

Release files for sas-prices-py 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sas-prices-py 0.1.2
File Size Uploaded Provenance
sas_prices_py-0.1.2.tar.gz 11.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sas-prices-py 0.1.2
File Interpreter ABI Platform
sas_prices_py-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / sas_prices_py-0.1.2.tar.gz

Download URL sas_prices_py-0.1.2.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0ed4bdf8cd46dd7e95b79965c3bb2f5227c388a3ce6af1fb9659076c3d862127
BLAKE2b-256 checksum
How to use checksums
e0cec40d021ee47906a64d66cae794c1025943c61e7cb79130a88273d2cff80e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Release files / sas_prices_py-0.1.2-py3-none-any.whl

Download URL sas_prices_py-0.1.2-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d37191215be3c027f47920475816a25f3ecbe3d9d2ead511a7019d71b53011d
BLAKE2b-256 checksum
How to use checksums
83120de33b862d1c03b54b3b8c6bb53512c4db526bb2292048c0cf1c4884d612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

Security for sas-prices-py 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sas_prices_py-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2024.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page