elpris

package module
v0.0.0-...-31b7081 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

elprisetjustnu-client-go

Go client for the public Elprisetjustnu day-ahead price API. It fetches 15-minute spot prices for Swedish bidding zones SE1–SE4. No authentication.

Dates in the URL are civil dates in Europe/Stockholm, not UTC. Tomorrow’s file is often missing until about 13:00; the client returns ErrNotYetPublished on HTTP 404.

Install

go get github.com/ohlen1/elprisetjustnu-client-go

Usage

client, err := elpris.New(elpris.SE3)
if err != nil {
    log.Fatal(err)
}
today, err := client.Today()
tomorrow, err := client.Tomorrow()

ForDate(t) converts t to Europe/Stockholm (since this API only deals with Swedish spot prices) and fetches that local date's prices. A UTC instant of 2026-08-19T22:30:00Z is 00:30 on 20 August in Stockholm, so it loads 2026/08-20_….json, not the 19th.

Override the default 10s timeout HTTP client with WithHTTPClient:

client, err := elpris.New(elpris.SE3, elpris.WithHTTPClient(&http.Client{
    Timeout: 30 * time.Second,
}))

API URL

GET https://www.elprisetjustnu.se/api/v1/prices/{YYYY}/{MM-DD}_{SE1|SE2|SE3|SE4}.json
curl -s 'https://www.elprisetjustnu.se/api/v1/prices/2026/08-20_SE3.json'
[
  {
    "SEK_per_kWh": 1.50616,
    "EUR_per_kWh": 0.13823,
    "EXR": 10.896049,
    "time_start": "2026-08-20T00:00:00+02:00",
    "time_end": "2026-08-20T00:15:00+02:00"
  }
]

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotYetPublished = errors.New("tomorrow's prices are not yet published")

ErrNotYetPublished is returned when the API responds 404, which is normal for tomorrow's prices until they are released (~13:00 Europe/Stockholm).

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(region Region, opts ...Option) (*Client, error)

func (*Client) ForDate

func (c *Client) ForDate(t time.Time) ([]Price, error)

ForDate converts t to Europe/Stockholm and fetches that local date's prices.

func (*Client) LocalNow

func (c *Client) LocalNow() time.Time

func (*Client) Location

func (c *Client) Location() *time.Location

func (*Client) Region

func (c *Client) Region() Region

func (*Client) Today

func (c *Client) Today() ([]Price, error)

func (*Client) Tomorrow

func (c *Client) Tomorrow() ([]Price, error)

type Option

type Option func(*Client)

func WithBaseURL

func WithBaseURL(u string) Option

func WithHTTPClient

func WithHTTPClient(h *http.Client) Option

func WithNow

func WithNow(now func() time.Time) Option

type Price

type Price struct {
	SEKPerKWh float64   `json:"SEK_per_kWh"`
	EURPerKWh float64   `json:"EUR_per_kWh"`
	EXR       float64   `json:"EXR"`
	TimeStart time.Time `json:"time_start"`
	TimeEnd   time.Time `json:"time_end"`
}

Price is one 15-minute slot from the Elprisetjustnu JSON API.

type Region

type Region string
const (
	SE1 Region = "SE1"
	SE2 Region = "SE2"
	SE3 Region = "SE3"
	SE4 Region = "SE4"
)

func ParseRegion

func ParseRegion(s string) (Region, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL