
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
enertalk-api-client
Advanced tools
The EnerTalk API Wrapper for convenience
Authentication must be perform by EnerTalk tokens based on OAuth2.
You can find a way to get tokens on our developer site.
> npm install enertalk-api-client
const EnerTalkAPI = require('enertalk-api-client');
or
import EnerTalkAPI from 'enertalk-api-client';
NOTE:
There's a compatibility issue.
If you're using webpack based project like create-react-app,
please use the build file as below:
const EnerTalkAPI = require('enertalk-api-client/build');
or
import EnerTalkAPI from 'enertalk-api-client/build';
const api = new EnerTalkAPI(authConfig, options);
api.getUser()
.then(response => console.log(response.data))
.catch(error => console.log(error.response.data));
Set the authConfig at the point of initialization.
const api = new EnerTalkAPI({
accessToken: 'yourAccessToken',
refreshToken: 'yourRefreshToken',
clientId: 'yourClientId',
clientSecret: 'yourClientSecret',
domain: 'yourCustomAuthServerDomain', // Default domain will be override
tokenUpdateFn: (tokenObject) => {
// The logic that update your token storage
// `tokenObject`has fields below:
// - `accessToken`
// - `refreshToken`
// - `expiresIn` (unit: second)
},
});
Or you can update the authConfig at any time.
api.updateAuthConfig({
accessToken: 'yourAccessToken',
refreshToken: 'yourRefreshToken',
// ...otherFields,
});
NOTES:
- The prameters
refreshToken,clientId,clientSecret,domainare used to issue new access token.tokenUpdateFnwill be called when a new token issued. You can sync the token object with your token storage.
This option follows axios request config.
For example,
const api = new EnerTalkAPI(authConfig, {
baseURL: 'yourCustomResourceServerDomain',
timeout: 10000,
});
You can pick specific categories by second or third option when construct instance.
For example,
const api = new EnerTalkAPI(authConfig, {
baseURL: 'yourCustomResourceServerDomain',
timeout: 10000,
}, ['bills', 'devices', 'usages']);
or apiConfig options can be omitted.
const api = new EnerTalkAPI(authConfig, ['bills', 'devices', 'usages']);
It's possible to pass single API Category
const api = new EnerTalkAPI(authConfig, 'bills');
Clicking on a category takes you to the api document.
| category | method | descriptions |
|---|---|---|
| [bills](https://developer.encoredtech.com/api2-bill/) | getBills(siteId:String) | Get billing information |
| updateBills(siteId:String, data:Object) | Update bill information | |
| getSuppliers() | List suppliers | |
| getRatePlanSchema(supplierId:String, ratePlanId:Number) | Get rate plan schema | |
| [devices](https://developer.encoredtech.com/api2-devices/) | listDevicesOfSite(siteId:String) | List devices of a site |
| createDevice(siteId:String, data:Object) | Create device | |
| getDevice(deviceId:String) | Get device | |
| updateDevice(deviceId:String, data:Object) | Update device | |
| replaceDevice(deviceId:String, data:Object) | Replace device | |
| deleteDevice(deviceId:String) | Delete device | |
| [push](https://developer.encoredtech.com/api2-push/) | registerPushId(data:Object) | Register push id |
| getPushInfo(params:Object) | Get push information | |
| updatePushStates(data:Object) | Update push states | |
| getPushStates() | Get push states | |
| resetPushToken(params: Object) | Reset push token | |
| [sites](https://developer.encoredtech.com/api2-sites/) | createSite(data:Object) | Create a site |
| listSites() | Get information of all sites belonging to a user | |
| getSite(siteId:String) | Get a site information for a user | |
| updateSite(siteId:String, data:Object) | Update a site Information for a user | |
| deleteSite(siteId:String) | Delete a site and its devices | |
| [tags](https://developer.encoredtech.com/api2-tags/) | createTag(siteId:String, data:Object) | Create a tag for the site |
| listTags(siteId:String) | List all tags of the site | |
| getTag(siteId:String, tagId:String) | ||
| updateTag(siteId:String, tagId:String, data:Object) | Update tag information | |
| deleteTag(siteId:String, tagId:String) | Delete a tag and untag its devices and channels | |
| tagDeviceOrChannel(tagId:String, deviceId:String, data:Object) | Tag or untag a device or channels | |
| [teams](https://developer.encoredtech.com/api2-teams/) | createTeam(data:Object) | Create a team |
| listTeams() | List all teams where authenticated user is a member | |
| getTeam(teamId:String) | Retrieve a team information | |
| updateTeam(teamId:String, data:Object) | Update team information | |
| deleteTeam(teamId:String) | Delete a team | |
| addTeamMemeber(teamId:Sring, data:Object) | Add a user to a team | |
| removeMember(teamId:String, data:Object) | Remove a member from a team | |
| [usages](https://developer.encoredtech.com/api2-usages/) | periodicUsagesBySite(siteId:String, params:Object) | Get usage from start to end time for a site, tag, or a device. |
| periodicUsagesByTag(siteId:String, tagId:String, params:Object) | ||
| periodicUsagesByDevice(deviceId:String, params:Object) | ||
| periodicUsagesByDeviceWithChannels(deviceId:String, params:Object) | ||
| billingUsagesBySite(siteId:String, params:Object) | Get usage and bill for billing periods from start to end time. | |
| billingUsagesByTag(siteId:String, tagId:String, params:Object) | ||
| billingUsagesByDevice(deviceId:String, params:Object) | ||
| billingUsagesByDeviceWithChannels(deviceId:String, params:Object) | ||
| realtimeUsagesBySite(siteId:String) | Get realtime usage information for a site, tag, or a device. | |
| realtimeUsagesByTag(siteId:String, tagId:String) | ||
| realtimeUsagesByDevice(deviceId:String) | ||
| realtimeUsagesByDeviceWithChannels(deviceId:String) | ||
| [users](https://developer.encoredtech.com/api2-users/) | getUser() | Get user information |
| updateUser(data:Object) | Update user information | |
| timelines | timelines(registrationId:String, params:Object) | Get timelines for a device |
| updateTimeline(registrationId:String, timelineId:Number, data:Object) | Update timeline | |
| timelinesBySite | timelinesBySite(siteId:String, params:Object) | Get timelines for a site |
| updateTimelineBySite(siteId:String, timelineId:Number, data:Object) | Update timeline for a site | |
| legacy | legacy(options:Object) | The bridge of old APIs |
These will continue to be added.
FAQs
The EnerTalk API Wrapper for convenience
We found that enertalk-api-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.