This directory contains complete, working examples demonstrating different use cases of OCPI Python.
A simple Charge Point Operator application that manages charging locations. Perfect for getting started.
Features:
- Location management (CRUD operations)
- Simple in-memory storage
- Basic authentication
An eMobility Service Provider application that manages charging sessions and token authorization.
Features:
- Session lifecycle management
- Token authorization
- Session tracking
A complete Charge Point Operator application with multiple modules.
Features:
- Locations management
- Sessions tracking
- CDR generation
- Tariff management
- Command handling
Smart charging control using charging profiles (OCPI 2.2.1+).
Features:
- Set charging profiles
- Get active charging profiles
- Clear charging profiles
- Smart charging control
EV charging reservation system using the OCPI 2.3.0 Booking extension.
Features:
- Create booking reservations
- Manage booking lifecycle (pending → confirmed → active → completed)
- Cancel/update bookings
- OCPI 2.3.0 specific module
Each example is self-contained and can be run independently:
cd examples/<example_name>
uvicorn main:app --reloadEach example includes:
- Complete working code
- README with usage instructions
- Test files to verify functionality
Run the tests:
# From the project root
pytest tests/test_examples/These examples use simple in-memory storage for demonstration purposes. For production use:
- Replace storage - Use a real database (PostgreSQL, MongoDB, etc.)
- Secure authentication - Implement proper token management and validation
- Add error handling - Implement comprehensive error handling and logging
- Add monitoring - Add metrics, logging, and monitoring
- Configure properly - Use environment variables for configuration
- Add tests - Write comprehensive test suites
After exploring these examples:
- Check out the Tutorials for detailed guides
- Read the API Reference for complete endpoint documentation
- Review the Quick Start Guide for setup instructions