Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Sau đây là một truy vấn mẫu đến MerchantPerformanceView, truy vấn này trả về hiệu suất của tài khoản trong 30 ngày qua, được phân đoạn theo program và offer_id. Bạn có thể thử ví dụ nhanh này để làm quen với dịch vụ Reports.
Nhấp vào Run (Chạy) để dùng thử mẫu trong API Explorer. Sau khi bạn nhấp vào Chạy, hãy cập nhật phần giữ chỗ mã người bán thành mã người bán của riêng bạn trong URL yêu cầu. Bạn có thể sửa đổi câu hỏi. Toàn bộ truy vấn phải nằm trên một dòng để hoạt động với trình khám phá API.
URL yêu cầu HTTP
Yêu cầu này bao gồm một yêu cầu HTTP POST đến máy chủ Content API for Shopping tại URL sau:
Sau đây là một ví dụ hoàn chỉnh cho thấy định nghĩa báo cáo ở trên được đặt trong một yêu cầu HTTP POST:
POST/v2.1/merchantId/reports/searchHTTP/1.1Host:shoppingcontent.googleapis.comUser-Agent:curlContent-Type:application/jsonAccept:application/jsonAuthorization:Bearer access tokenParameters:{"query":"SELECT segments.program, segments.offer_id, metrics.impressions, metrics.clicks, metrics.ctr FROM MerchantPerformanceView WHERE segments.date BETWEEN '2020-11-01' AND '2020-11-30'"}
[null,null,["Cập nhật lần gần đây nhất: 2025-08-13 UTC."],[[["\u003cp\u003eThe Merchant API is the new version of the Content API for Shopping and represents the future of the platform.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the Merchant API to retrieve performance data, such as impressions, clicks, and CTR, segmented by program and offer ID.\u003c/p\u003e\n"],["\u003cp\u003eA sample query is provided to demonstrate how to retrieve performance data for the last 30 days using the \u003ccode\u003eMerchantPerformanceView\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eIt's recommended to use one of the client libraries instead of directly making HTTP requests to the Content API for Shopping.\u003c/p\u003e\n"]]],["The beta version of the Merchant API, the new Content API for Shopping, is introduced. To use the `Reports` service, users with the Reporting manager role can query the `MerchantPerformanceView` for account performance. A sample query using Merchant Center Query Language is provided to retrieve data on `program`, `offer_id`, `impressions`, `clicks`, and `ctr` between '2020-11-01' and '2020-11-30'. Users can run the sample via the API Explorer, updating the merchant ID and modifying the query.\n"],null,["# Example\n\nHere's a sample query to the `MerchantPerformanceView` that returns the\nperformance of your account over the last 30 days, segmented by `program` and\n`offer_id`. You can try this quick example to get familiar with the `Reports` service.\n\nYou need the [Reporting manager\nrole](//support.google.com/merchants/answer/11935402) to retrieve this report.\n\nTo make the request, pass the following Merchant Center Query\nLanguage statement to the\n[`reports.search`](/shopping-content/reference/rest/v2.1/reports/search)\nmethod: \n\n SELECT\n segments.program,\n segments.offer_id,\n metrics.impressions,\n metrics.clicks,\n metrics.ctr\n FROM MerchantPerformanceView\n WHERE segments.date BETWEEN '2020-11-01' AND '2020-11-30'\n\n[Run](https://developers.google.com/shopping-content/reference/rest/v2.1/reports/search?apix=true&apix_params=%7B%22merchantId%22%3A0%2C%22resource%22%3A%7B%22query%22%3A%22SELECT%20%20segments.program%2C%20%20segments.offer_id%2C%20%20metrics.impressions%2C%20%20metrics.clicks%2C%20%20metrics.ctr%20FROM%20MerchantPerformanceView%20WHERE%20segments.date%20BETWEEN%20%272020-11-01%27%20AND%20%272020-11-30%27%22%7D%7D)\n\nClick **Run** to try the sample in the **API Explorer** . After you click\n**Run** , update the merchant ID placeholder to your own merchant ID in the\nrequest URL. You can modify the query. The full query must remain on one line to\nwork with the **API explorer**.\n| **Note:** This guide shows the underlying HTTP request as a teaching tool, but we recommend that you use one of the [client libraries](/shopping-content/guides/libraries) to submit your requests.\n\nHTTP request URL\n----------------\n\nThe request consists of an HTTP POST to the Content API for Shopping server at\nthe following URL: \n\n```text\nhttps://shoppingcontent.googleapis.com/content/v2.1/merchantId/reports/search\n```\n\nComplete HTTP request sample\n----------------------------\n\nHere is a complete example showing the report definition above enclosed within\nan HTTP POST request: \n\n```http\nPOST /v2.1/\u003cvar class=\"edit\" translate=\"no\"\u003emerchantId\u003c/var\u003e/reports/search HTTP/1.1\nHost: shoppingcontent.googleapis.com\nUser-Agent: curl\nContent-Type: application/json\nAccept: application/json\nAuthorization: Bearer \u003cvar class=\"edit\" translate=\"no\"\u003eaccess token\u003c/var\u003e\n\nParameters:\n{\n \"query\" : \"SELECT segments.program, segments.offer_id, metrics.impressions,\n metrics.clicks, metrics.ctr\n FROM MerchantPerformanceView\n WHERE segments.date BETWEEN '2020-11-01' AND '2020-11-30'\"\n}\n```"]]