Skip to content

Page Monitoring

Fresh Source: docs.airtop.ai

The monitor method watches a page for a specific condition at configurable intervals. When the condition is met (or the timeout expires), it returns the result.

Basic Usage

typescript
const result = await client.windows.monitor(sessionId, windowId, {
  condition: 'The product price drops below $100',
  configuration: {
    intervalMs: 5000,     // Check every 5 seconds
    timeoutMs: 300000,    // Give up after 5 minutes
  },
});

if (result.data.conditionMet) {
  console.log('Condition met:', result.data.modelResponse);
} else {
  console.log('Timed out');
}
python
result = client.windows.monitor(session_id, window_id,
    condition="The product price drops below $100",
    configuration={
        "intervalMs": 5000,
        "timeoutMs": 300000,
    }
)

if result.data.condition_met:
    print(f"Condition met: {result.data.model_response}")
else:
    print("Timed out")

Configuration

ParameterTypeDescription
conditionstringNatural language condition to watch for
intervalMsnumberTime between checks in milliseconds
timeoutMsnumberMaximum wait time before giving up

Response Fields

FieldTypeDescription
conditionMetbooleanWhether the condition was satisfied
modelResponsestringAI description of what was observed

Visual Analysis

The monitor doesn't just check text — it can analyze visual changes on the page:

typescript
// Watch for visual indicator changes
await client.windows.monitor(sessionId, windowId, {
  condition: 'The status badge changes from "Pending" (yellow) to "Complete" (green)',
  configuration: { intervalMs: 3000, timeoutMs: 120000 },
});

Use Case Examples

Price Monitoring

typescript
const result = await client.windows.monitor(sessionId, windowId, {
  condition: 'The price displayed on the page is less than $50',
  configuration: { intervalMs: 10000, timeoutMs: 600000 },
});
python
result = client.windows.monitor(session_id, window_id,
    condition="The price displayed on the page is less than $50",
    configuration={"intervalMs": 10000, "timeoutMs": 600000}
)

Stock Availability

typescript
const result = await client.windows.monitor(sessionId, windowId, {
  condition: 'The product shows as "In Stock" or an "Add to Cart" button is visible',
  configuration: { intervalMs: 15000, timeoutMs: 900000 },
});

Content Updates

typescript
const result = await client.windows.monitor(sessionId, windowId, {
  condition: 'A new article or post appears that was not visible when monitoring started',
  configuration: { intervalMs: 30000, timeoutMs: 3600000 },
});

Build/Deploy Status

typescript
const result = await client.windows.monitor(sessionId, windowId, {
  condition: 'The deployment status changes to "Success" or "Failed"',
  configuration: { intervalMs: 5000, timeoutMs: 300000 },
});

Best Practices

  1. Match session timeout to monitor timeout — ensure timeoutMinutes > timeoutMs / 60000
  2. Use reasonable intervals — 5-30 seconds for most cases; faster intervals use more credits
  3. Be specific in conditions — "price drops below $50" is better than "price changes"
  4. Handle both outcomes — always check conditionMet and handle the timeout case
  5. Combine with actions — after condition is met, use click/type to act
  6. Set cost thresholds — long-running monitors can accumulate costs

Unofficial SOP documentation for Airtop