An API for the Open Bus Stride Project
- 💬 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
- 🗺️ Open Bus Map Search (Client App) - Live Website
- 📦 Open Bus API Client (API Package Generator) - NPM Package
- 🏗️ 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
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.
Use this if you prefer to run directly from your local Python environment.
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
You’ll need a database. You have two options:
- Option A: Start
stride-db
using 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
uvicorn open_bus_stride_api.main:app --reload
Access the interactive API docs at: 👉 http://localhost:8000/docs
All routes are defined in:
open_bus_stride_api/routers/<base_router_name>.py
@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.
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