π Open Bus Stride API
August 10, 2025 Β· View on GitHub
An API for the Open Bus Stride Project
π’ Get Involved
- π¬ For general help and system updates, join the Hasadna Slack: #open-bus channel
- π Found a bug or have a feature request? Open an issue
- π€ Want to contribute? See our contributing guidelines
π Related Projects
Frontend
- πΊοΈ Open Bus Map Search (Client App) - Live Website
- π¦ Open Bus API Client (API Package Generator) - NPM Package
Backend
- ποΈ Open Bus Pipelines
- π Open Bus Stride API (REST) β API Docs
- π§Ύ Open Bus Stride DB
- π§ Open Bus Stride ETL
- π Open Bus GTFS ETL
- π‘ Open Bus SIRI Requester
- π§ͺ Open Bus SIRI ETL
π οΈ Tech Stack
π Getting Started
Option 1: Using Docker Compose (Recommended)
The easiest way to get up and running is with Docker Compose.
Follow the instructions here.
For local development (e.g. making changes to the code), also see:
Develop stride-api from a local clone in the same document.
Option 2: Local Development (Manual Setup)
Use this if you prefer to run directly from your local Python environment.
1. Clone and Setup
Ensure you have Python 3.8 installed.
python3.8 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install --upgrade pip
pip install -r requirements-dev.txt
Ensure a local clone of open-bus-stride-db exists at:
../open-bus-stride-db
2. Database Connection
Youβll need a database. You have two options:
- Option A: Start
stride-dbusing the Docker Compose environment from open-bus-pipelines. - Option B: Connect to the production DB using Redash read-only credentials.
Create a .env file:
export SQLALCHEMY_URL=postgresql://postgres:123456@localhost
Then source it:
. .env
3. Run the API Server
uvicorn open_bus_stride_api.main:app --reload
Access the interactive API docs at: π http://localhost:8000/docs
π§© API Development
All routes are defined in:
open_bus_stride_api/routers/<base_router_name>.py
βοΈ Example API
@router.<http_method>("/<api_path>", tags=["<tag_name>"], response_model=<ResponseModel>)
def name(<filtering_params>, limit, offset):
return common.get_list(
<DBModel>, limit, offset,
[
{'type': <filter_type>, 'field': <DBModel>.<field>, 'value': <filter_param>},
]
)
- Filters: Defined in
routers/common.pyβget_list_query_filter_<filter_type>(Examples:'equal','date_in_range')
Always include limit and offset for pagination.
π§ͺ Running Tests
Set up your environment as described in the Local Development section above.
Install test dependencies:
pip install -r tests/requirements.txt
Ensure the DB contains full Stride data (production read-only access works).
Run tests:
pytest -svvx