Skip to main content

Infobús Python Client

PyPI version Python Support License: Apache 2.0

A Python client library and CLI tools for accessing Infobús external APIs and integrating transit data into research workflows.

Overview

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

Installation

# 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]"

Quick Start

Python Library

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()

Command Line Interface

# 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

Features

Core API Client

  • 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

Data Models

  • 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

CLI Tools

  • 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

Research Integration

  • Pandas Integration: Easy conversion to pandas DataFrames
  • Time Series Support: Built-in support for time-based analysis
  • Geospatial Data: Integration with geospatial libraries

Configuration

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"

Development

Setup Development Environment

# 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

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=infobus

# Run specific test file
pytest tests/test_client.py

Code Quality

# Format code
black src/ tests/
isort src/ tests/

# Type checking
mypy src/

# Run pre-commit checks
pre-commit run --all-files

API Reference

InfobusClient

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]

Data Models

  • RealtimeData: Real-time transit information
  • Route: Transit route information
  • Screen: Display screen information
  • Alert: Service alerts and notifications
  • Weather: Weather data for transit locations

Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Support

Metadata

Release files for infobus 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for infobus 0.1.0
File Size Uploaded Provenance Actions
infobus-0.1.0.tar.gz 16.2 kB Without provenance Details for infobus-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for infobus 0.1.0
File Interpreter ABI Platform Actions
infobus-0.1.0-py3-none-any.whl Python 3 none any Details for infobus-0.1.0-py3-none-any.whl

Total release size: 32.4 kB

Release files / infobus-0.1.0.tar.gz

Download URL infobus-0.1.0.tar.gz
Size 16.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9fbd5ddd4413d37b19748c2c22c12dc50b586191ed0bf83c1ed7ec6085e9096b
BLAKE2b-256 checksum
How to use checksums
bfd91b5c02d4ccf6ff90a96ba53c8e6472acccfdea6a126cc7c8bff7f58544aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Release files / infobus-0.1.0-py3-none-any.whl

Download URL infobus-0.1.0-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b2e0ba92386b1c54a2d48ab0648dcadfd7a24e0fe7b5ae5db9830fda26c899e
BLAKE2b-256 checksum
How to use checksums
5b142e05435c1f7653f8989825310bb198ebdb7139b7ec5e5f39dcf9d7465def
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.7

Security for infobus 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page