Python SDK Examples
Code examples for integrating vfrog.ai with Python applications.
Installation
pip install requests
Basic Usage
import requests
import os
API_KEY = os.environ.get('VFROG_API_KEY')
BASE_URL = "https://api.vfrog.ai/v1/cv"
class VfrogClient:
def __init__(self, api_key):
self.api_key = api_key
self.headers = {
"x-api-key": api_key,
"Content-Type": "application/json"
}
def process_sync(self, image_url, external_id):
"""Submit sync processing request"""
payload = {
"external_id": external_id,
"image_url": image_url
}
response = requests.post(
f"{BASE_URL}/sync_request",
headers=self.headers,
json=payload,
timeout=30
)
response.raise_for_status()
return response.json()
# Usage
client = VfrogClient(API_KEY)
# Sync
result = client.process_sync(
"https://example.com/product.jpg",
"scan-456"
)
print(f"Found {len(result['results'])} objects")
More Examples
See the GitHub repository for more examples.