This guide shows you how to extract different types of data from your UI using AskUI’s get() method. Data extraction is a fundamental capability for building AI agents that can read and understand UI content.

Quick Start

The get() method allows you to ask questions about your UI and receive structured responses:

from askui import VisionAgent

with VisionAgent() as agent:
    # Basic text extraction
    text = agent.get("What is the main heading?", response_schema=str)
    
    # Boolean questions
    is_loaded = agent.get("Is the page fully loaded?", response_schema=bool)
    
    # Numeric values
    count = agent.get("How many items are in the cart?", response_schema=int)

Data Extraction Types

Common Patterns

Form Validation

with VisionAgent() as agent:
    # Check form state before submission
    has_errors = agent.get(
        "Are there any validation errors?", 
        response_schema=bool
    )
    
    if not has_errors:
        agent.click("Submit")
    else:
        error_messages = agent.get(
            "What are the error messages?",
            response_schema=List[str]
        )
        print(f"Fix these errors: {error_messages}")

Dashboard Metrics

from askui import ResponseSchemaBase

class Metrics(ResponseSchemaBase):
    total_users: int
    active_sessions: int
    revenue: float
    growth_percentage: float

with VisionAgent() as agent:
    dashboard = agent.get(
        "Extract the dashboard metrics",
        response_schema=Metrics
    )

Search Results

class SearchResult(ResponseSchemaBase):
    title: str
    url: str
    description: str

with VisionAgent() as agent:
    results = agent.get(
        "Get all search results",
        response_schema=List[SearchResult]
    )

Best Practices

  1. Be Specific: More specific questions yield better results

    # Good
    price = agent.get("What is the total price in the checkout?", response_schema=float)
    
    # Less specific
    price = agent.get("What's the price?", response_schema=float)
    
  2. Use Appropriate Types: Match response schema to expected data

    # For counts, use int
    count = agent.get("How many notifications?", response_schema=int)
    
    # For prices, use float
    price = agent.get("What's the price?", response_schema=float)
    
  3. Handle Missing Data: Use Optional fields when data might not exist

    from typing import Optional
    
    class UserProfile(ResponseSchemaBase):
        name: str
        email: str
        phone: Optional[str] = None
    

Troubleshooting

Data Extraction Issues?

Getting empty results or type errors? Our data extraction troubleshooting guide covers common problems and solutions for the get() method.

Performance Optimization

Learn how to optimize data extraction performance with batch extraction and caching strategies.

Next Steps