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 🙏

© 2025 – Pkg Stats / Ryan Hefner

energy-price-fetcher

v0.2.0

Published

Lightweight utilities for fetching and normalising European day-ahead electricity prices

Downloads

30

Readme

energy-price-fetcher

Minimal utilities for fetching and normalising Nordic day-ahead electricity prices. Pick a provider order, and receive a consistent JSON object with hourly or 15-minute prices.

Install

npm install energy-price-fetcher

Quick start

const { fetchDayAheadPrices } = require('energy-price-fetcher');

async function main() {
  const today = new Date().toISOString().slice(0, 10); // YYYY-MM-DD
  const prices = await fetchDayAheadPrices({
    region: 'NO1',
    currency: 'NOK',
    date: today,
    interval: '1h',
    prefer: 'nordpool',
    entsoeToken: process.env.ENTSOE_TOKEN,
  });

  console.log(prices.priceDate, prices.priceProvider);
  console.log(prices.daily);
}

main().catch((error) => {
  console.error(error.message);
  process.exit(1);
});

API

fetchDayAheadPrices(options)

Fetch day-ahead spot prices and return a normalised structure.

| option | type | default | description | | --- | --- | --- | --- | | region | string | required | Nord Pool bidding zone (e.g. NO1, NO2, SE3) | | currency | string | "NOK" | Output currency. The library converts ENTSO-E EUR prices using a currency provider when required. | | date | string | today | ISO date (YYYY-MM-DD) to fetch | | interval | string | "1h" | Resolution of the output series, "1h" or "15m" | | prefer | string | "nordpool" | Preferred source ("nordpool", "entsoe") | | providers | array | auto | Override the fallback order by passing an array of providers | | entsoeToken | string | null | Required to call the ENTSO-E API (if omitted, ENTSO-E is skipped) | | getCurrencyRate | function | null | Async function like (currencyCode) => number returning a conversion rate; if omitted and conversion is needed the built-in provider from currency-rate-fetcher kicks in (defaults to ECB data). | | currencyFetcherOptions | object | {} | Options for the built-in currency provider (forwarded to currency-rate-fetcher, e.g. { provider: "frc", baseCurrency: "EUR" } or { provider: "oxr", providerOptions: { appId: process.env.OXR_TOKEN } }). | | baseUrls | object | internal defaults | Override source URLs ({ nordpool, entsoe }) |

Response shape

{
  "priceDate": "2025-10-14",
  "priceProvider": "Nord Pool",
  "priceProviderUrl": "https://…",
  "hourly": [
    {
      "startTime": "2025-10-14T00:00:00+02:00",
      "endTime": "2025-10-14T01:00:00+02:00",
      "spotPrice": 0.4276
    }
  ],
  "daily": {
    "minPrice": 0.1221,
    "maxPrice": 0.4998,
    "avgPrice": 0.2684,
    "peakPrice": 0.3945,
    "offPeakPrice1": 0.1882,
    "offPeakPrice2": 0.1736
  }
}

Hourly entries contain only spot prices; downstream applications can layer VAT, grid tariffs, contracts, or subsidies however they like.

Examples

  • examples/cli-fetch.js — simple CLI that fetches today’s prices and prints the daily summary.
  • examples/rest-server.js — minimal Express server exposing GET /api/prices?region=NO1&date=YYYY-MM-DD.

Currency helpers

  • createCurrencyRateProvider(options) returns an async (code) => rate function and is exported for custom use. Internally it calls the published currency-rate-fetcher package (ECB by default, but you can switch providers through options.provider or pass the same currencyFetcherOptions used elsewhere).
  • fetchCurrencies(provider, base, options) and fetchCurrency(provider, currency, base, options) proxy the helpers from currency-rate-fetcher for convenience.

Notes on data sources

  • Nord Pool is the canonical source; it returns 1h or 15m data in the requested currency.
  • ENTSO-E mirrors Nord Pool but occasionally drops 15-minute slots in certain bidding zones. The library falls back gracefully, but you should treat missing points as a warning.

License

MIT