- Field of use
- Description
- Maven
- Requirements
- Installation
- Getting Started
- Use in Spring Boot App
- API Endpoints
- Models
- Authentication and Authorization
- Recommendation
- License
- About Extrawest.com
Client library for OCPI CPO Server. Library for OCPI eMSP can be found here.
This API exposes endpoints to manage OCPI entities. Open Charge Point Interface (OCPI) is an open protocol used for connections between charging station operators and service providers. Simply put, this protocol facilitates automated roaming for EV drivers between different EV charging networks.
Automatically generated by the OpenAPI Generator as a client library for OCPI CPO Server Library
With this library, you can easily get started with the Open Charge-Point Interface by making calls to OCPI CPO Server API. It is a client to OCPI CPO Server OCPI CPO Server Library, generated by OpenAPI Generator
Please note, this is a library and not an application, so there is no main method.
Currently we support 2.2.1 OCPI version.
Find the maven repo here: https://mvnrepository.com/artifact/com.extrawest/Extrawest-OCPI-2.2.1-CPO-Client
Building the API client library requires:
- Java 1.8+
- Maven
To install the API client library to your local Maven repository, simply execute:
mvn clean install
Add this dependency to your project's POM:
<dependency>
<groupId>com.extrawest</groupId>
<artifactId>Extrawest-OCPI-2.2.1-CPO-Client</artifactId>
<scope>compile</scope>
</dependency>
At first generate the JAR by executing:
mvn clean package
Then manually install the following JARs:
target/Extrawest-OCPI-2.2.1-CPO-Client-2023.8.18.jar
target/lib/*.jar
Please follow the installation instruction and execute the following Java code:
import com.extrawest.ocpi.cpo.client.invoker.*;
import com.extrawest.ocpi.cpo.client.invoker.auth.*;
import com.extrawest.ocpi.cpo.client.model.*;
import com.extrawest.ocpi.cpo.client.api.ClientInfoControllerApi;
public class ClientInfoControllerApiExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost:8080");
ClientInfoControllerApi apiInstance = new ClientInfoControllerApi(defaultClient);
String countryCode = "countryCode_example";
String partyId = "partyId_example";
try {
ClientInfoDTO result = apiInstance.getHubClientInfo(countryCode, partyId);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling ClientInfoControllerApi#getHubClientInfo");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
- To access the CPO API classes, we need to configure them as beans:
@Configuration
public class CpoClientConfig {
@Bean
public CpoTariffControllerApi cpoTariffControllerApi() {
return new CpoTariffControllerApi(apiClient());
}
@Bean
public ApiClient apiClient() {
ApiClient apiClient = new ApiClient();
apiClient.setBasePath("http://ocpi-server-api-url/");
return apiClient;
}
}
- Since we configured our API classes as beans, we can freely inject them in our Spring-managed classes:
@Service
public class CpoTariffServiceImpl implements CpoTariffService {
@Autowired
private CpoTariffControllerApi cpoTariffControllerApi;
@Override
public List<TariffDto> getTariffs() {
try {
return cpoTariffControllerApi.getTariffs(OffsetDateTime.now().minusDays(10), OffsetDateTime.now().minusDays(1), 1, 10);
} catch (RestClientException e) {
throw new RuntimeException();
}
}
}
Spring Boot application, where we have tested Extrawest-OCPI-2.2.1-CPO-Client, has below Spring dependencies. In case of library and your project dependencies versions incompatibility, try to add next spring versions into you projects:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.3.24</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.24</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.3.24</version>
</dependency>
All URIs are relative to http://localhost:8080
Class | Method | HTTP request | Description |
---|---|---|---|
ClientInfoApi | getHubClientInfo | GET /api/2.2.1/hubClientInfo/{country_code}/{party_id} | |
ClientInfoApi | putHubClientInfo | PUT /api/2.2.1/hubClientInfo/{country_code}/{party_id} | |
CpoCdrApi | getCdr | GET /cpo/api/2.2.1/cdr | |
CpoChargingProfilesApi | deleteChargingProfile | DELETE /cpo/api/2.2.1/chargingProfiles/{session_id}/{response_url} | |
CpoChargingProfilesApi | getChargingProfile | GET /cpo/api/2.2.1/chargingProfiles/{session_id}/{duration}/{response_url} | |
CpoChargingProfilesApi | putChargingProfile | PUT /cpo/api/2.2.1/chargingProfiles/{session_id} | |
CpoCommandsApi | postCommand | POST /cpo/api/2.2.1/commands/{command} | |
CpoCredentialsApi | deleteCredentials | DELETE /cpo/api/2.2.1/credentials | |
CpoCredentialsApi | getCredentials | GET /cpo/api/2.2.1/credentials | |
CpoCredentialsApi | postCredentials | POST /cpo/api/2.2.1/credentials | |
CpoCredentialsApi | putCredentials | PUT /cpo/api/2.2.1/credentials | |
CpoLocationApi | getConnector | GET /cpo/api/2.2.1/locations/{location_id}/{evse_uid}/{connector_id} | |
CpoLocationApi | getEvse | GET /cpo/api/2.2.1/locations/{location_id}/{evse_uid} | |
CpoLocationApi | getLocation | GET /cpo/api/2.2.1/locations/{location_id} | |
CpoLocationApi | getLocations | GET /cpo/api/2.2.1/locations | |
CpoSessionsApi | getSessions | GET /cpo/api/2.2.1/sessions | |
CpoSessionsApi | putChargingPreferences | PUT /cpo/api/2.2.1/sessions | |
CpoTariffApi | getTariffs | GET /cpo/api/2.2.1/tariffs | |
CpoTokensApi | getToken | GET /cpo/api/2.2.1/tokens/{country_code}/{party_id}/{token_uid}/{type} | |
CpoTokensApi | patchToken | PATCH /cpo/api/2.2.1/tokens/{country_code}/{party_id}/{token_uid}/{type} | |
CpoTokensApi | putToken | PUT /cpo/api/2.2.1/tokens/{country_code}/{party_id}/{token_uid}/{type} | |
CpoVersionApi | getVersionDetails | GET /cpo/api/versions/details | |
CpoVersionApi | getVersions | GET /cpo/api/versions | |
HubClientInfoApi | getClientInfoList | GET /hub/api/2.2.1/hubClientInfo |
- AbstractCommand
- AdditionalGeoLocation
- BusinessDetails
- CDRDto
- CdrDimension
- CdrLocation
- CdrToken
- ChargingPeriod
- ChargingPreferences
- ChargingProfile
- ChargingProfilePeriod
- ChargingProfileResponse
- ClientInfoDto
- CommandResponse
- Connector
- CredentialsDto
- CredentialsRole
- DisplayText
- EVSE
- Endpoint
- EnergyContract
- EnergyMix
- EnergySource
- EnvironmentalImpact
- ExceptionalPeriod
- GeoLocation
- Hours
- Image
- Location
- Price
- PriceComponent
- PublishTokenType
- RegularHours
- ResponseFormatChargingPreferences
- ResponseFormatChargingProfileResponse
- ResponseFormatCommandResponse
- ResponseFormatCredentialsDto
- ResponseFormatListCDRDto
- ResponseFormatListClientInfoDto
- ResponseFormatListLocation
- ResponseFormatListSessionDto
- ResponseFormatListTariffDto
- ResponseFormatListVersionDto
- ResponseFormatLocationData
- ResponseFormatObject
- ResponseFormatTokenDto
- ResponseFormatVersionDetailsDto
- SessionDto
- SetChargingProfile
- SignedData
- SignedValue
- StatusSchedule
- TariffDto
- TariffElement
- TariffRestrictions
- TokenDto
- VersionDetailsDto
- VersionDto
All endpoints do not require authorization or authentication.
It's recommended to create an instance of ApiClient
per thread in a multithreaded environment to avoid any potential issues.
We are devoted to push the marked for vehicles charging forward. There are many standards out there, we intend to implement and share them. Any help is much appreciated!
The market is in its defining state, the practices and standards we come up with now, may very well stick around for decades to come.
See our vision at https://www.extrawest.com/