import requests
API_KEY = "rastro_pk_..."
BASE_URL = "https://catalogapi.rastro.ai/api"
response = requests.post(
f"{BASE_URL}/public/enrich",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
},
json={
"prompt": "Find product specifications",
"items": [
{"name": "Sony WH-1000XM5"},
{"name": "Apple AirPods Pro 2"}
],
"output_schema": [
{"name": "price", "type": "string", "description": "Current retail price"},
{"name": "weight", "type": "string", "description": "Product weight"},
{"name": "battery_life", "type": "string", "description": "Battery duration"}
]
}
)
result = response.json()
print(f"Processed {result['total_items']} items, {result['successful']} successful")
for item_result in result["results"]:
print(f"\n{item_result['original_data']['name']}:")
for field, data in item_result["enriched_fields"].items():
print(f" {field}: {data['value']}")
print(f" Sources: {data['sources']}")