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 ERedes Open Data connector | no |
BaseUrl | string | ERedes Open Data base URL without trailing slash (e.g. https://e-redes.opendatasoft.com) | yes |
BASE_ADDRESS default: https://e-redes.opendatasoft.com.
Events
| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
|---|---|---|---|---|---|
ERedesCatalogDatasets | GET | /api/explore/v2.1/catalog/datasets?limit={value.json.limit}{value.json.params} | energy/pt/eredes/catalog/datasets/get | energy/pt/eredes/catalog/datasets/get/response | limit, params |
ERedesDataset | GET | /api/explore/v2.1/catalog/datasets/{value.json.dataset_id} | energy/pt/eredes/dataset/get | energy/pt/eredes/dataset/get/response | dataset_id |
ERedesRecords | GET | /api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/records?limit={value.json.limit}{value.json.params} | energy/pt/eredes/records/get | energy/pt/eredes/records/get/response | dataset_id, limit, params |
ERedesRecord | GET | /api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/records/{value.json.record_id} | energy/pt/eredes/record/get | energy/pt/eredes/record/get/response | dataset_id, record_id |
ERedesFacets | GET | /api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/facets?facet={value.json.facet}{value.json.params} | energy/pt/eredes/facets/get | energy/pt/eredes/facets/get/response | dataset_id, facet, params |
ERedesExportJson | GET | /api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/exports/json?limit={value.json.limit}{value.json.params} | energy/pt/eredes/export/get | energy/pt/eredes/export/get/response | dataset_id, limit, params |
ERedesMunicipalityConsumption | GET | /api/explore/v2.1/catalog/datasets/3-consumos-faturados-por-municipio-ultimos-10-anos/records?refine=concelho:{value.json.municipality}&order_by=-data&limit={value.json.limit}{value.json.params} | energy/pt/eredes/municipality-consumption/get | energy/pt/eredes/municipality-consumption/get/response | limit, municipality, params |
ERedesNationalConsumption | GET | /api/explore/v2.1/catalog/datasets/consumo-total-nacional/records?order_by=-datahora&limit={value.json.limit}{value.json.params} | energy/pt/eredes/national-consumption/get | energy/pt/eredes/national-consumption/get/response | limit, params |
ERedesNationalProduction | GET | /api/explore/v2.1/catalog/datasets/energia-produzida-total-nacional/records?order_by=-datahora&limit={value.json.limit}{value.json.params} | energy/pt/eredes/national-production/get | energy/pt/eredes/national-production/get/response | limit, params |
ERedesConsumptionForecast | GET | /api/explore/v2.1/catalog/datasets/previsao-de-consumo/records?refine=data:{value.json.date}&order_by=datahora&limit={value.json.limit}{value.json.params} | energy/pt/eredes/consumption-forecast/get | energy/pt/eredes/consumption-forecast/get/response | date, limit, params |
Deploy
Get the template card (JSON withtemplate and metadata) from the broker, then deploy the connector:
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode EREDES_OPEN_DATA"
BASE_ADDRESS already filled in:
DEFINE ROUTE ERedesOpenData WITH TYPE REST_API
ADD REST_API_CONFIG
WITH BASE_ADDRESS "https://e-redes.opendatasoft.com"
WITH ENABLE_CLIENT "true"
WITH USE_SSL "true"
WITH REQUEST_TIMEOUT '30'
WITH DEFAULT_CONTENT_TYPE "application/json"
ADD EVENT ERedesCatalogDatasets
WITH SOURCE_TOPIC "energy/pt/eredes/catalog/datasets/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/catalog/datasets/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets?limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesDataset
WITH SOURCE_TOPIC "energy/pt/eredes/dataset/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/dataset/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/{value.json.dataset_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesRecords
WITH SOURCE_TOPIC "energy/pt/eredes/records/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/records/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/records?limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesRecord
WITH SOURCE_TOPIC "energy/pt/eredes/record/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/record/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/records/{value.json.record_id}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesFacets
WITH SOURCE_TOPIC "energy/pt/eredes/facets/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/facets/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/facets?facet={value.json.facet}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesExportJson
WITH SOURCE_TOPIC "energy/pt/eredes/export/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/export/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/{value.json.dataset_id}/exports/json?limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesMunicipalityConsumption
WITH SOURCE_TOPIC "energy/pt/eredes/municipality-consumption/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/municipality-consumption/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/3-consumos-faturados-por-municipio-ultimos-10-anos/records?refine=concelho:{value.json.municipality}&order_by=-data&limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesNationalConsumption
WITH SOURCE_TOPIC "energy/pt/eredes/national-consumption/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/national-consumption/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/consumo-total-nacional/records?order_by=-datahora&limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesNationalProduction
WITH SOURCE_TOPIC "energy/pt/eredes/national-production/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/national-production/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/energia-produzida-total-nacional/records?order_by=-datahora&limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
ADD EVENT ERedesConsumptionForecast
WITH SOURCE_TOPIC "energy/pt/eredes/consumption-forecast/get"
WITH DESTINATION_TOPIC "energy/pt/eredes/consumption-forecast/get/response"
WITH METHOD "GET"
WITH ENDPOINT "/api/explore/v2.1/catalog/datasets/previsao-de-consumo/records?refine=data:{value.json.date}&order_by=datahora&limit={value.json.limit}{value.json.params}"
WITH HEADERS
ADD "Accept" "application/json"
ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
-addRoute (do not include ADD METADATA).
Usage example
CallERedesCatalogDatasets by publishing a JSON payload to its request topic, and read the reply on the response topic:
mosquitto_sub -t 'energy/pt/eredes/catalog/datasets/get/response' &
mosquitto_pub -t 'energy/pt/eredes/catalog/datasets/get' -m '{"limit": "<limit>", "params": "<params>"}'

