
A Python client library and CLI tools for accessing Infobús external APIs and integrating transit data into research workflows.
The infobus
package provides a simple and efficient way to interact with Infobús APIs, enabling researchers and developers to:
- Access real-time transit data from public transportation systems
- Retrieve historical transit information for analysis
- Integrate GTFS Realtime feeds into research workflows
- Query screen and display information
- Access weather and alert data associated with transit stops
# Install from PyPI (when available)
pip install infobus
# Install from source
pip install git+https://github.com/simovilab/infobus-py.git
# Development installation
git clone https://github.com/simovilab/infobus-py.git
cd infobus-py
pip install -e ".[dev]"
from infobus import InfobusClient
# Initialize client
client = InfobusClient(base_url="https://your-infobus-instance.com")
# Get real-time transit data
transit_data = client.get_realtime_data()
# Query specific routes
route_info = client.get_route(route_id="route_123")
# Get screen information
screens = client.get_screens()
# Get help
infobus --help
# List available routes
infobus routes list
# Get real-time data for a specific route
infobus realtime --route-id route_123
# Export data to CSV
infobus export --format csv --output data.csv
- RESTful API Integration: Clean interface to Infobús REST endpoints
- Authentication Support: Token-based authentication handling
- Error Handling: Comprehensive error handling with meaningful messages
- Rate Limiting: Built-in rate limiting and retry logic
- Pydantic Models: Type-safe data models for all API responses
- GTFS Compatibility: Models aligned with GTFS and GTFS Realtime specifications
- Validation: Automatic data validation and serialization
- Interactive Commands: Easy-to-use command-line interface
- Data Export: Export data in multiple formats (JSON, CSV, XML)
- Batch Operations: Process multiple requests efficiently
- Configuration Management: Store and manage API credentials
- Pandas Integration: Easy conversion to pandas DataFrames
- Time Series Support: Built-in support for time-based analysis
- Geospatial Data: Integration with geospatial libraries
Create a configuration file at ~/.infobus/config.yaml
:
api:
base_url: "https://your-infobus-instance.com"
token: "your-api-token"
timeout: 30
logging:
level: "INFO"
format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
# Clone repository
git clone https://github.com/simovilab/infobus-py.git
cd infobus-py
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run all tests
pytest
# Run with coverage
pytest --cov=infobus
# Run specific test file
pytest tests/test_client.py
# Format code
black src/ tests/
isort src/ tests/
# Type checking
mypy src/
# Run pre-commit checks
pre-commit run --all-files
The main client class for interacting with Infobús APIs.
class InfobusClient:
def __init__(self, base_url: str, token: str = None, timeout: int = 30)
def get_realtime_data(self, **filters) -> List[RealtimeData]
def get_routes(self) -> List[Route]
def get_route(self, route_id: str) -> Route
def get_screens(self) -> List[Screen]
def get_alerts(self) -> List[Alert]
RealtimeData
: Real-time transit informationRoute
: Transit route informationScreen
: Display screen informationAlert
: Service alerts and notificationsWeather
: Weather data for transit locations
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
- Documentation: GitHub README
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Infobús Server - The main Infobús Django application
- django-app-gtfs - GTFS data models for Django