A modern, production-ready Python implementation of the Open Charge Point Interface (OCPI) protocol built on FastAPI.
Supported OCPI versions: 2.3.0, 2.2.1, 2.1.1
OCPI Documentation: 2.3.0, 2.2.1, 2.1.1
- Full OCPI 2.3.0 support - Including the new Payments module
- OCPI 2.2.1 and 2.1.1 compatibility - Backward compatible with previous versions
- Modern stack - Built with FastAPI 0.115+ and Pydantic v2
- Complete role support - CPO, EMSP, and PTP (Payment Terminal Provider)
- Comprehensive modules - Locations, Sessions, CDRs, Tokens, Tariffs, Commands, Charging Profiles, Hub Client Info, Credentials, and Payments
- Production-ready - Extensive test coverage (83%+), async/await support, and robust error handling
- Type-safe - Full Pydantic v2 validation with modern Python 3.11+ features
uv pip install ocpi-pythonuv pip install git+https://github.com/elumobility/ocpi-python.git[project]
dependencies = [
"ocpi-python @ git+https://github.com/elumobility/ocpi-python.git",
]Then install with:
uv pip install -e .from ocpi import get_application
from ocpi.core.enums import RoleEnum, ModuleID
from ocpi.modules.versions.enums import VersionNumber
# Create OCPI application
app = get_application(
version_numbers=[VersionNumber.v_2_3_0],
roles=[RoleEnum.cpo],
modules=[ModuleID.locations],
)
# Run with: uvicorn main:app --reload| Module | 2.3.0 | 2.2.1 | 2.1.1 |
|---|---|---|---|
| Credentials | ✅ | ✅ | ✅ |
| Locations | ✅ | ✅ | ✅ |
| Sessions | ✅ | ✅ | ✅ |
| CDRs | ✅ | ✅ | ✅ |
| Tokens | ✅ | ✅ | ✅ |
| Tariffs | ✅ | ✅ | ✅ |
| Commands | ✅ | ✅ | ✅ |
| Charging Profiles | ✅ | ✅ | ❌ |
| Hub Client Info | ✅ | ✅ | ❌ |
| Payments | ✅ | ❌ | ❌ |
| Package | Version |
|---|---|
| Python | >=3.11 |
| Pydantic | >=2.0.0, <3.0.0 |
| pydantic-settings | >=2.0.0 |
| FastAPI | >=0.115.0, <1.0.0 |
| httpx | >=0.27.0 |
📚 Full Documentation - Complete API reference, tutorials, and examples
- Quick Start Guide
- LLM Assistance Guide - Tips for using AI coding assistants
- Tutorials
- API Reference
- Examples - Production-ready code examples
If you're using ChatGPT, Claude, GitHub Copilot, or Cursor, check out our LLM Assistance Guide for tips on getting the best results. The repository also includes a .cursorrules file for Cursor IDE users.
Contributions are welcome! Please read our Contributing Guide and Code of Conduct before submitting a Pull Request.
We welcome:
- 🐛 Bug reports
- 💡 Feature requests
- 📝 Documentation improvements
- 🧪 Test coverage improvements
- 🔧 Code refactoring
See our Issue Templates for guidelines on reporting bugs or requesting features.
This project is dual-licensed under:
- MIT License - Permissive, allows proprietary use
- European Union Public Licence (EUPL) v.1.2 - Copyleft, ideal for European public sector
You may use this software under either license at your choice. See LICENSE for full details.
This library is based on the excellent work from extrawest/extrawest_ocpi, with significant enhancements including OCPI 2.3.0 support, Pydantic v2 migration, and comprehensive test coverage.
Maintainer: ELU Mobility
