Since the last API updates roundup, we've been busy adding new experiences and APIs for Power BI developers. We're ready to take the covers off of our latest additions that we hope help developers do more and faster with Power BI.  Two major things have been added: simplified application registration experience and APIs to allow you to integrate reports into your applications. Here's a quick video that shows how developers can use these new features to get started developing for Power BI in just 5 minutes.

 

Making it easy to register apps for Power BI 

The very first thing you need to do to use the Power BI REST APIs is register an application.  That process in the past has required you to login to the Azure portal and navigate a number of UI pages. We heard your feedback and now are happy to announce our new simplified application registration page. The page is available at https://dev.powerbi.com/apps. We've also updated the register an app links in our Developer Center to take you directly to the new application registration page. 

The application registration page helps you create a new application in AAD that has all the scopes required to connect to Power BI.  It includes all the core settings like whether you're using a native client application or a web application.  It provides you the client id and client secret you need to use any of our samples or for your own custom built applications. After you create the application, you still need to head over to Azure's portal to manage or change the settings of an application you created through the application registration page.

Power BI Application Registration Page

 

Reports API

As we build out the set of APIs incrementally, we've now added the API to list all the reports in a work space.  You'll get the properties of the report such as the embedUrl and the webUrl that help you build integrated experiences within your applications.  More on how to Integrate a Report into your application below. I should mention that you can use this API with the Groups API to list the reports in a group work space. 

GET https://api.powerbi.com/beta/myorg/reports

 

Integrating reports into applications

Building on the strong momentum of our API to integrate tiles into applications, we're following it up with the ability to integrate reports into your applications.  This feature lets you integrate reports from a user's Power BI account into your own application UI. You can leverage this to add personalized data experiences into your applications.  The user can see the reports they have access to and if those reports are shared with others through the Power BI service, they could even add shared reports so their colleagues can see them within your application.

 

To use the report integration APIs, as a developer you would do the following:

1) In your application, login the user using Active Directory.  The AAD team has a great post with quick starts for virtually any platform.

2) Let the user pick a report to show in your application. The reports API returns an 'embedUrl' property you can use to embed the report  Here's an example embed URL:

https://app.powerbi.com/reportEmbed?reportId=d2a0ea38-0694-4c70-9673-ee9655d54a4a

 3) Add an iFrame in your application that points to the embed URL for the tile

iframe = document.getElementById('iFrameEmbedReport');iframe.src = embedUrl;iframe.onload = postActionLoadReport;

4) When the iFrame loads, send the access token to the iFrame to load the report. Note that if you miss this step, the report will not load.

iframe = document.getElementById('iFrameEmbedReport'); var m = { action: "loadReport", accessToken: accessToken}; message = JSON.stringify(m); iframe.contentWindow.postMessage(message, "*");;

 

Filtering reports embedded in your application

Similarly to how you can filter a tile using a URL syntax, you can do the same for reports embedded within your report.  To do this, you'd add a query string parameter to your iFrame src url with the filter specified. 

https://app.powerbi.com/reportEmbed?reportId=d2a0ea38-0694-4c70-9673-ee9655d54a4a&$filter={tableName/fieldName} eq '{fieldValue}'

{tableName/fieldName} cannot include spaces or special characters. The {fieldValue} accepts a single categorical value.  

 

We're exited to see how developers will use these new APIs and hope you'll send us links in the comments to solutions you build using these APIs.  

 

Resources

Register an app for Power BI

Integrate a report into your app sample

Integrate a report into your app documentation

 

Login a user with AAD Quick Starts