hcb_soap_client
A Python async SOAP client for the "Here Comes the Bus" API, used to track school bus locations and schedules.
Installation
pip install hcb_soap_client
Or install from source:
git clone https://github.com/pcartwright81/hcb_soap_client.git
cd hcb_soap_client
pip install -e .
Usage
Basic Usage (Context Manager - Recommended)
Using the async context manager is the most efficient approach as it reuses the HTTP session across multiple requests:
import asyncio
from hcb_soap_client import HcbSoapClient
async def main():
async with HcbSoapClient() as client:
# Get school ID from school code
school_id = await client.get_school_id("YOUR_SCHOOL_CODE")
# Login and get parent/account info
account = await client.get_parent_info(school_id, "username", "password")
print(f"Account ID: {account.account_id}")
print(f"Students: {[s.first_name for s in account.students]}")
# Get bus stop info for a student
for student in account.students:
# Use AM_ID for morning routes, PM_ID for afternoon
stops = await client.get_stop_info(
school_id,
account.account_id,
student.student_id,
HcbSoapClient.AM_ID # or HcbSoapClient.PM_ID
)
if stops.vehicle_location:
print(f"Bus location: {stops.vehicle_location.address}")
print(f"Speed: {stops.vehicle_location.speed} mph")
asyncio.run(main())
Simple Usage (Without Context Manager)
For one-off requests, you can use the client without a context manager. Note that this creates a new HTTP session for each request:
async def simple_example():
client = HcbSoapClient()
school_id = await client.get_school_id("YOUR_SCHOOL_CODE")
Using a Custom Session
You can provide your own aiohttp.ClientSession for advanced use cases:
import aiohttp
async def custom_session_example():
async with aiohttp.ClientSession() as session:
client = HcbSoapClient(session=session)
school_id = await client.get_school_id("YOUR_SCHOOL_CODE")
API Reference
HcbSoapClient
Constructor
HcbSoapClient(url: str | None = None, session: aiohttp.ClientSession | None = None)
url: Optional custom API endpoint (defaults to production URL)session: Optional aiohttp session to reuse
Class Attributes
AM_ID: Time of day ID for morning routesPM_ID: Time of day ID for afternoon routes
Methods
get_school_id(school_code: str) -> str
Look up the school ID from a school code.
get_parent_info(school_id: str, username: str, password: str) -> AccountResponse
Authenticate and retrieve account information including students and time of day options.
get_stop_info(school_id: str, parent_id: str, student_id: str, time_of_day_id: str) -> StopResponse
Get bus stop information and current vehicle location for a student.
Response Models
All response models are Pydantic BaseModel instances.
AccountResponse
account_id: strstudents: list[Student]times: list[TimeOfDay]
Student
student_id: strfirst_name: strlast_name: str
StopResponse
vehicle_location: VehicleLocation | Nonestudent_stops: list[StudentStop]
VehicleLocation
name: str- Vehicle/bus namelatitude: floatlongitude: floatlog_time: datetimespeed: intheading: straddress: strignition: booldisplay_on_map: bool
Development
Install development dependencies
pip install -e ".[dev,test]"
Run tests
pytest
Run linter
ruff check .
License
MIT License - see LICENSE for details.
Metadata
Release files for hcb-soap-client 0.1.5
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 | Actions |
|---|---|---|---|---|
| hcb_soap_client-0.1.5.tar.gz | 11.9 kB | Without provenance | Details for hcb_soap_client-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hcb_soap_client-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for hcb_soap_client-0.1.5-py3-none-any.whl |
Total release size: 25.9 kB
Release files / hcb_soap_client-0.1.5.tar.gz
| Download URL | hcb_soap_client-0.1.5.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
659a59cd6dc89b7ac2456f250ac40ffdec86200caf75941ac19346a7f1680ac7
|
|
BLAKE2b-256 checksum How to use checksums |
da48f66e713423ec7efce6c3256cb729e4f4324a3c4306ba722b54d7bc7131e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / hcb_soap_client-0.1.5-py3-none-any.whl
| Download URL | hcb_soap_client-0.1.5-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bec246f2d9aa03b34715c81182e0239d0c1a89a0d70702de5ee761e5dc8ce1e9
|
|
BLAKE2b-256 checksum How to use checksums |
b3609eb6273f7ea6e1a1c136a4803e1494a856c5d56ac866d443e1a289149c55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for hcb-soap-client 0.1.5
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.