npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

srp-data-api

v1.4.0

Published

package for data extraction from SRP company for getting utility data

Downloads

17

Readme

srp-data-api

npm package for SRP company for data extraction

  • This package contains two methods of data extraction
  1. getServiceAccounts - It gives the response in the form of list of service-accounts related to given user-account
  2. getMonthlyUtilityData - It gives the response in the form of list of monthly-utility-data for given service-account

Installation

npm i srp-data-api --save

How to use?

import { SRPUtilityDataService } from 'srp-data-api';
const srpUtilityDataService = new SRPUtilityDataService();

const payload: GetDataPayload = {
    password: string;
    username: string;
  };

const res = await srpUtilityDataService.getServiceAccounts(payload)

After data extraction, we will get response as -

res: UtilityUserAccountResponse = {
      id: string
      name: string
      serviceAccounts[]: [{id:string, address:Address}]
    };
const res = await srpUtilityDataService.getMonthlyUtilityData(payload)

After data extraction, we will get response as -

res: MonthlyUtilityData[] = {
      _id: string
      amountInCents: number
      energyConsumptionInWatts: number
      month: string
      serviceAccountId: string
      year: number
  };

Methods

    getServiceAccounts: (
      payload: GetDataPayload,
    ) => Promise<UtilityUserAccountResponse>;

    getMonthlyUtilityData: (
      payload: GetDataPayload,
    ) => Promise<MonthlyUtilityData[]>;

    setProxy:(proxy: string[]) => Promise<void>

Options

GetDataPayload = {
    password: string;
    username: string;
  };

WHERE,
password: password of the user-account
username: username of the user-account

proxy:string[]

WHERE,
proxy: VGS proxy we set

Responses

UtilityUserAccountResponse = {
      id: string
      name: string
      serviceAccounts[]: [{id:string, address:Address}]
    };

WHERE,
id: user-account id
name: Name of the user
serviceAccounts[]: List of service-accounts which are linked to given user-account id
MonthlyUtilityData[] = {
      _id: string
      amountInCents: number
      energyConsumptionInWatts: number
      month: string
      serviceAccountId: string
      year: number
  };

WHERE,
_id: id of monthly utility data model
amountInCents: Cost of electricity used in respective month and year in cents
energyConsumptionInWatts: Amount of electricity consumed in respective month and year in watts
month: Month of year for which utility data is extracted
serviceAccountId: service-account id for which utility data is extracted
year: Year of calender for which utility data is extracted

Scripts

  • npm run build - For building the app.
  • npm run test - Run automated test cases via mocha and chai.
  • npm run start - For starting the app.
  • npm run serve - For building and starting the app with auto-reload on changes.
  • npm run lint - To perform linting

Overview

  • Typescript support

  • Environment specific configuation support. The application use config npm module.

  • Linting support

npm run lint

Error Handling

  • If we pass incorrect credentials for getting utility-data, then...
import { SRPUtilityDataService } from 'srp-data-api';
const srpUtilityDataService = new SRPUtilityDataService();

const payload: GetDataPayload = {
    password: incorrect-username;
    username: incorrect-password;
  };

const res = await srpUtilityDataService.getServiceAccounts(payload)

  • The Promise gets rejected with AuthenticationError with message - The user name or password is incorrect.

  • If we pass correct credentials for getting utility-data, but data extraction failed and service cannot extract data, then...

import { SRPUtilityDataService } from 'srp-data-api';
const srpUtilityDataService = new SRPUtilityDataService();

const payload: GetDataPayload = {
    password: correct-username;
    username: correct-password;
  };

const res = await srpUtilityDataService.getMonthlyUtilityData(payload)
  • The Promise gets rejected with DataExtractionError with message - Failed to extract data