Skip to main content

Strategy Methods

Strategy methods allow you to create and manage AI-generated extraction strategies. See the MeterClient reference for complete method signatures.

Quick reference

MethodDescription
generate_strategy()Generate a new extraction strategy using AI
refine_strategy()Improve an existing strategy with feedback
list_strategies()List all strategies
get_strategy()Get details for a specific strategy
delete_strategy()Delete a strategy and associated data

Common workflows

Generate and refine

from meter_sdk import MeterClient

client = MeterClient(api_key="sk_live_...")

# Generate initial strategy
result = client.generate_strategy(
    url="https://shop.com/products",
    description="Extract product name, price, and image",
    name="Product Scraper"
)

# Check preview
print(result['preview_data'][:3])

# Refine if needed
if 'sku' not in result['preview_data'][0]:
    refined = client.refine_strategy(
        strategy_id=result['strategy_id'],
        feedback="Also extract the product SKU"
    )
    print(refined['preview_data'][:3])

List and filter

# Get all strategies
strategies = client.list_strategies()

# Find by name
product_strategies = [
    s for s in strategies
    if 'product' in s['name'].lower()
]

# Most recent
recent = client.list_strategies(limit=5, offset=0)

Batch operations

# Delete old strategies
strategies = client.list_strategies(limit=100)

for strategy in strategies:
    # Delete if created more than 30 days ago
    if is_old(strategy['created_at']):
        client.delete_strategy(strategy['id'])
        print(f"Deleted {strategy['name']}")

See also

Need help?

Email me at [email protected]