Question

Data capture with multiple API-endpoints

  • 20 November 2023
  • 2 replies
  • 35 views

Hi,

Has anyone worked with API from Energinet?

I need some help extracing data from Energinet. 

Energinet delivers data with multiple endpoints. 

It starts with https://www.energinet.net/api/unit which gives me this 

[
{
"unit_id": "1234ABCDfolder",
"name": "My Company",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1234ABCDfolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1234ABCDfolder"
}
},
"datasources": []
}
]

Now, i have to drill down to get some info: https://www.energinet.net/api/unit/1234ACDfolder

[
{
"unit_id": 1Afolder",
"name": "Company1",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1Afolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1Afolder"
}
},
"datasources": []
},
{
"unit_id": "1Bfolder",
"name": "Company2",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1Bfolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1Bfolder"
}
},
"datasources": []
},
{
"unit_id": "1Cfolder",
"name": "Company3",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1Cfolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1Cfolder"
}
},
"datasources": []
},
"datasources": []
}
]

Now, i have to drill down individual Comapnies to get more data: https://www.energinet.net/api/unit/1Afolder

[
{
"unit_id": "1AAfolder",
"name": "West Side",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1Awestfolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1Awestfolder"
}
},
"datasources": []
},
{
"unit_id": "1ABfolder",
"name": "North Side",
"links": {
"info": {
"verb": "GET",
"href": "/api/unitinfo/1Anothfolder"
},
"drilldown": {
"verb": "GET",
"href": "/api/unit/1Anorthfolder"
}
},
"datasources": []
}
]

and so on and so on, until i have run through all the endpoints. There are 10 more levels.

Is there a way to create a datasource from such kind of API an easy way?

 


2 replies

Userlevel 5
Badge +5

Hi @aftabp 

Yes you can use nested calls.

So you start by generating an RSD file on each level you want to connect to.

So if you want to iterate over https://www.energinet.net/api/unit/1Afolder  you will need to pull a list of folders in a call and then use it as explained in the guide.

You can get many levels in one file, so you can have unit folder and unitfolder info in the same rsd file.

Userlevel 5
Badge +5

Hi @aftabp 

Were you able to resolve the issue using the guide Thomas mentions above?

Reply