-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathucp_search.py
More file actions
58 lines (47 loc) · 1.92 KB
/
Copy pathucp_search.py
File metadata and controls
58 lines (47 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""UCP merchant and product search example.
This example demonstrates:
- Searching for UCP merchants
- Searching for products across merchants
- Using filters and pagination
"""
import asyncio
import os
from rencom import AsyncRencomClient
async def main():
"""Search UCP merchants and products."""
api_key = os.getenv("RENCOM_API_KEY")
if not api_key:
print("Error: RENCOM_API_KEY environment variable not set")
return
async with AsyncRencomClient(api_key=api_key) as client:
# Search for retail merchants with checkout capability
print("Searching for retail merchants...")
merchants = await client.ucp.merchants.search(
capabilities=["dev.ucp.shopping.checkout"], industry="retail", limit=5
)
print(f"\nFound {merchants.total} merchants (showing {len(merchants.merchants)}):")
for merchant in merchants.merchants:
print(f"\n{merchant.name} ({merchant.domain})")
print(f" Industry: {merchant.industry}")
print(f" Region: {merchant.region}")
print(f" Capabilities: {', '.join(merchant.capabilities)}")
# Search for products
print("\n\nSearching for laptops under $1500...")
products = await client.ucp.products.search(
"laptop",
price_max=150000, # $1500 in cents
category="electronics",
condition="new",
limit=10,
)
print(f"\nFound {products.total} products (showing {len(products.products)}):")
for product in products.products:
if product.price:
price = product.price.amount / 100
print(f"\n{product.title}")
print(f" Price: ${price:.2f}")
print(f" Merchant: {product.merchant_domain}")
if product.brand:
print(f" Brand: {product.brand}")
if __name__ == "__main__":
asyncio.run(main())