British Airways API Python Package
This Python package provides an interface to fetch data from the British Airways Low-Price Finder API. It supports fetching round-trip flight prices, one-way flight prices, monthly pricing graphs, and calendar pricing data.
⚠️ Disclaimer: This package is in no way affiliated with British Airways.
Features
- Fetch the specific round-trip flight price for given departure and return dates.
- Fetch the specific one-way flight price for a given date.
- Fetch the cheapest round-trip flights for a region and origin airport.
- Retrieve monthly pricing data for a specific route and trip length.
- Fetch calendar-based pricing data for specific months, showing daily flight prices.
Installation
This package is available on PyPI. Install it directly using pip:
pip install britishairways
Or, clone the repository and install it locally:
git clone https://github.com/alexechoi/british-airways-py.git
cd british-airways-py
pip install .
Usage
Initialize the Client
Before using the package, initialize the BritishAirways client:
from britishairways.api import BritishAirways
# Initialize the client
ba = BritishAirways()
Functions
1. get_one_way_price
Fetch the price for a one-way flight on a specific date.
Parameters:
origin(str): The origin airport code (e.g., "LHR").destination(str): The destination airport code (e.g., "JFK").departure_date(str): The departure date inYYYY-MM-DDformat.
Example:
one_way_flight = ba.get_one_way_price(
origin="LON",
destination="NYC",
departure_date="2024-12-15"
)
print(one_way_flight)
2. get_specific_round_trip
Fetch details for a specific round trip, given a departure and return date.
Parameters:
origin(str): The origin airport code (e.g., "LHR").destination(str): The destination airport code (e.g., "JFK").departure_date(str): The departure date inYYYY-MM-DDformat.return_date(str): The return date inYYYY-MM-DDformat.
Example:
flights = ba.get_specific_round_trip(
origin="LON",
destination="NYC",
departure_date="2024-12-15",
return_date="2024-12-22"
)
print(flights)
3. get_cheapest_round_trips
Fetch the cheapest round-trip flights for a given region and origin.
Parameters:
region(str): The region code (e.g., "FEA").origin(str): The origin airport code (e.g., "LON").
Example:
cheapest_flights = ba.get_cheapest_round_trips(region="FEA", origin="LON")
print(cheapest_flights)
4. get_monthly_graphs
Retrieve monthly pricing data for a specific origin and destination.
Parameters:
origin(str): The origin airport code (e.g., "LHR").destination(str): The destination airport code (e.g., "ATL").trip_length(int): The length of the trip in days (e.g., 7).
Example:
monthly_graphs = ba.get_monthly_graphs(origin="LHR", destination="ATL", trip_length=7)
print(monthly_graphs)
5. get_calendar_prices
Retrieve calendar-based pricing data for specific months, displaying daily flight prices.
Parameters:
origin(str): The origin airport code (e.g., "LHR").destination(str): The destination airport code (e.g., "NYC").trip_length(int): The number of nights for the trip (e.g., 7).months(list): A list of months inYYYYMMformat (e.g.,["202412", "202501"]).
Example:
calendar_prices = ba.get_calendar_prices(
origin="LHR",
destination="NYC",
trip_length=7,
months=["202412", "202501", "202502"]
)
print(calendar_prices)
Region Codes
The following region codes are supported:
| Code | Region |
|---|---|
NOA |
North America |
SOA |
Latin America and Caribbean |
EUK |
Europe, UK, and Ireland |
SAS |
South and Central Asia |
MDE+OR+AFR |
Middle East and Africa |
FEA |
Far East and Australia |
Contributing
Contributions are welcome! If you find a bug or have a feature suggestion, feel free to open an issue or submit a pull request.
License
This project is licensed under the MIT License.
Happy Coding! 😊
Metadata
Release files for britishairways 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| britishairways-0.1.1.tar.gz | 9.9 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| britishairways-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.4 kB
Release files / britishairways-0.1.1.tar.gz
| Download URL | britishairways-0.1.1.tar.gz |
|---|---|
| Size | 9.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
89a60c59e6bb22dcc13da913dda75eddcb127b0190a85f51c26622218ee1c5d2
|
|
BLAKE2b-256 checksum How to use checksums |
fb71e1d2f918a18fd2e7f75022f5e5515903a5f57c2192c002e0f15f59ade7cf
|
| 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 logRelease files / britishairways-0.1.1-py3-none-any.whl
| Download URL | britishairways-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
19bf99c2daaae6150097903f5e8eacc2d60bacff64327e1d6cf0f1eed91cd753
|
|
BLAKE2b-256 checksum How to use checksums |
68421175c30f8904064ece13ab337f8b7a9b6ba27763d73cb8b526a99dd3b608
|
| 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 logSecurity for britishairways 0.1.1
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.
Attestation for britishairways-0.1.1.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 logA 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.