> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Ren Data Hub

> Client-mode REST API connectors for Portuguese grid open data with no API key: E-REDES distribution datasets (15-minute national consumption and production, consumption forecast, consumption by municipality) and REN DataHub electricity and gas balances, production by source and market prices

Technical Preview

## Overview

Client-mode REST API connectors for Portuguese grid open data with no API key: E-REDES distribution datasets (15-minute national consumption and production, consumption forecast, consumption by municipality) and REN DataHub electricity and gas balances, production by source and market prices.

This is one of the templates in the E-REDES and REN open data (Portugal) REST API app (`e-redes-and-ren-open-data`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

## Auth

* **schemes**: \["none"]
* **secrets**: \[]
* **note**: Both keyless. E-REDES optional portal API key (Authorization: Apikey ...) for higher quota; not wired by default.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Ren Data Hub connector | no |
| `BaseUrl` | string | Ren Data Hub base URL without trailing slash (e.g. [https://servicebus.ren.pt](https://servicebus.ren.pt)) | yes |

`BASE_ADDRESS` default: `https://servicebus.ren.pt`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `RenElectricityBalanceDaily` | GET | `/datahubapi/electricity/ElectricityConsumptionSupplyDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/electricity/balance-daily/get` | `energy/pt/ren/electricity/balance-daily/get/response` | `culture`, `date` |
| `RenElectricityProductionDaily` | GET | `/datahubapi/electricity/ElectricityProductionBreakdownDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/electricity/production-daily/get` | `energy/pt/ren/electricity/production-daily/get/response` | `culture`, `date` |
| `RenElectricityBalanceMonthly` | GET | `/datahubapi/electricity/ElectricityConsumptionSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/electricity/balance-monthly/get` | `energy/pt/ren/electricity/balance-monthly/get/response` | `culture`, `month`, `year` |
| `RenElectricityInstalledPowerMonthly` | GET | `/datahubapi/electricity/ElectricityInstalledPowerMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/electricity/installed-power-monthly/get` | `energy/pt/ren/electricity/installed-power-monthly/get/response` | `culture`, `month`, `year` |
| `RenElectricityConsumptionYearly` | GET | `/datahubapi/electricity/ElectricityConsumptionVariationYearly?culture={value.json.culture}&year={value.json.year}` | `energy/pt/ren/electricity/consumption-yearly/get` | `energy/pt/ren/electricity/consumption-yearly/get/response` | `culture`, `year` |
| `RenElectricityPricesDaily` | GET | `/datahubapi/electricity/ElectricityMarketPricesDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/electricity/prices-daily/get` | `energy/pt/ren/electricity/prices-daily/get/response` | `culture`, `date` |
| `RenElectricityPricesMonthly` | GET | `/datahubapi/electricity/ElectricityMarketPricesMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/electricity/prices-monthly/get` | `energy/pt/ren/electricity/prices-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasBalanceDaily` | GET | `/datahubapi/gas/GasConsumptionSupplyDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/gas/balance-daily/get` | `energy/pt/ren/gas/balance-daily/get/response` | `culture`, `date` |
| `RenGasConsumptionBreakdownDaily` | GET | `/datahubapi/gas/GasConsumptionBreakdownDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/gas/consumption-breakdown-daily/get` | `energy/pt/ren/gas/consumption-breakdown-daily/get/response` | `culture`, `date` |
| `RenGasRntgBalanceDaily` | GET | `/datahubapi/gas/GasRNTGBalanceDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/gas/rntg-balance-daily/get` | `energy/pt/ren/gas/rntg-balance-daily/get/response` | `culture`, `date` |
| `RenGasLngTerminalDaily` | GET | `/datahubapi/gas/GasLNGTerminalBalanceDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/gas/lng-terminal-daily/get` | `energy/pt/ren/gas/lng-terminal-daily/get/response` | `culture`, `date` |
| `RenGasStorageDaily` | GET | `/datahubapi/gas/GasUndergroundStorageBalanceDaily?culture={value.json.culture}&date={value.json.date}` | `energy/pt/ren/gas/storage-daily/get` | `energy/pt/ren/gas/storage-daily/get/response` | `culture`, `date` |
| `RenGasBalanceMonthly` | GET | `/datahubapi/gas/GasConsumptionSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/balance-monthly/get` | `energy/pt/ren/gas/balance-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasRntgBalanceMonthly` | GET | `/datahubapi/gas/GasRNTGBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/rntg-balance-monthly/get` | `energy/pt/ren/gas/rntg-balance-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasLngTerminalMonthly` | GET | `/datahubapi/gas/GasLNGTerminalBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/lng-terminal-monthly/get` | `energy/pt/ren/gas/lng-terminal-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasStorageMonthly` | GET | `/datahubapi/gas/GasUndergroundStorageBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/storage-monthly/get` | `energy/pt/ren/gas/storage-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasSupplyBreakdownMonthly` | GET | `/datahubapi/gas/GasBreakdownOfSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/supply-breakdown-monthly/get` | `energy/pt/ren/gas/supply-breakdown-monthly/get/response` | `culture`, `month`, `year` |
| `RenGasConsumptionYearly` | GET | `/datahubapi/gas/GasConsumptionVariationYearly?culture={value.json.culture}&year={value.json.year}` | `energy/pt/ren/gas/consumption-yearly/get` | `energy/pt/ren/gas/consumption-yearly/get/response` | `culture`, `year` |
| `RenGasPricesDaily` | GET | `/datahubapi/gas/GasMarketPricesDaily?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/prices-daily/get` | `energy/pt/ren/gas/prices-daily/get/response` | `culture`, `month`, `year` |
| `RenGasPricesMonthly` | GET | `/datahubapi/gas/GasMarketPricesMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}` | `energy/pt/ren/gas/prices-monthly/get` | `energy/pt/ren/gas/prices-monthly/get/response` | `culture`, `month`, `year` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode REN_DATA_HUB"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE RenDataHub WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://servicebus.ren.pt"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT RenElectricityBalanceDaily
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/balance-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/balance-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityConsumptionSupplyDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityProductionDaily
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/production-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/production-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityProductionBreakdownDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityBalanceMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/balance-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/balance-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityConsumptionSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityInstalledPowerMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/installed-power-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/installed-power-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityInstalledPowerMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityConsumptionYearly
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/consumption-yearly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/consumption-yearly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityConsumptionVariationYearly?culture={value.json.culture}&year={value.json.year}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityPricesDaily
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/prices-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/prices-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityMarketPricesDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenElectricityPricesMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/electricity/prices-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/electricity/prices-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/electricity/ElectricityMarketPricesMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasBalanceDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/balance-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/balance-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasConsumptionSupplyDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasConsumptionBreakdownDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/consumption-breakdown-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/consumption-breakdown-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasConsumptionBreakdownDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasRntgBalanceDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/rntg-balance-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/rntg-balance-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasRNTGBalanceDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasLngTerminalDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/lng-terminal-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/lng-terminal-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasLNGTerminalBalanceDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasStorageDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/storage-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/storage-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasUndergroundStorageBalanceDaily?culture={value.json.culture}&date={value.json.date}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasBalanceMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/balance-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/balance-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasConsumptionSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasRntgBalanceMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/rntg-balance-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/rntg-balance-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasRNTGBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasLngTerminalMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/lng-terminal-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/lng-terminal-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasLNGTerminalBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasStorageMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/storage-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/storage-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasUndergroundStorageBalanceMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasSupplyBreakdownMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/supply-breakdown-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/supply-breakdown-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasBreakdownOfSupplyMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasConsumptionYearly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/consumption-yearly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/consumption-yearly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasConsumptionVariationYearly?culture={value.json.culture}&year={value.json.year}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasPricesDaily
        WITH SOURCE_TOPIC "energy/pt/ren/gas/prices-daily/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/prices-daily/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasMarketPricesDaily?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
    ADD EVENT RenGasPricesMonthly
        WITH SOURCE_TOPIC "energy/pt/ren/gas/prices-monthly/get"
        WITH DESTINATION_TOPIC "energy/pt/ren/gas/prices-monthly/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/datahubapi/gas/GasMarketPricesMonthly?culture={value.json.culture}&year={value.json.year}&month={value.json.month}"
        WITH HEADERS
            ADD "Accept" "*/*"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `RenElectricityBalanceDaily` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'energy/pt/ren/electricity/balance-daily/get/response' &
mosquitto_pub -t 'energy/pt/ren/electricity/balance-daily/get' -m '{"culture": "<culture>", "date": "<date>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.