PHPackages                             baspa/energyzero-php-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. baspa/energyzero-php-api

ActiveLibrary[API Development](/categories/api)

baspa/energyzero-php-api
========================

PHP client for the dynamic prices from EnergyZero

v2.0.0(2mo ago)16MITPHPPHP ^8.2CI passing

Since Aug 26Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Baspa/energyzero-php-api)[ Packagist](https://packagist.org/packages/baspa/energyzero-php-api)[ Docs](https://github.com/baspa/energyzero-php-api)[ GitHub Sponsors](https://github.com/Baspa)[ RSS](/packages/baspa-energyzero-php-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (10)Used By (0)

PHP client for the dynamic prices from EnergyZero
=================================================

[](#php-client-for-the-dynamic-prices-from-energyzero)

[![Latest Version on Packagist](https://camo.githubusercontent.com/88a62124c87850b01573dde0ee33538687cbecb98ed90c3031b52b57e4da1e91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f62617370612f656e657267797a65726f2d7068702d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/baspa/energyzero-php-api)[![Tests](https://camo.githubusercontent.com/fc1fca6b98c6692eda61b7b7cb0dcf2c2e59df5f441c6492023ee7fe21508e16/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62617370612f656e657267797a65726f2d7068702d6170692f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/baspa/energyzero-php-api/actions/workflows/run-tests.yml)[![PHPStan](https://camo.githubusercontent.com/7c9993a4eef7e42e1b745cccc9105307bfc10b039fff0071851e04e128dead72/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f62617370612f656e657267797a65726f2d7068702d6170692f7068707374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/baspa/energyzero-php-api/actions/workflows/phpstan.yml)[![Total Downloads](https://camo.githubusercontent.com/45f497e55a0faf4d7695610f47892872f18b1e51c132ac4a2518671982c39793/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f62617370612f656e657267797a65726f2d7068702d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/baspa/energyzero-php-api)

This PHP package provides a client for fetching dynamic energy prices from the [EnergyZero](https://www.energyzero.nl/) API. It allows you to retrieve energy prices for a specified date range with customizable intervals and VAT options.

> **Building your own client?** See [API.md](API.md) for detailed API documentation with examples in multiple languages.

Price Availability
------------------

[](#price-availability)

Energy TypeToday's PricesTomorrow's PricesElectricityAvailable from 00:00Published around **14:00 UTC** (15:00 CET / 16:00 CEST)GasAvailable from 06:00 CETPublished around **05:00 UTC** (06:00 CET / 07:00 CEST)Installation
------------

[](#installation)

You can install the package via composer:

```
composer require baspa/energyzero-php-api
```

Usage
-----

[](#usage)

You can fetch the energy prices for a specific date range with a specific interval and VAT option. When the VAT option is not provided, it will default to `true`. Make sure you provide a date in the format `Y-m-d`.

```
use Baspa\EnergyZero\EnergyZero;
use Baspa\EnergyZero\Enums\Interval;

$prices = (new EnergyZero())->energyPrices(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    interval: Interval::HOUR,
    vat: true
);
```

The response will be an array of prices for the specified date range and also include the average price for the period.

### Interval options

[](#interval-options)

The following interval options are available:

IntervalEnumValueDescriptionQuarter`Interval::QUARTER`315-minute intervalsHour`Interval::HOUR`4Hourly intervals (default)Day`Interval::DAY`5Daily intervalsWeek`Interval::WEEK`6Weekly intervalsMonth`Interval::MONTH`7Monthly intervalsYear`Interval::YEAR`8Yearly intervalsYou can also use integer values directly for backward compatibility:

```
$prices = (new EnergyZero())->energyPrices('2024-01-01', '2024-01-02', 4);
```

### Set default interval

[](#set-default-interval)

You can set a default interval that will be used for all requests:

```
use Baspa\EnergyZero\EnergyZero;
use Baspa\EnergyZero\Enums\Interval;

$energyZero = (new EnergyZero())->setDefaultInterval(Interval::QUARTER);

// All subsequent calls will use 15-minute intervals by default
$prices = $energyZero->energyPrices('2024-01-01', '2024-01-02');
```

### Get quarter-hour prices

[](#get-quarter-hour-prices)

Fetch prices in 15-minute intervals for more granular data:

```
use Baspa\EnergyZero\EnergyZero;
use Baspa\EnergyZero\Enums\Interval;

$prices = (new EnergyZero())->energyPrices(
    startDate: '2024-01-01',
    endDate: '2024-01-01',
    interval: Interval::QUARTER
);
```

### Get gas prices

[](#get-gas-prices)

Fetch gas prices instead of electricity prices:

```
use Baspa\EnergyZero\EnergyZero;

$gasPrices = (new EnergyZero())->gasPrices(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    vat: true
);
```

Or set the default energy type:

```
use Baspa\EnergyZero\EnergyZero;
use Baspa\EnergyZero\Enums\EnergyType;

$energyZero = (new EnergyZero())->setDefaultEnergyType(EnergyType::GAS);

$prices = $energyZero->energyPrices('2024-01-01', '2024-01-02');
```

### Get the current price

[](#get-the-current-price)

Get the current electricity price for the current hour:

```
$currentPrice = (new EnergyZero())->getCurrentPrice();
// Returns: ['price' => 0.25, 'datetime' => '2024-01-01T14:00:00']
```

### Get prices for specific hours

[](#get-prices-for-specific-hours)

Get prices for specific hours of a day:

```
$prices = (new EnergyZero())->getPricesForHours(
    date: '2024-01-01',
    hours: [8, 12, 18, 22]
);
```

### Get the average price for a period

[](#get-the-average-price-for-a-period)

```
$averagePrice = (new EnergyZero())->getAveragePriceForPeriod(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    interval: Interval::HOUR,
    vat: true
);
```

### Get the lowest price for a period

[](#get-the-lowest-price-for-a-period)

```
$lowestPrice = (new EnergyZero())->getLowestPriceForPeriod(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    interval: Interval::HOUR,
    vat: true
);
```

### Get the highest price for a period

[](#get-the-highest-price-for-a-period)

```
$highestPrice = (new EnergyZero())->getHighestPriceForPeriod(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    interval: Interval::HOUR,
    vat: true
);
```

### Get the prices above a threshold

[](#get-the-prices-above-a-threshold)

```
$prices = (new EnergyZero())->getPricesAboveThreshold(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    threshold: 0.05,
    interval: Interval::HOUR,
    vat: true
);
```

### Get the prices below a threshold

[](#get-the-prices-below-a-threshold)

```
$prices = (new EnergyZero())->getPricesBelowThreshold(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    threshold: 0.05,
    interval: Interval::HOUR,
    vat: true
);
```

### Get the peak hours

[](#get-the-peak-hours)

Get the top N peak hours for a period.

```
$peakHours = (new EnergyZero())->getPeakHours(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    topN: 5,
    interval: Interval::HOUR,
    vat: true
);
```

### Get the valley hours

[](#get-the-valley-hours)

Get the top N valley hours for a period.

```
$valleyHours = (new EnergyZero())->getValleyHours(
    startDate: '2024-01-01',
    endDate: '2024-01-02',
    topN: 5,
    interval: Interval::HOUR,
    vat: true
);
```

Testing
-------

[](#testing)

```
composer test
```

API Documentation
-----------------

[](#api-documentation)

For developers who want to build their own client in another programming language, see [API.md](API.md) for:

- Complete API endpoint documentation
- Query parameters and response format
- Code examples in Python, JavaScript, and cURL
- Information about price availability times

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Baspa](https://github.com/Baspa)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance88

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~113 days

Recently: every ~142 days

Total

6

Last Release

62d ago

Major Versions

v1.0.4 → v2.0.02026-03-17

PHP version history (2 changes)v1.0.0PHP ^8.1

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b4c1c73be31056bf9c8f132938f77de518259ed02f5675e4339bc7dfab5b13c?d=identicon)[Baspa](/maintainers/Baspa)

---

Top Contributors

[![Baspa](https://avatars.githubusercontent.com/u/10845460?v=4)](https://github.com/Baspa "Baspa (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (16 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

energy-dataenergy-pricesphpphp-packagephp8Baspaenergyzero-php-api

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/baspa-energyzero-php-api/health.svg)

```
[![Health](https://phpackages.com/badges/baspa-energyzero-php-api/health.svg)](https://phpackages.com/packages/baspa-energyzero-php-api)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
