MCPcopy Create free account
hub / github.com/googleapis/google-api-python-client / main

Function main

samples/searchforshopping/crowding.py:17–45  ·  view source on GitHub ↗

Get and print a feed of public products in the United States mathing a text search query for 'digital camera' and grouped by the 8 top brands. The list method of the resource should be called with the "crowdBy" parameter. Each parameter should be designed as : ,

()

Source from the content-addressed store, hash-verified

15
16
17def main():
18 """Get and print a feed of public products in the United States mathing a
19 text search query for 'digital camera' and grouped by the 8 top brands.
20
21 The list method of the resource should be called with the "crowdBy"
22 parameter. Each parameter should be designed as <attribute>:<occurence>,
23 where <occurrence> is the number of that <attribute> that will be used. For
24 example, to crowd by the 5 top brands, the parameter would be "brand:5". The
25 possible rules for crowding are currently:
26
27 account_id:<occurrence> (eg account_id:5)
28 brand:<occurrence> (eg brand:5)
29 condition:<occurrence> (eg condition:3)
30 gtin:<occurrence> (eg gtin:10)
31 price:<occurrence> (eg price:10)
32
33 Multiple crowding rules should be specified by separating them with a comma,
34 for example to crowd by the top 5 brands and then condition of those items,
35 the parameter should be crowdBy="brand:5,condition:3"
36 """
37 client = build("shopping", SHOPPING_API_VERSION, developerKey=DEVELOPER_KEY)
38 resource = client.products()
39 # The crowdBy parameter to the list method causes the results to be grouped,
40 # in this case by the top 8 brands.
41 request = resource.list(
42 source="public", country="US", q="digital camera", crowdBy="brand:8"
43 )
44 response = request.execute()
45 pprint.pprint(response)
46
47
48if __name__ == "__main__":

Callers 1

crowding.pyFile · 0.70

Calls 2

buildFunction · 0.90
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…