FuelSpyder is a production-grade FastAPI application that aggregates real-time UK fuel price data from major retailers, providing a unified REST API for querying cheapest and cleanest fuel options by location.
- Concurrent Data Fetching: Async HTTP with
httpxandasyncio.gather()for fast aggregation - Normalized Data Format: Standardized schema across all providers
- Smart Caching: In-memory cache with configurable TTL (5 min default)
- Environmental Ratings: Fuel cleanliness ranking based on UK carbon intensity standards
- Robust Error Handling: Graceful degradation when providers fail
- Production Ready: Structured logging, health checks, Docker support
Currently Implemented:
- Asda
Planned (Phase 2):
- BP, Esso, Morrisons, Moto, Motor Fuel Group, Rontec, Sainsbury's, SGN, Shell, Tesco
GET /api/v1/prices
Fetches from all providers concurrently. Returns normalized station data with prices.
GET /api/v1/prices/{provider}
Fetches from a specific provider (e.g., /api/v1/prices/asda).
GET /api/v1/prices/providers/list
Returns all available provider names.
GET /api/v1/health
Health status for monitoring/orchestration.
-
Clone the repository:
git clone https://github.com/CodeKeanu/fuelspyder.git cd fuelspyder -
Install dependencies:
pip install -r requirements.txt
-
Run the app:
python -m app.main # Or with auto-reload: uvicorn app.main:app --reload -
Access the API:
- Visit http://localhost:8000 (redirects to docs)
- Interactive docs at http://localhost:8000/docs
- Alternative docs at http://localhost:8000/redoc
-
Build the image:
docker build -t fuelspyder:latest . -
Run the container:
docker run -d -p 8000:8000 --name fuelspyder fuelspyder:latest
-
Access the API:
curl http://localhost:8000/api/v1/pricescurl http://localhost:8000/api/v1/prices/asdacurl http://localhost:8000/api/v1/prices/providers/listCopy .env.example to .env and adjust settings:
cp .env.example .envKey settings:
CACHE_TTL_SECONDS: Cache duration (default: 300s)HTTP_TIMEOUT: Provider request timeout (default: 10s)LOG_LEVEL: Logging level (default: INFO)
app/
├── main.py # FastAPI application
├── config.py # Settings management
├── api/v1/
│ ├── router.py # API router aggregation
│ └── endpoints/ # API endpoints
├── schemas/ # Pydantic models
├── services/ # Business logic
│ ├── aggregator.py # Concurrent fetching
│ ├── http_client.py # Async HTTP
│ └── cache.py # In-memory caching
├── providers/ # Provider adapters
│ ├── base.py # Abstract base
│ ├── registry.py # Provider registry
│ └── asda.py # Asda implementation
└── core/ # Core utilities
├── exceptions.py # Custom exceptions
└── logging.py # Logging config
MIT License
Note: This project simply proxies public data from retailer APIs. Data accuracy and availability depend on the source sites.