https://github.com/savjee/energy-prices-api
https://github.com/savjee/energy-prices-api
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/savjee/energy-prices-api
- Owner: Savjee
- Created: 2022-09-03T11:13:52.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-05T09:58:16.000Z (over 1 year ago)
- Last Synced: 2025-01-17T06:46:33.410Z (over 1 year ago)
- Language: TypeScript
- Size: 45.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Energy Price API
Simple API that returns the price for gas and electricity.
Currently only supports Belgium 🇧🇪 but I'm open to pull requests!.
## Usage
Get gas prices:
```
GET https://energy-prices.savjee.workers.dev/be/gas
```
Response:
```json
{
"price":2.3989239371241693,
"unit":"m3"
}
```
Get electricity price:
```
GET https://energy-prices.savjee.workers.dev/be/electricity
```
Response:
```json
{
"avg":0.3301816666666666,
"median":0.30147
}
```
The API is a Cloudflare Worker that makes requests to the datasources (PowerNext and Elia) and caches the results for 1 hour.
## Integration with Home Assistant
Want to use this API in your Home Assistant instance? Simply include these RESTful sensors:
```yaml
- platform: rest
resource: https://energy-prices.savjee.workers.dev/be/gas
method: GET
name: Gas wholesale price
value_template: {{ value_json.price | round(2) }}
device_class: monetary
state_class: measurement
unit_of_measurement: "€/m³"
scan_interval: 3600 # 1 hour
- platform: rest
resource: https://energy-prices.savjee.workers.dev/be/electricity
method: GET
name: Electricity wholesale price
value_template: {{ value_json.avg | round(2) }}
device_class: monetary
state_class: measurement
unit_of_measurement: "€/kWh"
scan_interval: 3600 # 1 hour
```
## Wishlist
- [ ] Support more countries
- [ ] Version the API to prevent breaking changes in the future
- [ ] Have a uniform response format and document the units we're using