การค้นหาชุดเมตริก
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หลังจากตั้งค่าทุกอย่างแล้ว คุณจะส่งคำขอไปยัง Google Play Developer Reporting API เพื่อดึงข้อมูล
เมตาดาต้าเกี่ยวกับชุดเมตริกและค้นหาเมตริกของชุดเมตริกเหล่านั้นได้
ตัวอย่างโค้ดต่อไปนี้แสดงวิธีส่งคำขออย่างง่าย 2-3 รายการ เช่น วิธีการด้านล่างจะแสดงวิธีดึงข้อมูลเมตริกต่างๆ ของแอป มีพารามิเตอร์การค้นหาที่แตกต่างกันเล็กน้อยซึ่งใช้เพื่อจำกัดการค้นหาได้
ตัวอย่างต่อไปนี้ดึงข้อมูลเมตาสำหรับชุดเมตริกอัตราการขัดข้องที่ตั้งค่าไว้สำหรับแอปพลิเคชันสมมติ 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
ขนาดสูงสุดของข้อมูลที่แสดง หากไม่ระบุ ระบบจะแสดงผลแถวอย่างมาก 1, 000 แถว
ค่าสูงสุดคือ 100,000 และค่าที่สูงกว่า 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
) ให้ใช้พารามิเตอร์เหล่านั้นเพื่อลดผลลัพธ์ของการค้นหาแต่ละครั้ง
ให้อยู่ในขนาดที่จัดการได้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\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."]]