Skip to main content

Create your API key

Create your API key in the Catalog Dashboard.

Create a .env file

Create a file called .env in the root of your project and add the following line.
CATALOG_API_KEY=<YOUR_API_KEY>

Make an API request

Use Python or JavaScript, or call the API directly with cURL.
Install the required Python packages. If you want to store your API key in a .env file, make sure to install the dotenv library.
pip install requests
pip install python-dotenv
Once you’ve installed the dependencies, choose an endpoint below to get started:
Discover collections and product listings
import os
import requests
import time
from dotenv import load_dotenv

# Use .env to store your API key or paste it directly into the code
load_dotenv()

# Start async crawl
response = requests.post(
    'https://api.getcatalog.ai/v2/crawl',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.getenv('CATALOG_API_KEY')
    },
    json={
        'url': 'skims.com'
    }
)

data = response.json()
execution_id = data['execution_id']
print(f"Crawl started with execution ID: {execution_id}")

# Poll for results
while True:
    status_response = requests.get(
        f'https://api.getcatalog.ai/v2/crawl/{execution_id}',
        headers={'x-api-key': os.getenv('CATALOG_API_KEY')}
    )
    status_data = status_response.json()
    
    if status_data['status'] == 'completed':
        result = status_data['meta']['result']
        print(f"Crawl completed!")
        print(f"Collections found: {result['collections_total']}")
        print(f"Listings found: {result['listings_total']}")
        break
    elif status_data['status'] == 'failed':
        print(f"Crawl failed: {status_data.get('error', 'Unknown error')}")
        break
    else:
        progress = status_data.get('meta', {}).get('progress')
        if progress:
            print(f"Progress: {progress['collections_found']} collections, {progress['listings_found']} listings")
        time.sleep(10)  # Wait 10 seconds before next poll

# Fetch the discovered listings
listings_response = requests.post(
    'https://api.getcatalog.ai/v2/listings',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.getenv('CATALOG_API_KEY')
    },
    json={
        'vendor': 'skims.com',
        'page': 1,
        'page_size': 5
    }
)

listings = listings_response.json()
print(f"\nFirst {len(listings['data'])} listings:")
for listing in listings['data']:
    print(f"- {listing['name']}: {listing['url']}")