Google Shopping Type API client library providing protobuf-generated classes for common shopping data types
npx @tessl/cli install tessl/pypi-google-shopping-type@1.0.0Google Shopping Type API client library providing protobuf-generated classes for common shopping-related data types and structures. This package serves as a foundational dependency for other Google Shopping services with key features:
pip install google-shopping-typefrom google.shopping.type import (
Channel,
CustomAttribute,
Destination,
Price,
ReportingContext,
Weight
)Alternative import pattern:
from google.shopping.type.types import (
Channel,
CustomAttribute,
Destination,
Price,
ReportingContext,
Weight
)Version information:
from google.shopping.type import __version__from google.shopping.type import Price, Weight, Channel
# Create a price object
price = Price()
price.amount_micros = 1500000 # $1.50 in micros
price.currency_code = "USD"
# Create a weight object
weight = Weight()
weight.amount_micros = 1000000 # 1kg in micros
weight.unit = Weight.WeightUnit.KILOGRAM
# Create a channel enum
channel_online = Channel.ChannelEnum.ONLINE
channel_local = Channel.ChannelEnum.LOCAL
print(f"Price: {price.amount_micros} micros {price.currency_code}")
print(f"Weight: {weight.amount_micros} micros, unit: {weight.unit}")
print(f"Channels: {channel_online}, {channel_local}")This package follows Google's protobuf-based API design patterns using the proto-plus library. All classes are protobuf message classes that provide type-safe representations of shopping-related data structures:
proto.Message providing serialization and validationRepresents monetary values with micros precision and currency codes following ISO 4217 standards.
class Price(proto.Message):
"""
The price represented as a number and currency.
Attributes:
amount_micros (int, optional): Price in micros (1 million micros = 1 currency unit)
currency_code (str, optional): Three-letter ISO 4217 currency code
"""
amount_micros: int = proto.Field(proto.INT64, number=1, optional=True)
currency_code: str = proto.Field(proto.STRING, number=2, optional=True)Represents weight values with micros precision and standard units (kg/lb).
class Weight(proto.Message):
"""
The weight represented as the value in string and the unit.
Attributes:
amount_micros (int, optional): Weight in micros (1 million micros = 1 unit)
Can be set to -1 for infinity
unit (WeightUnit): Required weight unit (kg or lb)
"""
class WeightUnit(proto.Enum):
"""Weight unit enumeration."""
WEIGHT_UNIT_UNSPECIFIED = 0
POUND = 1
KILOGRAM = 2
amount_micros: int = proto.Field(proto.INT64, number=1, optional=True)
unit: WeightUnit = proto.Field(proto.ENUM, number=2, enum=WeightUnit)Represents custom attributes with hierarchical structure support for nested attributes.
class CustomAttribute(proto.Message):
"""
Custom attributes with name/value pairs or nested groups.
Exactly one of value or group_values must not be empty.
Attributes:
name (str, optional): The name of the attribute
value (str, optional): The value (mutually exclusive with group_values)
group_values (MutableSequence[CustomAttribute]): Nested attributes
"""
name: str = proto.Field(proto.STRING, number=1, optional=True)
value: str = proto.Field(proto.STRING, number=2, optional=True)
group_values: MutableSequence["CustomAttribute"] = proto.RepeatedField(
proto.MESSAGE, number=3, message="CustomAttribute"
)Defines available destinations where products can be displayed across Google's merchant ecosystem.
class Destination(proto.Message):
"""
Destinations available for a product.
Used in Merchant Center to control where products are displayed.
"""
class DestinationEnum(proto.Enum):
"""Destination values."""
DESTINATION_ENUM_UNSPECIFIED = 0
SHOPPING_ADS = 1
DISPLAY_ADS = 2
LOCAL_INVENTORY_ADS = 3
FREE_LISTINGS = 4
FREE_LOCAL_LISTINGS = 5
YOUTUBE_SHOPPING = 6Defines reporting contexts for account and product issues across various Google surfaces and formats.
class ReportingContext(proto.Message):
"""
Reporting contexts that account and product issues apply to.
Groups surfaces and formats for product results on Google.
"""
class ReportingContextEnum(proto.Enum):
"""Reporting context values."""
REPORTING_CONTEXT_ENUM_UNSPECIFIED = 0
SHOPPING_ADS = 1
DISCOVERY_ADS = 2 # Deprecated: Use DEMAND_GEN_ADS instead
DEMAND_GEN_ADS = 13
DEMAND_GEN_ADS_DISCOVER_SURFACE = 14
VIDEO_ADS = 3
DISPLAY_ADS = 4
LOCAL_INVENTORY_ADS = 5
VEHICLE_INVENTORY_ADS = 6
FREE_LISTINGS = 7
FREE_LOCAL_LISTINGS = 8
FREE_LOCAL_VEHICLE_LISTINGS = 9
YOUTUBE_SHOPPING = 10
CLOUD_RETAIL = 11
LOCAL_CLOUD_RETAIL = 12Distinguishes between online and local products in the merchant ecosystem.
class Channel(proto.Message):
"""
Channel of a product, used to distinguish between online and local products.
"""
class ChannelEnum(proto.Enum):
"""Channel values."""
CHANNEL_ENUM_UNSPECIFIED = 0
ONLINE = 1
LOCAL = 2All message classes extend proto.Message and provide the following common functionality:
# Common proto.Message methods available on all classes
def __init__(self, mapping=None, **kwargs): ...
def __contains__(self, key): ...
def __getattr__(self, key): ...
def __setattr__(self, key, value): ...
def to_dict(self, **kwargs): ...
def to_json(self, **kwargs): ...from typing import MutableMapping, MutableSequence
import protoThis package uses proto-plus validation which will raise ValueError exceptions for:
The protobuf classes handle serialization errors and will raise appropriate exceptions during message parsing or field validation.