查詢指標集
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
完成所有設定後,您就可以向 Google Play Developer Reporting API 傳送要求,擷取指標集的相關中繼資料,並查詢指標。
下列程式碼範例示範如何傳送幾項簡單要求。舉例來說,下列方法會說明如何擷取應用程式的各種指標。您可以使用幾種不同的查詢參數來縮小查詢範圍。
以下範例會擷取虛構應用程式 com.example.app
的當機率指標組合中繼資料。
簡單要求:
這個 HTTP GET
要求會指定應用程式名稱參數,並傳回與應用程式相關聯的完整指標資源。
GET https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet
指標資訊回應:
回應會包括下列與指標集相關的欄位:
{
"freshness_info": {
"freshness": [
"aggregation_period": "DAILY"
"latest_end_time": { year: "2021" month: "7" day: "22" time_zone: "America/Los_Angeles" }
]
}
}
使用查詢功能
以下是對相同資源發出的 HTTP POST
要求,其中使用了 query
端點,從指標集中擷取特定資料。
POST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query
在要求主體中傳遞查詢選項,根據特定條件擷取指標。
{
"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"
}
以下提供幾個集合層級的範例:
欄位 |
timelineSpec |
object (TimelineSpec )
時間軸匯總參數的規格。如要查看支援的匯總週期,請參閱各指標集的說明文件。
|
dimensions[] |
string
用來細分指標的維度。如要查看支援的維度清單,請參閱各指標集的說明文件。
|
metrics[] |
string
要匯總的指標。
|
pageSize |
integer
傳回資料的大小上限。 如未指定,最多將傳回 1000 列。許可的最大值為 100,000;超出的數值將一律指定為 100,000。
|
處理回應
伺服器處理包含有效欄位的有效要求後,會傳回一個 HTTP 200 OK
狀態碼,以及所要求的資料。如果 fields
查詢參數發生錯誤或無效,伺服器會傳回 HTTP
400 Bad Request
狀態碼和錯誤訊息,指出使用者選取欄位時發生的錯誤 (例如 "Invalid field timeline_spec"
)。
以下是前述簡介一節中顯示的回應範例。
POST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query
回應的形式如下所示:
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"
}
注意:如果 API 支援資料分頁的查詢參數 (例如 maxResults
和 nextPageToken
),請使用這些參數將各筆查詢的結果縮減至方便管理的大小。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eSend requests to the Google Play Developer Reporting API to retrieve app metric data after setup.\u003c/p\u003e\n"],["\u003cp\u003eUse the \u003ccode\u003equery\u003c/code\u003e endpoint with parameters like \u003ccode\u003etimeline_spec\u003c/code\u003e, \u003ccode\u003edimensions\u003c/code\u003e, and \u003ccode\u003emetrics\u003c/code\u003e to retrieve specific data within a metric set.\u003c/p\u003e\n"],["\u003cp\u003eResponses include metric data based on the query, or error messages for invalid requests.\u003c/p\u003e\n"],["\u003cp\u003eFor large datasets, utilize pagination parameters like \u003ccode\u003epageSize\u003c/code\u003e to handle responses efficiently.\u003c/p\u003e\n"]]],["After setup, you can interact with the Google Play Developer Reporting API. A `GET` request, like for `com.example.app`, can retrieve metric set metadata, including freshness information. To query specific data, use a `POST` request with parameters like `timeline_spec`, `dimensions`, `metrics`, and `page_size`. A successful request returns a `200 OK` status and the requested data, while a `400 Bad Request` signifies errors in the query parameters. Use pagination to manage large data sets.\n"],null,["# Querying Metric Sets\n\nAfter you've set everything up, you can send requests to the Google Play Developer Reporting API to retrieve\nmetadata about metric sets and query their metrics.\n\n\nThe following code samples demonstrate how to send a few simple requests. For example, the\nmethods below show you how to retrieve various metrics for your app. There are a few different\nquery parameters that can be used to narrow your query.\n\nRetrieving metric set metadata\n------------------------------\n\n\nThe following example retrieves the metadata for the crash rate metric set for a fictional\napplication, `com.example.app`.\n\n#### Simple request:\n\n\nThis HTTP `GET` request specifies the application name parameter and returns the\nfull metric resource associated with your application. \n\n```text\nGET https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet\n```\n\n#### Metric info response:\n\n\nThe response includes the following fields related to the metric set: \n\n```verilog\n{\n \"freshness_info\": {\n \"freshness\": [\n \"aggregation_period\": \"DAILY\"\n \"latest_end_time\": { year: \"2021\" month: \"7\" day: \"22\" time_zone: \"America/Los_Angeles\" }\n ]\n }\n}\n```\n\nUsing the query feature\n-----------------------\n\n\nThe following HTTP `POST`request for this same resource uses the `query`\nendpoint to retrieve specific data from within the metric set. \n\n```text\nPOST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query\n```\n\n\nIn the request body, pass query options to retrieve metrics based on specific criteria. \n\n```verilog\n{\n \"timeline_spec\": {\n \"aggregation_period\": \"DAILY\"\n \"start_time\": { year: \"2021\" month: \"7\" day: \"1\" time_zone: \"America/Los_Angeles\" }\n \"end_time\": { year: \"2021\" month: \"7\" day: \"3\" time_zone: \"America/Los_Angeles\" }\n }\n \"dimensions\": [\"apiLevel\"]\n \"metrics\": [\"errorReportCount\", \"distinctUsers\"]\n \"page_size\": \"10\"\n}\n```\n\n\nHere are some collection-level examples:\n\n| Fields ||\n|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `timelineSpec` | `object (`[TimelineSpec](/play/developer/reporting/reference/rest/v1beta1/anomalies#TimelineSpec)`)` Specification of the timeline aggregation parameters. Please check the documentation of each metric set for a list of what aggregation periods are supported. |\n| `dimensions[]` | `string` Dimensions to slice the metrics by. Please check the documentation of each metric set for a list of what dimensions are supported. |\n| `metrics[]` | `string` Metrics to aggregate. |\n| `pageSize` | `integer` 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. |\n\n### Handling responses\n\n\nAfter a server processes a valid request that includes valid fields, it sends back an HTTP\n`200 OK` status code, along with the requested data. If the `fields`\nquery parameter has an error or is otherwise invalid, the server returns an HTTP\n`400 Bad Request` status code, along with an error message telling the user what\nwas wrong with their fields selection (for example, `\"Invalid field timeline_spec\"`).\n\n\nHere is the response example shown in the introductory section above. \n\n```text\nPOST https://playdeveloperreporting.googleapis.com/v1beta1/apps/com.example.app/crashRateMetricSet:query\n```\n\nThe response looks like this: \n\n```\n200 OK\n``` \n\n```verilog\n{\n rows: [\n {\n aggregation_period: \"DAILY\"\n start_time: { year: \"2021\" month: \"7\" day: \"1\" time_zone: \"America/Los_Angeles\" }\n dimensions: [{dimension: \"apiLevel\" int64_value: \"20\"}]\n metrics: [\n {metric: \"errorReportCount\" decimal_value: \"100\"},\n {metric: \"distinctUsers\" decimal_value: \"57\"},\n ]\n }, {\n aggregation_period: \"DAILY\"\n start_time: { year: \"2021\" month: \"7\" day: \"1\" time_zone: \"America/Los_Angeles\" }\n dimensions: [{dimension: \"apiLevel\" int64_value: \"21\"}]\n metrics: [\n {metric: \"errorReportCount\" decimal_value: \"123\"},\n {metric: \"distinctUsers\" decimal_value: \"65\"},\n ]\n },\n ...\n ]\n next_page_token: \"eW91IGhhdmUgdG9vIG11Y2ggZnJlZSB0aW1l\"\n}\n```\n\n\n**Note:** For APIs that support query parameters for data pagination (`maxResults`\nand `nextPageToken`, for example), use those parameters to reduce the results of each\nquery to a manageable size."]]