Python wrapper for the Book-A-Limo API
Project description
Book-A-Limo Python SDK
A modern, async Python wrapper for the Book-A-Limo API with full type support. Built on top of httpx and pydantic.
Table of Contents
- Book-A-Limo Python SDK
Features
- Asynchronous
- Fully Typed for requests & responses
- Input validation including airports and addresses.
- Clean, minimal interface for each API operation
- Custom exceptions & error handling
- Tests and examples
Requirements
- Python 3.9+ (
pyproject.tomlsetsrequires-python = ">=3.9") - An async event loop (examples use
asyncio) - Time strings use
MM/dd/yyyy hh:mm tt(e.g.,09/05/2025 12:44 AM)
Installation
pip install bookalimo
Quick Start
import asyncio
from bookalimo import (
BookALimo,
create_credentials,
create_airport_location,
create_address_location,
)
from bookalimo.models import RateType
async def main():
# For Travel Agents (customers: pass is_customer=True)
credentials = create_credentials("TA10007", "your_password")
async with BookALimo(credentials) as client:
# Build locations
pickup = create_airport_location("JFK", "New York")
dropoff = create_address_location("53 East 34th Street, Manhattan")
prices = await client.get_prices(
rate_type=RateType.P2P,
date_time="09/05/2025 12:44 AM",
pickup=pickup,
dropoff=dropoff,
passengers=2,
luggage=3,
)
print(f"Available cars: {len(prices.prices)}")
for price in prices.prices:
print(f"- {price.car_description}: ${price.price}")
if __name__ == "__main__":
asyncio.run(main())
Authentication
from bookalimo import create_credentials
# Travel Agents
ta_creds = create_credentials("TA10007", "password", is_customer=False)
# Customers
cust_creds = create_credentials("customer@email.com", "password", is_customer=True)
Core Operations
# List Reservations
reservations = await client.list_reservations(is_archive=False)
# Get Reservation Details
details = await client.get_reservation("5452773")
Get Pricing
from bookalimo.models import RateType
prices = await client.get_prices(
rate_type=RateType.P2P,
date_time="09/05/2025 12:44 AM",
pickup=pickup, # Location
dropoff=dropoff, # Location
passengers=2,
luggage=3,
# Optional kwargs:
# hours=2, stops=[...], account=..., passenger=..., rewards=[...],
# car_class_code="SD", pets=0, car_seats=0, boosters=0, infants=0,
# customer_comment="..."
)
Book a Reservation
from bookalimo import create_credit_card, create_passenger
from bookalimo.models import CardHolderType
# Optionally set details first (select car class, add passenger, etc.)
details = await client.set_details(
token=prices.token,
car_class_code="SD",
passenger=create_passenger("John", "Smith", "+19173334455"),
)
# Book with credit card
card = create_credit_card(
number="4111 1111 1111 1111", # test PAN
card_holder="John Smith",
holder_type=CardHolderType.PERSONAL,
expiration="01/28",
cvv="123",
zip_code="10016",
)
booking = await client.book(token=prices.token, credit_card=card)
print(f"Booked! Confirmation: {booking.reservation_id}")
# Or charge account
booking = await client.book(token=prices.token, method="charge")
Location Builders
Airport Locations
from bookalimo import create_airport_location
pickup = create_airport_location(
iata_code="JFK",
city_name="New York",
airline_code="UA",
flight_number="UA1234",
terminal="7",
)
Address Locations
from bookalimo import create_address_location
dropoff = create_address_location(
address="53 East 34th Street, Manhattan",
zip_code="10016",
)
Stops
from bookalimo import create_stop
stops = [
create_stop("Brooklyn Bridge", is_en_route=False),
create_stop("Empire State Building", is_en_route=True),
]
Advanced
Using Account Info (Travel Agents)
from bookalimo.models import Account
account = Account(
id="TA10007",
department="Sales",
booker_first_name="Jane",
booker_last_name="Agent",
booker_email="jane@agency.com",
booker_phone="+19173334455",
)
prices = await client.get_prices(
# ... required args
account=account,
)
Edit / Cancel a Reservation
# Edit (e.g., add note or change passengers). Omitting fields leaves them unchanged.
edit_result = await client.edit_reservation(
confirmation="5452773",
is_cancel_request=False,
passengers=3,
other="Gate pickup",
)
# Cancel
cancel_result = await client.edit_reservation(
confirmation="5452773",
is_cancel_request=True,
)
Error Handling
from bookalimo.exceptions import BookALimoError
try:
reservations = await client.list_reservations()
except BookALimoError as e:
print(f"API Error: {e}")
print(f"Status Code: {e.status_code}")
print(f"Response Data: {e.response_data}")
Logging
By default, no log messages appear. Enable logging for debugging or monitoring.
Enable Debug Logging
import bookalimo
bookalimo.enable_debug_logging()
async with bookalimo.BookALimo(credentials) as client:
reservations = await client.list_reservations() # Shows API calls, timing, etc.
Or use the environment variable:
export BOOKALIMO_LOG_LEVEL=DEBUG
Custom Logging
import logging
import bookalimo
logging.basicConfig(level=logging.INFO)
bookalimo.get_logger().setLevel(logging.WARNING) # Production setting
Security
Sensitive data is automatically redacted in logs:
- Passwords, tokens, CVV codes:
****** - API keys:
abc123…89(first 6, last 2 chars) - Emails:
j***@example.com - Credit cards:
**** **** **** 1234
Disable Logging
bookalimo.disable_debug_logging()
Development
# Clone & setup
git clone https://github.com/yourusername/bookalimo-python.git
cd bookalimo-python
pip install -e ".[dev]"
pre-commit install
# Run tests
pytest
pytest --cov=bookalimo --cov-report=html
# Docs (MkDocs)
mkdocs serve
Security Notes
- Never log raw passwords or credit card numbers.
- Store credentials securely (e.g., environment variables, secrets managers).
License
This project is licensed under the MIT License — see LICENSE.
Changelog
See CHANGELOG.md for release history.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bookalimo-0.1.4.tar.gz.
File metadata
- Download URL: bookalimo-0.1.4.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9040be27f350595f9038778f437130fd3451c09ac77260905dded5cb4c7cd58
|
|
| MD5 |
62e199d34230fe25e1322814e1b2a028
|
|
| BLAKE2b-256 |
04e6a472e2f6f7850c13c2cda5afed348d2e831ae916b9943a4e31c105a09de3
|
File details
Details for the file bookalimo-0.1.4-py3-none-any.whl.
File metadata
- Download URL: bookalimo-0.1.4-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c53a2b7dadece8ecad30ee2d02cfc8477f77d249fbb5cf0acb277ac2f608d300
|
|
| MD5 |
309ba60d90a5ffdf4783e88c105da75e
|
|
| BLAKE2b-256 |
427c09dec69fd34fc29baeada557f2b39c395b1a381d9f8ba6bc07464e135959
|