Page Querying
Fresh Source: docs.airtop.aiUse pageQuery to ask natural language questions about page content. Use paginatedExtraction for multi-page data collection. Both support JSON schema output for structured results.
pageQuery — Single Page
Basic Query
typescript
const result = await client.windows.pageQuery(sessionId, windowId, {
prompt: 'What is the main heading on this page?',
});
console.log(result.data.modelResponse);python
result = client.windows.page_query(
session_id, window_id,
prompt="What is the main heading on this page?"
)
print(result.data.model_response)Structured Output with JSON Schema
typescript
const result = await client.windows.pageQuery(sessionId, windowId, {
prompt: 'Extract all team members with their name, role, and LinkedIn URL',
configuration: {
outputSchema: {
type: 'object',
properties: {
teamMembers: {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
role: { type: 'string' },
linkedinUrl: { type: 'string' },
},
required: ['name', 'role'],
},
},
},
},
},
});
const data = JSON.parse(result.data.modelResponse);
console.log(data.teamMembers);python
result = client.windows.page_query(
session_id, window_id,
prompt="Extract all team members with their name, role, and LinkedIn URL",
configuration={
"outputSchema": {
"type": "object",
"properties": {
"teamMembers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {"type": "string"},
"role": {"type": "string"},
"linkedinUrl": {"type": "string"}
},
"required": ["name", "role"]
}
}
}
}
}
)
import json
data = json.loads(result.data.model_response)
print(data["teamMembers"])paginatedExtraction — Multi-Page
Automatically navigates through paginated content, collecting data from each page.
typescript
const result = await client.windows.paginatedExtraction(
sessionId,
windowId,
{
config: {
outputSchema: {
type: 'object',
properties: {
listings: {
type: 'array',
items: {
type: 'object',
properties: {
title: { type: 'string' },
price: { type: 'string' },
location: { type: 'string' },
},
},
},
},
},
},
}
);
console.log('Total items collected:', result.data.listings?.length);python
result = client.windows.paginated_extraction(
session_id, window_id,
config={
"outputSchema": {
"type": "object",
"properties": {
"listings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"title": {"type": "string"},
"price": {"type": "string"},
"location": {"type": "string"}
}
}
}
}
}
}
)Writing Effective Prompts
Good Prompts
- "Extract all product names and prices listed on this page"
- "What are the shipping options and their costs?"
- "List all navigation menu items with their URLs"
- "Is this product currently in stock? Answer yes or no."
Poor Prompts
- "Tell me about this page" (too vague)
- "Everything" (no focus)
- "Data" (meaningless)
Tips
- Be specific about what data you want
- Use JSON schema when you need structured output
- Ask one thing at a time for best accuracy
- Include format instructions if the default isn't right (e.g., "as a comma-separated list")
- Use
requiredin schema to ensure fields are always present
Cost Controls
Add cost limits to prevent runaway spending on complex queries.
typescript
const result = await client.windows.pageQuery(sessionId, windowId, {
prompt: 'Extract all pricing tiers',
configuration: {
costThresholdCredits: 10,
timeThresholdSeconds: 30,
},
});Best Practices
- Start with simple queries — add complexity as needed
- Use JSON schema for any data you'll process programmatically
- Test prompts on a few pages before scaling with batch operations
- Set cost/time thresholds for production workloads
- Combine methods — use
scrapeContentfor overview,pageQueryfor specifics