API Documentation

Endpoints

Process Endpoint

POST /api/v1/{endpoint_id}/

Headers


{ "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json" }

Request Body


{
  "query": "search query",
  "instructions": "extraction instructions",
  "url_pattern_match": "regex pattern",
  "pattern_exclude": false,
  "results": 5,
  "schema": {
    "field_name": {
      "type": "string|integer|boolean",
      "description": "field description"
    }
  }
}
  • query Required - The search query to use
  • instructions Required - Instructions for data extraction
  • schema Optional - Definition of fields to extract. If not provided, a schema will be automatically generated based on the instructions
  • url_pattern_match Optional - Regex pattern to filter URLs
  • pattern_exclude Optional - Whether to exclude or include pattern matches
  • results Optional - Number of results to process (default: 5)

Note: These parameters can be set as defaults when creating the endpoint, and overridden in the request body.

Response


{ "status": "success", "message": "Request accepted and being processed", "task_id": "550e8400-e29b-41d4-a716-446655440000" }

Webhook Payload


{ 
  "task_id": "550e8400-e29b-41d4-a716-446655440000", 
  "success": true, 
  "url": "https://example.com/page1", 
  "items": [
    { 
      "price": "$35,000", 
      "model": "Model 3 Standard Range", 
      "year": 2024 
    },
    {
      "price": "$40,000",
      "model": "Model 3 Standard Range Plus",
      "year": 2024
    }
  ] 
}

Results will be sent to your webhook endpoints as they are processed. Each URL's results will be sent as a separate webhook request.

Error Responses

401 Missing or invalid API key

{"status": "error", "message": "Invalid API key"}

403 Not authorized for this endpoint

{"status": "error", "message": "Not authorized to access this endpoint"}

404 Endpoint not found

{"status": "error", "message": "Endpoint not found"}

400 Invalid request data

{"status": "error", "message": "Invalid JSON data"}

429 Rate limit exceeded

{"status": "error", "message": "Rate limit exceeded. Please wait 10 seconds."}

500 Server error

{"status": "error", "message": "Server error: {error details}"}

Webhook Integration

Configure a webhook to receive results automatically. Each search result will be processed and sent individually to your webhook endpoint. This is useful for requests that may take longer to process.

Webhook Configuration

  • Configure your webhook URL in the endpoint settings
  • Configure custom headers for your webhook (optional)
  • Choose HTTP method for the webhook (GET, POST, etc.)
  • Use the task_id from the initial request to track related results

Webhook Payload Format


{ 
  "task_id": "unique-task-id", 
  "success": true, 
  "url": "https://example.com/page", 
  "items": [{ 
    "price": "$35,000",
    "model": "Model 3 Standard Range",
    "year": 2024
  }] 
}

Each webhook response represents one processed URL. Multiple webhook requests may be sent for a single API request, all sharing the same task_id.

Webhook Response

  • Webhook expects a response within 10 seconds
  • Failed webhook deliveries will be logged but not retried
  • Each webhook can have its own custom headers

Rate Limits

Plan Requests per Day Results per Request
Free Account 10 10
Business Account Custom Custom

Code Examples


import requests

API_KEY = 'your_api_key'
ENDPOINT_ID = 'your-endpoint-id'

headers = {
    'x-api-key': API_KEY,
    'Content-Type': 'application/json'
}

data = {
    'query': 'tesla model 3 price',
    'instructions': 'Extract the price for each variant',
    'results': 5
}

response = requests.post(
    f'https://api.autoserp.com/endpoint/v1/{ENDPOINT_ID}/',
    json=data,
    headers=headers
)

# Get task_id to track results in webhooks
task_id = response.json().get('task_id')