Google Shopping Merchant Reviews API client library for managing merchant and product reviews
npx @tessl/cli install tessl/pypi-google-shopping-merchant-reviews@0.2.00
# Google Shopping Merchant Reviews
1
2
A Python client library for the Google Shopping Merchant Reviews API that enables developers to programmatically manage merchant and product reviews. This library provides comprehensive functionality for submitting, retrieving, and managing merchant reviews and product reviews within Google's merchant ecosystem.
3
4
## Package Information
5
6
- **Package Name**: google-shopping-merchant-reviews
7
- **Language**: Python
8
- **Installation**: `pip install google-shopping-merchant-reviews`
9
- **Python Support**: 3.7+
10
11
## Core Imports
12
13
```python
14
from google.shopping.merchant_reviews import (
15
MerchantReviewsServiceClient,
16
MerchantReviewsServiceAsyncClient,
17
ProductReviewsServiceClient,
18
ProductReviewsServiceAsyncClient
19
)
20
```
21
22
For working with data types:
23
24
```python
25
from google.shopping.merchant_reviews import (
26
MerchantReview,
27
ProductReview,
28
MerchantReviewAttributes,
29
ProductReviewAttributes,
30
MerchantReviewStatus,
31
ProductReviewStatus,
32
# Request/Response types
33
GetMerchantReviewRequest,
34
ListMerchantReviewsRequest,
35
ListMerchantReviewsResponse,
36
InsertMerchantReviewRequest,
37
DeleteMerchantReviewRequest,
38
GetProductReviewRequest,
39
ListProductReviewsRequest,
40
ListProductReviewsResponse,
41
InsertProductReviewRequest,
42
DeleteProductReviewRequest
43
)
44
```
45
46
For authentication and client configuration:
47
48
```python
49
from google.auth import credentials as ga_credentials
50
from google.auth import service_account
51
from google.api_core import client_options as client_options_lib
52
from google.api_core import gapic_v1
53
from google.api_core import retry as retries
54
```
55
56
For custom types in shopping:
57
58
```python
59
from google.shopping.type.types import types
60
```
61
62
## Basic Usage
63
64
```python
65
from google.shopping.merchant_reviews import MerchantReviewsServiceClient
66
from google.auth import default
67
68
# Initialize client with default credentials
69
credentials, project = default()
70
client = MerchantReviewsServiceClient(credentials=credentials)
71
72
# List merchant reviews for an account
73
parent = "accounts/your-account-id"
74
reviews = client.list_merchant_reviews(parent=parent)
75
76
# Iterate through results
77
for review in reviews:
78
print(f"Review ID: {review.merchant_review_id}")
79
print(f"Rating: {review.merchant_review_attributes.rating}")
80
print(f"Content: {review.merchant_review_attributes.content}")
81
```
82
83
## Architecture
84
85
The library follows Google Cloud client library patterns with several key components:
86
87
- **Service Clients**: Primary interfaces for API operations (sync and async variants)
88
- **Data Types**: Proto message classes representing reviews, attributes, and status information
89
- **Transport Layer**: Multiple transport options (gRPC, REST) with automatic retry and authentication
90
- **Pagination**: Built-in pager classes for efficient handling of large result sets
91
- **Authentication**: Integration with Google Cloud authentication and service accounts
92
93
The API is organized around two main services:
94
- **Merchant Reviews Service**: Manages reviews about merchants themselves
95
- **Product Reviews Service**: Manages reviews about specific products
96
97
## Capabilities
98
99
### Merchant Reviews Management
100
101
Complete CRUD operations for merchant reviews including retrieval, listing with pagination, insertion, and deletion. Supports both synchronous and asynchronous operations.
102
103
```python { .api }
104
class MerchantReviewsServiceClient:
105
def get_merchant_review(
106
self,
107
request: Optional[Union[GetMerchantReviewRequest, dict]] = None,
108
*,
109
name: Optional[str] = None,
110
retry = gapic_v1.method.DEFAULT,
111
timeout = gapic_v1.method.DEFAULT,
112
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
113
) -> MerchantReview: ...
114
115
def list_merchant_reviews(
116
self,
117
request: Optional[Union[ListMerchantReviewsRequest, dict]] = None,
118
*,
119
parent: Optional[str] = None,
120
retry = gapic_v1.method.DEFAULT,
121
timeout = gapic_v1.method.DEFAULT,
122
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
123
) -> ListMerchantReviewsPager: ...
124
125
def insert_merchant_review(
126
self,
127
request: Optional[Union[InsertMerchantReviewRequest, dict]] = None,
128
*,
129
retry = gapic_v1.method.DEFAULT,
130
timeout = gapic_v1.method.DEFAULT,
131
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
132
) -> MerchantReview: ...
133
134
def delete_merchant_review(
135
self,
136
request: Optional[Union[DeleteMerchantReviewRequest, dict]] = None,
137
*,
138
name: Optional[str] = None,
139
retry = gapic_v1.method.DEFAULT,
140
timeout = gapic_v1.method.DEFAULT,
141
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
142
) -> None: ...
143
144
class MerchantReviewsServiceAsyncClient:
145
async def get_merchant_review(self, ...) -> MerchantReview: ...
146
async def list_merchant_reviews(self, ...) -> ListMerchantReviewsAsyncPager: ...
147
async def insert_merchant_review(self, ...) -> MerchantReview: ...
148
async def delete_merchant_review(self, ...) -> None: ...
149
```
150
151
[Merchant Reviews](./merchant-reviews.md)
152
153
### Product Reviews Management
154
155
Complete CRUD operations for product reviews including retrieval, listing with pagination, insertion, and deletion. Supports both synchronous and asynchronous operations.
156
157
```python { .api }
158
class ProductReviewsServiceClient:
159
def get_product_review(
160
self,
161
request: Optional[Union[GetProductReviewRequest, dict]] = None,
162
*,
163
name: Optional[str] = None,
164
retry = gapic_v1.method.DEFAULT,
165
timeout = gapic_v1.method.DEFAULT,
166
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
167
) -> ProductReview: ...
168
169
def list_product_reviews(
170
self,
171
request: Optional[Union[ListProductReviewsRequest, dict]] = None,
172
*,
173
parent: Optional[str] = None,
174
retry = gapic_v1.method.DEFAULT,
175
timeout = gapic_v1.method.DEFAULT,
176
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
177
) -> ListProductReviewsPager: ...
178
179
def insert_product_review(
180
self,
181
request: Optional[Union[InsertProductReviewRequest, dict]] = None,
182
*,
183
retry = gapic_v1.method.DEFAULT,
184
timeout = gapic_v1.method.DEFAULT,
185
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
186
) -> ProductReview: ...
187
188
def delete_product_review(
189
self,
190
request: Optional[Union[DeleteProductReviewRequest, dict]] = None,
191
*,
192
name: Optional[str] = None,
193
retry = gapic_v1.method.DEFAULT,
194
timeout = gapic_v1.method.DEFAULT,
195
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
196
) -> None: ...
197
198
class ProductReviewsServiceAsyncClient:
199
async def get_product_review(self, ...) -> ProductReview: ...
200
async def list_product_reviews(self, ...) -> ListProductReviewsAsyncPager: ...
201
async def insert_product_review(self, ...) -> ProductReview: ...
202
async def delete_product_review(self, ...) -> None: ...
203
```
204
205
[Product Reviews](./product-reviews.md)
206
207
### Data Types and Messages
208
209
Comprehensive type system including review objects, attributes, status information, and request/response types for all API operations.
210
211
```python { .api }
212
class MerchantReview:
213
name: str
214
merchant_review_id: str
215
merchant_review_attributes: MerchantReviewAttributes
216
custom_attributes: MutableSequence[CustomAttribute]
217
data_source: str # Output only
218
merchant_review_status: MerchantReviewStatus # Output only
219
220
class ProductReview:
221
name: str
222
product_review_id: str
223
product_review_attributes: ProductReviewAttributes
224
custom_attributes: MutableSequence[CustomAttribute]
225
data_source: str # Output only
226
product_review_status: ProductReviewStatus # Output only
227
```
228
229
[Data Types](./data-types.md)
230
231
## Types
232
233
```python { .api }
234
# Core service client classes
235
class MerchantReviewsServiceClient:
236
def __init__(
237
self,
238
*,
239
credentials: Optional[ga_credentials.Credentials] = None,
240
transport: Optional[Union[str, MerchantReviewsServiceTransport]] = None,
241
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
242
client_info: gapic_v1.client_info.ClientInfo = None
243
): ...
244
245
class MerchantReviewsServiceAsyncClient:
246
def __init__(
247
self,
248
*,
249
credentials: Optional[ga_credentials.Credentials] = None,
250
transport: Optional[Union[str, MerchantReviewsServiceTransport]] = None,
251
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
252
client_info: gapic_v1.client_info.ClientInfo = None
253
): ...
254
255
class ProductReviewsServiceClient:
256
def __init__(
257
self,
258
*,
259
credentials: Optional[ga_credentials.Credentials] = None,
260
transport: Optional[Union[str, ProductReviewsServiceTransport]] = None,
261
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
262
client_info: gapic_v1.client_info.ClientInfo = None
263
): ...
264
265
class ProductReviewsServiceAsyncClient:
266
def __init__(
267
self,
268
*,
269
credentials: Optional[ga_credentials.Credentials] = None,
270
transport: Optional[Union[str, ProductReviewsServiceTransport]] = None,
271
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
272
client_info: gapic_v1.client_info.ClientInfo = None
273
): ...
274
275
# Pagination classes
276
class ListMerchantReviewsPager:
277
def __iter__(self) -> Iterator[MerchantReview]: ...
278
@property
279
def pages(self) -> Iterator[ListMerchantReviewsResponse]: ...
280
281
class ListMerchantReviewsAsyncPager:
282
def __aiter__(self) -> AsyncIterator[MerchantReview]: ...
283
@property
284
def pages(self) -> AsyncIterator[ListMerchantReviewsResponse]: ...
285
286
class ListProductReviewsPager:
287
def __iter__(self) -> Iterator[ProductReview]: ...
288
@property
289
def pages(self) -> Iterator[ListProductReviewsResponse]: ...
290
291
class ListProductReviewsAsyncPager:
292
def __aiter__(self) -> AsyncIterator[ProductReview]: ...
293
@property
294
def pages(self) -> AsyncIterator[ListProductReviewsResponse]: ...
295
```