Connecting to Trading212 on Power BI

Hi guys, does anyone know how I can connect my T212 to Power BI so that I can create a dashboard with it?

I have done some research to see that T212 has an API but Iā€™m not too familiar how to use this and Python in Power BI.

Any help would be appreciated :grinning:

Hi jjs234,

For my dashboard I used Google Apps Script, querying with the API provided by T212 and importing the data into a Google Sheets. Then I used Looker Studio. Once you have the data in a spreadsheet, you can use any BI, including Power BI.

The most critical part is to get right the API call, Here is a fairly simple function you can use:

function T212APICall(url) {
  const params = {
    "method":"GET",
    "headers":{
      "Authorization":T212_API_KEY
    },
    "muteHttpExceptions":false
  };

  let response;
  let respCode;
  try {
    response = UrlFetchApp.fetch(url, params);
    respCode = response.getResponseCode();
  } catch (e) {
    Logger.log("Error: "+e);
  }
  
  return {'error': respCode, 'response': response};
}


The function requires the complete URL and returns an object that contains the error code (error) that in case of success has to return 200 and the response that should contain a JSON with the requested data.

T212_API_KEY is the key that you can get reading these instructions.

For the different queries follow the Trading212 Public API manual.

Hope this helps.

4 Likes