<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elprisdisplay</title>
    <description>The latest articles on DEV Community by Elprisdisplay (@elprisdisplay).</description>
    <link>https://dev.to/elprisdisplay</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4212927%2F957c45c4-6127-448a-a569-c3d73f1ab7b0.png</url>
      <title>DEV Community: Elprisdisplay</title>
      <link>https://dev.to/elprisdisplay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elprisdisplay"/>
    <language>en</language>
    <item>
      <title>How to fetch Danish hourly electricity spot prices from Energi Data Service</title>
      <dc:creator>Elprisdisplay</dc:creator>
      <pubDate>Wed, 28 Oct 2026 11:17:45 +0000</pubDate>
      <link>https://dev.to/elprisdisplay/how-to-fetch-danish-hourly-electricity-spot-prices-from-energi-data-service-11gd</link>
      <guid>https://dev.to/elprisdisplay/how-to-fetch-danish-hourly-electricity-spot-prices-from-energi-data-service-11gd</guid>
      <description>&lt;p&gt;Energinet, the Danish transmission system operator, publishes a lot of its data through &lt;strong&gt;Energi Data Service&lt;/strong&gt; (energidataservice.dk). Everything is available through a free, open REST API at &lt;code&gt;api.energidataservice.dk&lt;/code&gt; - no API key or sign-up needed. This post shows how to fetch Danish day-ahead electricity spot prices with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The dataset
&lt;/h2&gt;

&lt;p&gt;The current dataset for day-ahead (spot) prices is called &lt;strong&gt;DayAheadPrices&lt;/strong&gt;. It replaced the older &lt;strong&gt;Elspotprices&lt;/strong&gt; dataset, which I checked still responds but whose latest record is from 30 September 2025. If you find old tutorials using &lt;code&gt;Elspotprices&lt;/code&gt;, switch to &lt;code&gt;DayAheadPrices&lt;/code&gt; for current data.&lt;/p&gt;

&lt;p&gt;Each record in DayAheadPrices contains these fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;TimeUTC&lt;/code&gt; and &lt;code&gt;TimeDK&lt;/code&gt; - the start of the period in UTC and Danish local time&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;PriceArea&lt;/code&gt; - the bidding zone&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;DayAheadPriceEUR&lt;/code&gt; and &lt;code&gt;DayAheadPriceDKK&lt;/code&gt; - the price in EUR/MWh and DKK/MWh&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note that the dataset is now published in 15-minute resolution, so you get four records per hour instead of one. If you need an hourly price, average the four values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Price areas: DK1 and DK2
&lt;/h2&gt;

&lt;p&gt;Denmark is split into two price areas. &lt;strong&gt;DK1&lt;/strong&gt; is West Denmark (Jutland and Funen), &lt;strong&gt;DK2&lt;/strong&gt; is East Denmark (Zealand and the islands). The dataset also contains neighbouring areas such as DE, so always filter on &lt;code&gt;PriceArea&lt;/code&gt; unless you want them all. Which area you need depends on where the consumer lives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example request with curl
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-G&lt;/span&gt; &lt;span class="s2"&gt;"https://api.energidataservice.dk/dataset/DayAheadPrices"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s1"&gt;'start=2026-10-28T00:00'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s1"&gt;'end=2026-10-29T00:00'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s1"&gt;'filter={"PriceArea":["DK1"]}'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s1"&gt;'sort=TimeUTC asc'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--data-urlencode&lt;/span&gt; &lt;span class="s1"&gt;'limit=100'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response is JSON with a &lt;code&gt;records&lt;/code&gt; array, plus &lt;code&gt;total&lt;/code&gt;, &lt;code&gt;limit&lt;/code&gt; and &lt;code&gt;dataset&lt;/code&gt; fields. The &lt;code&gt;filter&lt;/code&gt; parameter takes a JSON object where each key is a column and each value is a list of accepted values. &lt;code&gt;sort&lt;/code&gt; accepts a column name followed by &lt;code&gt;asc&lt;/code&gt; or &lt;code&gt;desc&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same thing in JavaScript
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2026-10-28T00:00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2026-10-29T00:00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;PriceArea&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DK2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="na"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;TimeUTC asc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;100&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://api.energidataservice.dk/dataset/DayAheadPrices?&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;records&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;records&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;kronerPerKwh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DayAheadPriceDKK&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TimeDK&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;kronerPerKwh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;kr/kWh&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Things to watch out for
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Units.&lt;/strong&gt; Prices are given per &lt;strong&gt;MWh&lt;/strong&gt;, not per kWh. To get kr/kWh, divide the DKK price by 1000.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is not included.&lt;/strong&gt; The spot price excludes grid tariffs, the electricity tax (elafgift), your supplier's margin and VAT. What you actually pay per kWh is considerably higher in most hours, so do not present the raw spot price as the "price of electricity" without saying so. If you want a realistic number, you need to add the tariffs for your grid company, the tax and 25% VAT.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Publication time.&lt;/strong&gt; The prices for the next day are published around &lt;strong&gt;13:00 CET&lt;/strong&gt;. Before that, a request for tomorrow returns no records, so schedule your fetch for the afternoon and handle an empty result gracefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time zones.&lt;/strong&gt; Use &lt;code&gt;TimeUTC&lt;/code&gt; for sorting and joining data, and &lt;code&gt;TimeDK&lt;/code&gt; for showing it to people. This avoids headaches around the daylight saving changeover.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Be a good API citizen.&lt;/strong&gt; The API is free but not unlimited. Cache the result, since the data for a day does not change once published, and fetch once per day instead of on every page view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;With a single GET request you can get Danish day-ahead prices for either price area, sorted and filtered the way you want. From there it is a matter of dividing by 1000 and deciding which extras to add on top.&lt;/p&gt;

&lt;p&gt;We use this data in Elprisdisplay (&lt;a href="https://elprisdisplay.dk" rel="noopener noreferrer"&gt;https://elprisdisplay.dk&lt;/a&gt;), a small display that shows the current price at home.&lt;/p&gt;

</description>
      <category>api</category>
      <category>opendata</category>
      <category>energy</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
