Pivota Agent SDK for Python
Official Python SDK for integrating AI agents with the Pivota e-commerce platform.
🚀 Quick Start
Installation
pip install pivota-agent-sdk
Get API Key
from pivota_agent import PivotaAgentClient
# Create agent and get API key
client = PivotaAgentClient.create_agent(
agent_name="MyShoppingBot",
agent_email="bot@mycompany.com",
description="AI shopping assistant"
)
print(f"Your API key: {client.api_key}")
# Save this key securely!
Initialize with API Key
client = PivotaAgentClient(api_key="ak_live_your_key_here")
📚 Usage Examples
1. Search Products
# Search across all merchants
products = client.search_products(
query="gaming laptop",
max_price=1500,
limit=10
)
for product in products["products"]:
print(f"{product['name']} - ${product['price']} - {product['merchant_name']}")
2. Create Order
# Create order
order = client.create_order(
merchant_id="merch_xxx",
items=[
{"product_id": "prod_123", "quantity": 1},
{"product_id": "prod_456", "quantity": 2}
],
customer_email="buyer@example.com",
shipping_address={
"street": "123 Main St",
"city": "San Francisco",
"state": "CA",
"zip": "94105",
"country": "US"
}
)
print(f"Order created: {order['order_id']}")
print(f"Total: ${order['total_amount']}")
3. Process Payment
# Create payment
payment = client.create_payment(
order_id=order["order_id"],
payment_method={
"type": "card",
"token": "tok_visa_test" # From Stripe/Adyen
},
return_url="https://mybot.com/payment-callback"
)
if payment["status"] == "requires_action":
# Handle 3DS
print(f"Redirect user to: {payment['next_action']['redirect_url']}")
elif payment["status"] == "succeeded":
print("Payment successful!")
4. Track Order
# Get order status
order_status = client.get_order(order_id="order_xxx")
print(f"Status: {order_status['status']}")
print(f"Tracking: {order_status.get('tracking_number')}")
🔧 Advanced Features
Error Handling
from pivota_agent import AuthenticationError, RateLimitError, NotFoundError
try:
products = client.search_products(query="laptop")
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except NotFoundError:
print("Resource not found")
except PivotaAPIError as e:
print(f"API error: {e.message} (status: {e.status_code})")
Pagination
# Get all products with pagination
all_products = []
offset = 0
limit = 50
while True:
result = client.search_products(
query="shoes",
limit=limit,
offset=offset
)
all_products.extend(result["products"])
if not result["pagination"]["has_more"]:
break
offset += limit
print(f"Total products found: {len(all_products)}")
List Merchants
# Get all available merchants
merchants = client.list_merchants(status="active", limit=100)
for merchant in merchants:
print(f"{merchant['business_name']} - {merchant['status']}")
if merchant['mcp_connected']:
print(f" Platform: {merchant['mcp_platform']}")
if merchant['psp_connected']:
print(f" PSP: {merchant['psp_type']}")
📖 API Reference
PivotaAgentClient
Constructor
PivotaAgentClient(
api_key: str = None,
base_url: str = "https://web-production-fedb.up.railway.app/agent/v1",
timeout: int = 30
)
Methods
| Method | Description | Returns |
|---|---|---|
create_agent(name, email, desc) |
Create agent and get API key | PivotaAgentClient |
health_check() |
Check API health | Dict |
list_merchants(status, limit, offset) |
List merchants | List[Dict] |
search_products(query, **filters) |
Search products | Dict |
create_order(merchant_id, items, email) |
Create order | Dict |
get_order(order_id) |
Get order status | Dict |
list_orders(filters) |
List orders | Dict |
create_payment(order_id, payment_method) |
Create payment | Dict |
get_payment(payment_id) |
Get payment status | Dict |
get_analytics_summary() |
Get analytics | Dict |
🔒 Rate Limits
- Standard tier: 1,000 requests per minute
- Burst: Up to 50 requests in first 10 seconds
Rate limit headers included in responses:
X-RateLimit-Limit: Total limitX-RateLimit-Remaining: Remaining requestsX-RateLimit-Reset: Reset timestamp
🆘 Support
- Documentation: https://docs.pivota.com
- GitHub: https://github.com/pivota/pivota-agent-sdk-python
- Email: support@pivota.com
📄 License
MIT License - see LICENSE file for details
Metadata
Release files for pivota-agent 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pivota_agent-1.0.0.tar.gz | 10.6 kB | Without provenance | Details for pivota_agent-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pivota_agent-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pivota_agent-1.0.0-py3-none-any.whl |
Total release size: 20.6 kB
Release files / pivota_agent-1.0.0.tar.gz
| Download URL | pivota_agent-1.0.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc188b9c7d5e2c65f7f3d2d04488c284b536970ad818a2b6c92ccc9c95301a33
|
|
BLAKE2b-256 checksum How to use checksums |
e9b2e2914a75548742a17096a76e59cb26df46c08aabcd024bba3e0b6929b27f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / pivota_agent-1.0.0-py3-none-any.whl
| Download URL | pivota_agent-1.0.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0439c96b88b8863ccfa69d4124755d53cd31cafc6bdbddd9710dd19008e80850
|
|
BLAKE2b-256 checksum How to use checksums |
ee67ad824cab8d433af1bf0c490198135373fc5684f399daf94da577c4ad92d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for pivota-agent 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.