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" ,
"output_schema" : { "title" : "string" , "price" : "number" },
"filter_config" : {
"mode" : "all" ,
"conditions" : [
{ "field" : "price" , "operator" : "gt" , "value" : "10" }
]
}
}
Field Type Required Description urlstring Yes Target webpage URL descriptionstring Yes What to extract namestring Yes Strategy name output_schemaobject No Desired output JSON structure. See Output Schemas filter_configobject No Post-extraction filter. See Filtering strategy_group_idUUID No Add the strategy to this group on creation
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
Parameter Type Required Description limitinteger No Max results (default: 20) offsetinteger No Results 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_..."
Update strategy
Update a strategy’s filter configuration.
PATCH /api/strategies/{strategy_id}
Request body
{
"filter_config" : {
"mode" : "all" ,
"conditions" : [
{ "field" : "price" , "operator" : "gt" , "value" : "50" },
{ "field" : "in_stock" , "operator" : "equals" , "value" : "true" }
]
}
}
Field Type Required Description filter_configobject No Post-extraction filter configuration. See Filtering
Response
Updated strategy details.
Example
curl -X PATCH https://api.meter.sh/api/strategies/550e8400-e29b-41d4-a716-446655440000 \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"filter_config": {
"mode": "all",
"conditions": [
{"field": "price", "operator": "gt", "value": "50"}
]
}
}'
Compare manifest
Compare a manifest of known items against the latest scrape results for a strategy. This is a convenience endpoint that automatically uses the most recent completed job.
POST /api/strategies/{strategy_id}/compare-manifest
Request body
{
"manifest" : [
{ "name" : "Acme Corp" },
{ "name" : "Beta Industries" },
{ "name" : "Gamma Solutions" }
],
"match_fields" : [ "name" ],
"threshold" : 80
}
Field Type Required Description manifestarray Yes List of known items (objects with at least the match_fields keys) match_fieldsarray Yes Field name(s) to fuzzy-match on (e.g., ["name"]) thresholdnumber No Minimum match score 0-100 (default: 80)
Response
{
"matched" : [
{
"manifest_item" : { "name" : "Acme Corp" },
"scraped_item" : { "name" : "Acme Corporation" , "website" : "acme.com" },
"score" : 90.0 ,
"matched_on" : "name"
}
],
"added" : [
{ "name" : "Delta Partners" , "website" : "delta.com" }
],
"removed" : [
{ "name" : "Beta Industries" }
],
"summary" : {
"matched" : 1 ,
"added" : 1 ,
"removed" : 1 ,
"manifest_count" : 2 ,
"scraped_count" : 2
},
"threshold_used" : 80.0 ,
"match_fields_used" : [ "name" ],
"job_id" : "660e8400-e29b-41d4-a716-446655440000"
}
Example
curl -X POST https://api.meter.sh/api/strategies/550e8400-e29b-41d4-a716-446655440000/compare-manifest \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"manifest": [
{"name": "Acme Corp"},
{"name": "Beta Industries"}
],
"match_fields": ["name"],
"threshold": 80
}'
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
Status Description 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
Job Endpoints Execute scrapes using strategies
Python SDK Use the Python SDK instead
Strategies Concept Learn about strategies
Need help?
Email me at mckinnon@meter.sh