After you've set everything up, you can send requests to the Google Play Developer Reporting API to retrieve metadata about metric sets and query their metrics.
The following code samples demonstrate how to send a few simple requests. For example, the methods below show you how to retrieve various metrics for your app. There are a few different query parameters that can be used to narrow your query.
Retrieving metric set metadata
The following example retrieves the metadata for the crash rate metric set for a fictional
application, com.example.app
.
Simple request:
This HTTP GET
request specifies the application name parameter and returns the
full metric resource associated with your application.
GET https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet
Metric info response:
The response includes the following fields related to the metric set:
{ "freshness_info": { "freshness": [ "aggregation_period": "DAILY" "latest_end_time": { year: "2021" month: "7" day: "22" time_zone: "America/Los_Angeles" } ] } }
Using the query feature
The following HTTP POST
request for this same resource uses the query
endpoint to retrieve specific data from within the metric set.
POST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query
In the request body, pass query options to retrieve metrics based on specific criteria.
{ "timeline_spec": { "aggregation_period": "DAILY" "start_time": { year: "2021" month: "7" day: "1" time_zone: "America/Los_Angeles" } "end_time": { year: "2021" month: "7" day: "3" time_zone: "America/Los_Angeles" } } "dimensions": ["apiLevel"] "metrics": ["errorReportCount", "distinctUsers"] "page_size": "10" }
Here are some collection-level examples:
Fields | |
---|---|
timelineSpec |
Specification of the timeline aggregation parameters. Please check the documentation of each metric set for a list of what aggregation periods are supported. |
dimensions[] |
Dimensions to slice the metrics by. Please check the documentation of each metric set for a list of what dimensions are supported. |
metrics[] |
Metrics to aggregate. |
pageSize |
Maximum size of the returned data. If unspecified, at most 1000 rows will be returned. The maximum value is 100,000; values above 100,000 will be coerced to 100,000. |
Handling responses
After a server processes a valid request that includes valid fields, it sends back an HTTP
200 OK
status code, along with the requested data. If the fields
query parameter has an error or is otherwise invalid, the server returns an HTTP
400 Bad Request
status code, along with an error message telling the user what
was wrong with their fields selection (for example, "Invalid field timeline_spec"
).
Here is the response example shown in the introductory section above.
POST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query
The response looks like this:
200 OK
{ rows: [ { aggregation_period: "DAILY" start_time: { year: "2021" month: "7" day: "1" time_zone: "America/Los_Angeles" } dimensions: [{dimension: "apiLevel" int64_value: "20"}] metrics: [ {metric: "errorReportCount" decimal_value: "100"}, {metric: "distinctUsers" decimal_value: "57"}, ] }, { aggregation_period: "DAILY" start_time: { year: "2021" month: "7" day: "1" time_zone: "America/Los_Angeles" } dimensions: [{dimension: "apiLevel" int64_value: "21"}] metrics: [ {metric: "errorReportCount" decimal_value: "123"}, {metric: "distinctUsers" decimal_value: "65"}, ] }, ... ] next_page_token: "eW91IGhhdmUgdG9vIG11Y2ggZnJlZSB0aW1l" }
Note: For APIs that support query parameters for data pagination (maxResults
and nextPageToken
, for example), use those parameters to reduce the results of each
query to a manageable size.