We just announced the availability of the Windows Store analytics API. With these APIs you can get many useful information directly from the Windows Store, without the need to pick up a browser and login in the Dev Center. More important, you can now programmatically access to these information!
Let’s see, for example, how to write a simple method that downloads all the reviews for a specific app.
The API to use is the following:
The only required parameter is the applicationID, but it supports many optional parameters to narrow down the results and to filter based on the reviewer properties or the app marketplace. Interesting, this API does support also a basic query language.
The API is part of the new Azure Resource Manager namespace, so as every other Azure REST API in this namespace is secured with Azure AD. This means it can be consumed only by authorized users, hence for each call you must provide a JWT token to prove your identity. As per documentation, this token must be set as http header:
Authorization: Bearer XXXXXXXXXYYYYZZZZZZ…==
So the first step is to retrieve the token from Azure AD but in order to be able to get the JWT there are some preliminary steps you need to complete. Basically you have to link your Dev Center account with your Azure AD tenant and create an application that will act as “bridge” to the Windows Store APIs. This application will be used to create the Azure access tokens you need.
Once you have completed the preliminary steps, you can use the following code to get the token:
The code uses the latest pre-release version of Microsoft.IdentityModel.Clients.ActiveDirectory to trigger the OAuth2 flow and retrieve a JWT token (returned as Base64 string).
Once you have the token you can attach it as HTTP header and call the API, it is really straightforward:
The API returns a JSON document with all the reviews that match the input filter, a total count and an optional link to the next page (if any). In this example I’m just returning the result to the caller, but you can easily write a method to parse the JSON and build an array of objects that represent your reviews.