Skip to main content
Deno 2 is finally here πŸŽ‰οΈ
Learn more

spotprice

Get spot prices from Nordpool. Works in Node, Deno and Bun.

NOTE: THIS IS WORK IN PROGRESS.

NOTE: This works, but it is not allowed by Nordpool terms of usage to fetch data using this method. This as a proof of concept.

Node.js CI Deno CI Bun CI npm version NPM Downloads jsdelivr MIT License

  • Works in Node.js >=18.0 (both require and import)
  • Works in Deno >=1.16
  • Works in Bun >=0.2.2
  • Supports both CommonJS, UMD and ESM
  • Includes TypeScript typings

Installation

Node.js

npm install spotprice --save

JavaScript

// ESM Import ...
import spotprice from "spotprice";

// ... or CommonJS Require
const spotprice = require("spotprice");

TypeScript

Note that only default export is available in Node.js TypeScript, as the commonjs module is used internally.

import spotprice from "spotprice";

// ...

Bun

bun add spotprice

Note If you experience problems during install, try using bun add spotprice --backend=copyfile.

import spotprice from "spotprice";

// ...

Deno

JavaScript

import spotprice from "https://deno.land/x/spotprice@0.0.1/src/spotprice.js";

// ...

TypeScript

import { spotprice } from "https://deno.land/x/spotprice@0.0.1/src/spotprice.js";

// ...

Browser

Manual

  • Download latest zipball
  • Unpack
  • Grab spotprice.min.js (UMD and standalone) or spotprice.min.mjs (ES-module) from the dist/ folder

CDN

To use as a UMD-module (stand alone, RequireJS etc.)

<script src="https://cdn.jsdelivr.net/npm/spotprice@0.0.1/dist/spotprice.min.js"></script>

To use as an ES-module

<script type="module">
    import spotprice from "https://cdn.jsdelivr.net/npm/spotprice@0.0.1/dist/spotprice.min.mjs";

    // ... see usage section ...
</script>

Documentation

Full documentation available at hexagon.github.io/spotprice.

Examples

Assuming you have imported spotprice as described under β€˜Installation’.

// Import using the right method for your runtime
// according to the 'Installation'-section of the README
// This example is for Node/Bun using EMS import
import { spotprice } from "spotprice";

// Will throw on error
const result = await spotprice("hourly", "SE2", "SEK", "17-11-2022");

console.table(result);

/* 

Output:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (index) β”‚       startTime       β”‚ areaCode β”‚ spotPrice β”‚   unit    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    0    β”‚ '2020-01-17T00:00:00' β”‚  'SE2'   β”‚ '395,26'  β”‚ 'SEK/MWh' β”‚
β”‚    1    β”‚ '2020-01-17T01:00:00' β”‚  'SE2'   β”‚ '259,96'  β”‚ 'SEK/MWh' β”‚
β”‚    2    β”‚ '2020-01-17T02:00:00' β”‚  'SE2'   β”‚ '184,42'  β”‚ 'SEK/MWh' β”‚
β”‚    3    β”‚ '2020-01-17T03:00:00' β”‚  'SE2'   β”‚ '159,32'  β”‚ 'SEK/MWh' β”‚
β”‚    4    β”‚ '2020-01-17T04:00:00' β”‚  'SE2'   β”‚ '159,97'  β”‚ 'SEK/MWh' β”‚

[...]

Full API

Todo …

Contributing

See Contribution Guide

License

MIT