Python wrapper for the Book-A-Limo API
Project description
Bookalimo Python SDK
A modern, fully-typed Python SDK for the Book-A-Limo transportation booking API with async/sync support, type safety, Google Places integration, and ergonomic resource management via context managers.
Important notes
- Docs are in preview: Many pages were AI-generated from the codebase and haven’t had a full manual review yet. In case of conflict, the code and docstrings are the source of truth. Please report issues you find.
- Terms & credentials: Use of Book-A-Limo API and Google APIs are subject to their respective Terms of Service.
Design philosophy: IDE-first DX
The library is comprehensively typed and richly documented via docstrings. Most users can rely on IDE hints, docstrings, and autocomplete without reading the docs.
Features
- Async & Sync Support – Choose the right client for your use case
- Type Safety – Full Pydantic models with validation
- Google Places Integration – Autocomplete, search, details, and geocoding
- Automatic Retry – Built-in exponential backoff for reliability
- Comprehensive Error Handling – Detailed exceptions with context
- Resource Management – Context managers for proper cleanup
Installation
pip install bookalimo
# With Google Places integration
pip install bookalimo[places]
Core API
Clients
AsyncBookalimo– Async client for high-concurrency applicationsBookalimo– Sync client for simple scripts and legacy code
Services
client.pricing– Get quotes and update booking detailsclient.reservations– Book, list, modify, and cancel reservationsclient.places– Google Places search and geocoding (optional)
Authentication
SHA256-based credential system with automatic password hashing:
from bookalimo.transport.auth import Credentials
# Agency account
agency = Credentials.create("AGENCY123", "password", is_customer=False)
# Customer account
customer = Credentials.create("user@email.com", "password", is_customer=True)
Booking Flow
- Get Pricing –
client.pricing.quote()returns session token + vehicle options - Update Details –
client.pricing.update_details()finalize booking details - Book Reservation –
client.reservations.book()confirms with payment
Quick Examples
Async example
import asyncio
from bookalimo import AsyncBookalimo
from bookalimo.transport.auth import Credentials
from bookalimo.schemas.booking import (
RateType,
Location,
LocationType,
Address,
City,
Airport,
)
async def book_ride():
credentials = Credentials.create("your_id", "your_password", is_customer=False)
pickup = Location(
type=LocationType.ADDRESS,
address=Address(
place_name="Empire State Building",
city=City(city_name="New York", country_code="US", state_code="NY"),
),
)
dropoff = Location(type=LocationType.AIRPORT, airport=Airport(iata_code="JFK"))
async with AsyncBookalimo(credentials=credentials) as client:
# 1) Get pricing
quote = await client.pricing.quote(
rate_type=RateType.P2P,
date_time="12/25/2024 03:00 PM",
pickup=pickup,
dropoff=dropoff,
passengers=2,
luggage=2,
)
# 2) Book reservation
booking = await client.reservations.book(
token=quote.token, method="charge" # or credit_card=CreditCard(...)
)
return booking.reservation_id
confirmation = asyncio.run(book_ride())
Sync example
from bookalimo import Bookalimo
from bookalimo.transport.auth import Credentials
credentials = Credentials.create("your_id", "your_password", is_customer=False)
with Bookalimo(credentials=credentials) as client:
quote = client.pricing.quote(...)
booking = client.reservations.book(token=quote.token, method="charge")
Rate Types & Options
from bookalimo.schemas.booking import RateType
# Point-to-point transfer
quote = await client.pricing.quote(
rate_type=RateType.P2P,
pickup=pickup_location,
dropoff=dropoff_location,
# ...
)
# Hourly service (minimum 2 hours)
quote = await client.pricing.quote(
rate_type=RateType.HOURLY,
hours=4,
pickup=pickup_location,
dropoff=pickup_location, # Same for hourly
# ...
)
# Daily service
quote = await client.pricing.quote(
rate_type=RateType.DAILY,
pickup=hotel_location,
dropoff=hotel_location,
# ...
)
Location Types
from bookalimo.schemas.booking import Location, LocationType, Address, Airport, City
# Street address
address_location = Location(
type=LocationType.ADDRESS,
address=Address(
place_name="Empire State Building",
street_name="350 5th Ave",
city=City(city_name="New York", country_code="US", state_code="NY"),
),
)
# Airport with flight details
airport_location = Location(
type=LocationType.AIRPORT,
airport=Airport(iata_code="JFK", flight_number="UA123", terminal="4"),
)
Google Places Integration (Recommended flow)
async with AsyncBookalimo(
credentials=credentials, google_places_api_key="your-google-places-key"
) as client:
# Search locations
results = await client.places.search("Hilton Miami Beach")
# OR
# autocomplete = await client.places.autocomplete(input="Hilton Miami Beach")
# top_result = autocomplete.suggestions[0].place_prediction.place
# top_result_place_id = top_result.id
# OR
# resolve_airport = await client.places.resolve_airport(query="Hilton Miami Beach")
# top_result = resolve_airport[0]
# iata_code = top_result.iata_code
# Get the top result
top_result = results[0]
# Get the top result geocode
# By place_id
top_result_place_id = top_result.google_place.id
top_result_geocode = await client.places.geocode(place_id=top_result_place_id)
# By lat-lng
top_result_geocode = await client.places.geocode(
lat=top_result.lat, lng=top_result.lng
)
# Convert to booking location
location = Location(
type=LocationType.ADDRESS,
address=Address(
google_geocode=top_result_geocode, place_name=top_result.formatted_address
),
)
(You can also search independent pickup/dropoff locations and feed them into the booking flow.)
Reservation Management
# List reservations
reservations = await client.reservations.list(is_archive=False)
# Get details
details = await client.reservations.get("ABC123")
# Modify reservation
edit_result = await client.reservations.edit(
confirmation="ABC123", passengers=3, pickup_date="12/26/2024"
)
# Cancel reservation
cancel_result = await client.reservations.edit(confirmation="ABC123", is_cancel=True)
Error Handling
from bookalimo.exceptions import (
BookalimoError, # base SDK error
BookalimoHTTPError, # HTTP/transport errors
BookalimoValidationError, # input/schema validation errors
)
try:
booking = await client.reservations.book(...)
except BookalimoValidationError as e:
print(f"Invalid input: {e.message}")
for error in e.errors():
print(f" {error['loc']}: {error['msg']}")
except BookalimoHTTPError as e:
if e.status_code == 401:
print("Authentication failed")
elif e.status_code == 400:
print(f"Bad request: {e.payload}")
else:
print(f"API error: {e}")
except BookalimoError as e:
print(f"SDK error: {e}")
Documentation
📖 Complete Documentation: https://asparagusbeef.github.io/bookalimo-python
- Quick Start Guide: https://asparagusbeef.github.io/bookalimo-python/guide/quickstart/
- API Reference: https://asparagusbeef.github.io/bookalimo-python/api/
- Examples: https://asparagusbeef.github.io/bookalimo-python/examples/basic/
Environment
export GOOGLE_PLACES_API_KEY="your_google_places_key"
export BOOKALIMO_LOG_LEVEL="DEBUG"
Requirements
- Python 3.9+
- Book-A-Limo API credentials
- Dependencies: httpx, pydantic, pycountry, us, airportsdata
- Optional: google-maps-places, google-api-core, numpy, rapidfuzz
Support & Resources
- GitHub: https://github.com/asparagusbeef/bookalimo-python
- PyPI: https://pypi.org/project/bookalimo/
- Issues: https://github.com/asparagusbeef/bookalimo-python/issues
- Changelog: CHANGELOG.md
License
MIT License — see LICENSE for details.
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-1.0.1.tar.gz.
File metadata
- Download URL: bookalimo-1.0.1.tar.gz
- Upload date:
- Size: 79.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e10b16c7f773723274670648ac8fe39a489de390d648a0526f9872a38498c809
|
|
| MD5 |
ac5208f5926290e3de31253b83bd9e68
|
|
| BLAKE2b-256 |
6313b94f60af59af1a8d76e7733f47d7f1dbb9c757e221759192e421ee6b7024
|
File details
Details for the file bookalimo-1.0.1-py3-none-any.whl.
File metadata
- Download URL: bookalimo-1.0.1-py3-none-any.whl
- Upload date:
- Size: 63.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2582b49bedb07f7f8ccd8aee08104e48733280d519ae72c9524264e9a1b2fa2c
|
|
| MD5 |
deb39304c79a24838841696aa5daa05b
|
|
| BLAKE2b-256 |
ab19fece4af6641e44be604acc96fac0c3c9e5500d7dd77042623e29bccc9ce6
|