API Integration
This project requires several APIs. some of API is free to use without API keys Some of API is free, but need an API Key. All keys are stored locally and never transmitted to third parties. If you scale up with large amount of API request, you need a commercial usage aggrement with API Provider to get large volume request available API Keys.
Required API Keysβ
Overviewβ
- Google Geolocation API: Location detection (requires key)
- RMV Transport API: German public transport data (requires key)
- Open-Meteo Weather API: Weather data via DWD (free, no key)
- OpenStreetMap Nominatim: Location names (free, no key)
1. Basic Setup for API Keys Encryptionβ
All API Keys must be encrypted in AES-128-CBC.
ENCRYPTION_KEY is used to encrypt/decrypt the API keys stored in the device.
For detail on how to encrypt the API Keys, see: https://github.com/gogo-boot/aes-demo
cp include/secrets/general_secrets.h.example include/secrets/general_secrets.h
1. Google Geolocation APIβ
Purpose: Automatic approximate longitude latitude location detection.
Setup Steps:β
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Geolocation API
- Create credentials (API Key)
- Restrict the API key to Geolocation API only (recommended)
- Encrypt the API Key with Encryption Key
Configuration:β
// include/secrets/general_secrets.h
#pragma once
#define GOOGLE_API_KEY "your_google_api_key_here"
Cost:β
- Free tier: 40,000 requests/month
- Usage: ~1 request per device setup (one-time)
2. RMV Transport APIβ
Purpose:
- Getting nearby Stations by geo coordinate information
- Real-time public transport departure information
Setup Steps:β
- Visit RMV Open Data Portal
- Register for an account
- Request API access for HAFAS API
- Obtain your API key
- Encrypt the API Key with Encryption Key
Configuration:β
// include/secrets/general_secrets.h
#pragma once
#define RMV_API_KEY "your_rmv_api_key_here"
Coverage:β
- Region: Hesse, Germany (Frankfurt, Wiesbaden, Kassel, etc.)
- Transport: Trains, buses, trams, subways
- Cost: Free for non-commercial use
3. Open-Meteo Weather APIβ
Purpose: Weather information using DWD (German Weather Service) data by longitude and latitude
Setup:β
No API key required - Open-Meteo provides free access to DWD weather data.
Configuration:β
Already configured in src/api/dwd_weather_api.cpp:
Setup Steps:β
- visit https://open-meteo.com/
- read docs and test several online API calls
Coverage:β
- Region: Germany and surrounding European areas
- Data: Temperature, humidity, precipitation, weather conditions, forecasts
- Cost: Free (up to 10,000 requests/day)
- Rate Limits: 10,000 API calls per day, 5,000 per hour
Features:β
- Real-time weather data from DWD
- Hourly forecasts up to 7 days
- Historical weather data
- No registration required
4. OpenStreetMap Nominatim APIβ
Purpose: It is used by application configuration
- Getting City/Town Name from geocoding coordinates while application configuration
- Getting longitude/latitude from City/Town Name while application configuration
Setup:β
Visit https://nominatim.org/ and read documentation. No API key required - Nominatim is free and open source.
Configuration:β
Already configured in the location detection code:
Coverage:β
- Global: Worldwide coverage from OpenStreetMap data
- Cost: Free
- Rate Limits: 1 request per second (respected by the device)
- Usage Policy: Must include proper attribution, reasonable use
Important Notes:β
- Fair Use Policy: Nominatim is provided as a free service
- Rate Limiting: Device automatically respects 1 request/second limit
- Attribution: OpenStreetMap data contributors are credited
- Backup Options: For high-volume applications, consider self-hosting
API Key Securityβ
Best Practicesβ
-
Never commit secrets to Git
- Use
.gitignoreto excludeinclude/secrets/general_secrets.h(except examples) - Check your repository history for accidentally committed keys
- Use
-
Restrict API key permissions
- Google: Limit to Geolocation API only
- RMV: Use for personal/development purposes only
-
Monitor usage
- Check Google Cloud Console for unexpected usage
- Monitor RMV API quotas
Other Transport APIsβ
According to recent reports, RMV and NRW public transport systems have been experiencing high delays and cancellations: https://www.adac.de/news/test-oepnv-ausfaelle-verspaetungen/ NRW API implementation will be followed up in future releases.
Germanyβ
- DB API - Deutsche Bahn (national railways) : cost near 4000 Euros, to get one API access (State 2025)
- RMV API - Rhein-Main transport (default) : 67% S-Bahn on-time rate (less than 3 minutes delay)
- NRW API - North Rhine-Westphalia transport : KΓΆln, DΓΌsseldorf, Dortmund
- VBB API - Berlin-Brandenburg transport
- MVV API - Munich transport
- HVV API - Hamburg transport : over 95% high on-time rate in public transport, may not need to implement
Internationalβ
- GTFS - General Transit Feed Specification (worldwide)
- TfL API - Transport for London
- RATP API - Paris transport
- SL API - Stockholm transport
Adapting for Other APIsβ
- Create new API files in
src/api/ - Implement similar functions to
rmv_api.cpp - Update configuration to use new API
- Add new secrets file if required
Next Stepsβ
After setting up API keys:
- Development Setup - Set up your development environment
- Configuration Layers - Understanding configuration system
- Run Book - Operational procedures and commands