Top 5 Power BI APIs

Microsoft provides a plethora of APIs and excellent documentation for the Power BI service. In this article I’ve picked 5 of my favourites that could help you or your organization in a variety of situations!

January 27, 2022

1.       Scanner API (Admin REST APIs)

In my opinion this is probably one the most useful APIs currently available on the PBI platform, enabling users to quickly catalogue all the metadata from datasets on their Power BI tenant and is also great for documentation, which can quickly get outdated. By using this data, you can deliver a report to end users, allowing them to search for a measure/table on the entire tenant and not only see the description but also the DAX code of the measure to better understand the logic behind it.

Something to remember however, is in order to get this detailed information, the dataset has to have been published with a version of PBI Desktop that supports the enhanced metadata feature.

Full documentation here.

2.       Admin - Get Activity Events

There are already usage reports available in the PBI service, but if you you’d like to build a custom report to track usage of all reports in all workspaces, this is a great source of that information. The activity events don’t just track views but other events too, which could be useful for audit purposes. This data can then be combined with other metadata and the above API, to built the ultimate admin report.

Information on the usage can be found here.

 

3.       Asynchronous refresh with the Power BI REST API (Preview)

Typically, users or admins will publish datasets and configure their refresh policies directly in the service. This can be suboptimal on several levels and perhaps not necessarily best practices, especially for larger datasets. For example, perhaps you need your data to be refreshed based on an event rather than on a fixed schedule, such as completion of an Azure Data Factory pipeline. Or maybe you only want to process a single table instead of the entire dataset.

Additionally, this enables dataset-refresh operations to be carried out asynchronously, meaning long-running HTTP connections from client applications aren't necessary. Asynchronous refresh also includes additional reliability features such as auto retries and batched commits, along with greater control over parallelism.

More information can be found here

4.       Reports - Update Report Content In Group

Have you ever had issues where you cannot download your report from the Power BI service? Although this can be avoided by following a proper governance strategy and best practices. This can happen due to various scenarios, two that I have experienced is 1) When users save reports in the service to another workspace and 2) a user has created a report based on an existing dataset, directly in the Power BI service.

As you can imagine, even if you do have the original PBIX file, there may have been changes applied to the report that can no longer be version controlled.

A method of getting around this and to enable you to download the report is to leverage the Update Report Content API, to copy the contents of the report to a new blank report based on the same dataset.

Full details on how to do this can be found here.

5.       Export Power BI report to file (preview)

Following up on the Update Report in Group API, this API is useful in a scenario where you need to either export your report for sending out via email as a PDF or PPT, or if you haven’t already got a system in place for version control and you need to take a backup your reports by downloading all to PBIX files.

Documentation here

You should also be aware of the limitations currently in place for this, which can be found here.

Honorary mention:

I had to sneak just one more into my top favourites!

Push Datasets - Datasets PostRowsInGroup

Although this involves much more technical skills to use, this is an extremely useful API which enabled you to push data into a dataset from an application, opening up the possibility of near real time updates of your data, as opposed to using a scheduled refresh.

Power BI legends Marco Russo & Alberto Ferrari have an excellent and extremely detailed blog on this subject here.

Final thoughts

Due to the number of APIs available, the immense number of tasks that can be automated or made simpler by using them, it’s tough to pick just a few. So, I selected only five (plus an honorary) mention that I have found particularly useful.

In addition, REST APIs give you the flexibility to use your tool of choice. Some of the options just within the Microsoft ecosystem include .Net Console Apps, Azure Functions, Azure Logic Apps, Azure Data Factory, PowerShell or even Databricks!

At BizOne we’ve had lots of experience leveraging these APIs to help our customers in various ways. If you need help in this area, reach out to us today!