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.0A 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.
pip install google-shopping-merchant-reviewsfrom google.shopping.merchant_reviews import (
MerchantReviewsServiceClient,
MerchantReviewsServiceAsyncClient,
ProductReviewsServiceClient,
ProductReviewsServiceAsyncClient
)For working with data types:
from google.shopping.merchant_reviews import (
MerchantReview,
ProductReview,
MerchantReviewAttributes,
ProductReviewAttributes,
MerchantReviewStatus,
ProductReviewStatus,
# Request/Response types
GetMerchantReviewRequest,
ListMerchantReviewsRequest,
ListMerchantReviewsResponse,
InsertMerchantReviewRequest,
DeleteMerchantReviewRequest,
GetProductReviewRequest,
ListProductReviewsRequest,
ListProductReviewsResponse,
InsertProductReviewRequest,
DeleteProductReviewRequest
)For authentication and client configuration:
from google.auth import credentials as ga_credentials
from google.auth import service_account
from google.api_core import client_options as client_options_lib
from google.api_core import gapic_v1
from google.api_core import retry as retriesFor custom types in shopping:
from google.shopping.type.types import typesfrom google.shopping.merchant_reviews import MerchantReviewsServiceClient
from google.auth import default
# Initialize client with default credentials
credentials, project = default()
client = MerchantReviewsServiceClient(credentials=credentials)
# List merchant reviews for an account
parent = "accounts/your-account-id"
reviews = client.list_merchant_reviews(parent=parent)
# Iterate through results
for review in reviews:
print(f"Review ID: {review.merchant_review_id}")
print(f"Rating: {review.merchant_review_attributes.rating}")
print(f"Content: {review.merchant_review_attributes.content}")The library follows Google Cloud client library patterns with several key components:
The API is organized around two main services:
Complete CRUD operations for merchant reviews including retrieval, listing with pagination, insertion, and deletion. Supports both synchronous and asynchronous operations.
class MerchantReviewsServiceClient:
def get_merchant_review(
self,
request: Optional[Union[GetMerchantReviewRequest, dict]] = None,
*,
name: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> MerchantReview: ...
def list_merchant_reviews(
self,
request: Optional[Union[ListMerchantReviewsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> ListMerchantReviewsPager: ...
def insert_merchant_review(
self,
request: Optional[Union[InsertMerchantReviewRequest, dict]] = None,
*,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> MerchantReview: ...
def delete_merchant_review(
self,
request: Optional[Union[DeleteMerchantReviewRequest, dict]] = None,
*,
name: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> None: ...
class MerchantReviewsServiceAsyncClient:
async def get_merchant_review(self, ...) -> MerchantReview: ...
async def list_merchant_reviews(self, ...) -> ListMerchantReviewsAsyncPager: ...
async def insert_merchant_review(self, ...) -> MerchantReview: ...
async def delete_merchant_review(self, ...) -> None: ...Complete CRUD operations for product reviews including retrieval, listing with pagination, insertion, and deletion. Supports both synchronous and asynchronous operations.
class ProductReviewsServiceClient:
def get_product_review(
self,
request: Optional[Union[GetProductReviewRequest, dict]] = None,
*,
name: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> ProductReview: ...
def list_product_reviews(
self,
request: Optional[Union[ListProductReviewsRequest, dict]] = None,
*,
parent: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> ListProductReviewsPager: ...
def insert_product_review(
self,
request: Optional[Union[InsertProductReviewRequest, dict]] = None,
*,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> ProductReview: ...
def delete_product_review(
self,
request: Optional[Union[DeleteProductReviewRequest, dict]] = None,
*,
name: Optional[str] = None,
retry = gapic_v1.method.DEFAULT,
timeout = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, Union[str, bytes]]] = ()
) -> None: ...
class ProductReviewsServiceAsyncClient:
async def get_product_review(self, ...) -> ProductReview: ...
async def list_product_reviews(self, ...) -> ListProductReviewsAsyncPager: ...
async def insert_product_review(self, ...) -> ProductReview: ...
async def delete_product_review(self, ...) -> None: ...Comprehensive type system including review objects, attributes, status information, and request/response types for all API operations.
class MerchantReview:
name: str
merchant_review_id: str
merchant_review_attributes: MerchantReviewAttributes
custom_attributes: MutableSequence[CustomAttribute]
data_source: str # Output only
merchant_review_status: MerchantReviewStatus # Output only
class ProductReview:
name: str
product_review_id: str
product_review_attributes: ProductReviewAttributes
custom_attributes: MutableSequence[CustomAttribute]
data_source: str # Output only
product_review_status: ProductReviewStatus # Output only# Core service client classes
class MerchantReviewsServiceClient:
def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[Union[str, MerchantReviewsServiceTransport]] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = None
): ...
class MerchantReviewsServiceAsyncClient:
def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[Union[str, MerchantReviewsServiceTransport]] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = None
): ...
class ProductReviewsServiceClient:
def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[Union[str, ProductReviewsServiceTransport]] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = None
): ...
class ProductReviewsServiceAsyncClient:
def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Optional[Union[str, ProductReviewsServiceTransport]] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = None
): ...
# Pagination classes
class ListMerchantReviewsPager:
def __iter__(self) -> Iterator[MerchantReview]: ...
@property
def pages(self) -> Iterator[ListMerchantReviewsResponse]: ...
class ListMerchantReviewsAsyncPager:
def __aiter__(self) -> AsyncIterator[MerchantReview]: ...
@property
def pages(self) -> AsyncIterator[ListMerchantReviewsResponse]: ...
class ListProductReviewsPager:
def __iter__(self) -> Iterator[ProductReview]: ...
@property
def pages(self) -> Iterator[ListProductReviewsResponse]: ...
class ListProductReviewsAsyncPager:
def __aiter__(self) -> AsyncIterator[ProductReview]: ...
@property
def pages(self) -> AsyncIterator[ListProductReviewsResponse]: ...