Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Voici un exemple de requête destinée à MerchantPerformanceView qui renvoie les performances de votre compte au cours des 30 derniers jours, segmentées par program et offer_id. Vous pouvez essayer cet exemple simple pour vous familiariser avec le service Reports.
Cliquez sur Exécuter pour essayer l'exemple dans l'explorateur d'API. Après avoir cliqué sur Exécuter, remplacez l'espace réservé pour l'ID marchand par votre propre ID marchand dans l'URL de la requête. Vous pouvez modifier la requête. Pour fonctionner avec l'explorateur d'API, la requête complète doit tenir sur une seule ligne.
URL de la requête HTTP
La requête consiste en une requête HTTP POST adressée au serveur Content API for Shopping à l'URL suivante :
Voici un exemple complet illustrant la définition de rapport ci-dessus comprise dans une requête 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'"}
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/13 (UTC).
[null,null,["Dernière mise à jour le 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```"]]