Skip to main content

Strategy Endpoints

Create and manage AI-generated extraction strategies via HTTP.

Generate strategy

Generate a new extraction strategy using AI.
POST /api/strategies/generate

Request body

{
  "url": "https://example.com/products",
  "description": "Extract product names and prices",
  "name": "Product Scraper"
}
FieldTypeRequiredDescription
urlstringYesTarget webpage URL
descriptionstringYesWhat to extract
namestringYesStrategy name

Response

{
  "strategy_id": "550e8400-e29b-41d4-a716-446655440000",
  "strategy": {
    "container": {...},
    "fields": {...}
  },
  "preview_data": [
    {"name": "Product A", "price": "$19.99"},
    {"name": "Product B", "price": "$29.99"}
  ],
  "attempts": 1
}

Example

curl -X POST https://api.meter.sh/api/strategies/generate \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://news.ycombinator.com",
    "description": "Extract post titles and scores",
    "name": "HN Front Page"
  }'

Refine strategy

Improve an existing strategy with feedback.
POST /api/strategies/{strategy_id}/refine

Request body

{
  "feedback": "Also extract product images and SKU"
}

Response

Same as generate strategy response with updated preview data.

Example

curl -X POST https://api.meter.sh/api/strategies/550e8400-e29b-41d4-a716-446655440000/refine \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"feedback": "Also extract product images"}'

List strategies

Get all strategies for the authenticated user.
GET /api/strategies?limit=20&offset=0

Query parameters

ParameterTypeRequiredDescription
limitintegerNoMax results (default: 20)
offsetintegerNoResults to skip (default: 0)

Response

[
  {
    "strategy_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Product Scraper",
    "description": "Extract product names and prices",
    "url": "https://example.com/products",
    "preview_data": [...],
    "created_at": "2025-01-15T10:30:00Z",
    "updated_at": "2025-01-15T10:30:00Z"
  }
]

Example

curl https://api.meter.sh/api/strategies?limit=10 \
  -H "Authorization: Bearer sk_live_..."

Get strategy

Get details for a specific strategy.
GET /api/strategies/{strategy_id}

Response

Same format as list strategies items.

Example

curl https://api.meter.sh/api/strategies/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer sk_live_..."

Delete strategy

Delete a strategy and all associated jobs and schedules.
DELETE /api/strategies/{strategy_id}

Response

{
  "message": "Strategy deleted successfully"
}

Example

curl -X DELETE https://api.meter.sh/api/strategies/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer sk_live_..."
This action is irreversible and deletes all associated resources.

Error responses

StatusDescription
400Invalid request (missing required fields, invalid URL format)
401Invalid or missing API key
404Strategy not found
429Rate limit exceeded (strategy generation is rate-limited)
500Internal server error
503Service temporarily unavailable (AI service issues)
See REST API Errors for detailed error handling.

Next steps

Need help?

Email me at mckinnon@meter.sh