Socket
Socket
Sign inDemoInstall

node-ocpi

Package Overview
Dependencies
6
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-ocpi

An OCPI library for Node.js


Version published
Weekly downloads
21
increased by31.25%
Maintainers
1
Install size
680 kB
Created
Weekly downloads
 

Readme

Source

node-ocpi Library Documentation

Overview

node-ocpi is a Node.js library designed for the implementation of the Open Charge Point Interface (OCPI) protocol. It provides structured models and validation for various OCPI entities, making it ideal for developers building applications for EV charging stations and related services.

Features

  • Models for key OCPI entities: Location, EVSE, Connector, CDR, Command, Transaction, Feedback, Meter, Reservation, Tariff, User.
  • Comprehensive validation for OCPI-compliant data structures.
  • Supports a wide range of OCPI operations and functionalities.

Installation

You can install node-ocpi using npm with the following command:

npm install https://github.com/hyndex/node-ocpi

This command fetches and installs the library directly from the specified GitHub repository.

Usage

Import the models you need from the node-ocpi library as follows:

const { Location, EVSE, Connector, CDR, Command, Transaction, Feedback, Meter, Reservation, Tariff, User } = require('node-ocpi');

Model Usage Examples

Below are examples showing how to create instances of each model and perform data validation:

Location
const location = new Location('loc1', 'ON_STREET', 'Main Street Charging Station', '123 Main St', 'Anytown', '12345', 'USA', { latitude: 52.520008, longitude: 13.404954 });
location.validate();
EVSE
const evse = new EVSE('evse1', 'loc1', 'AVAILABLE', ['CHADEMO']);
evse.validate();
Connector
const connector = new Connector('1', 'IEC_62196_T2', 'CABLE', 'AC_3_PHASE', 400, 16, 0);
connector.validate();
CDR
const cdr = new CDR('cdr1', new Date(), new Date(), 'session1', 'token1', 'authMethod1', { id: 'loc1', address: '123 Main St' }, 'evse1', '1', 'meter1', 'EUR', 15.00);
cdr.validate();
Command
const command = new Command('cmd1', 'START_TRANSACTION', { connectorId: '1', idTag: 'tag1' });
command.validate();
Transaction
const transaction = new Transaction('txn1', 'tag1', new Date(), 100, 'loc1', 'evse1', '1');
transaction.validate();
Feedback
const feedback = new Feedback('feedback1', 'user1', 'Great charging station!', 5);
feedback.validate();
Meter
const meter = new Meter('meter1', 500, new Date());
meter.validate();
Reservation
const reservation = new Reservation('res1', new Date(), new Date(), 'loc1', 'evse1', 'tag1');
reservation.validate();
Tariff
const tariff = new Tariff('tariff1', 'EUR', [{ type: 'TIME', price: 2.00 }]);
tariff.validate();
User
const user = new User('user1', 'John Doe', 'john.doe@example.com', true);
user.validate();

Contributing

Contributions to node-ocpi are always welcome. To contribute:

  1. Fork the repository.
  2. Create a new branch for your feature.
  3. Implement your feature or bug fix.
  4. Write or adapt tests as needed.
  5. Update the documentation.
  6. Commit and push your changes.
  7. Submit a pull request.

License

node-ocpi is released under the MIT License. See the LICENSE file for more details.

FAQs

Last updated on 24 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc