Skip to main content

Overview

Search enables you to search the web and extract structured results using AI. It combines web search capabilities with intelligent data extraction, returning clean, structured data from search results.
Try Search instantly in our interactive playground

Getting Started

Quick Start

from scrapegraph_py import Client

client = Client(api_key="your-api-key")

response = client.search(
    query="What are the key features of ChatGPT Plus?"
)

Parameters

ParameterTypeRequiredDescription
querystringYesThe search query to execute.
num_resultsintNoNumber of search results to return (1-20). Default: 5.
promptstringNoPrompt used when extracting structured results.
output_schemaobjectNoPydantic or Zod schema for structured response format (requires prompt).
formatstringNoOutput format: "markdown" (default) or "html".
modestringNoHTML processing mode: "normal", "reader", "prune" (default).
countrystringNoTwo-letter ISO country code for localized results (e.g. "us", "it", "gb").
time_rangestringNoRecency filter: "past_hour", "past_24_hours", "past_week", "past_month", "past_year".
fetch_configFetchConfigNoConfiguration for page fetching (mode, stealth, headers, etc.).
Get your API key from the dashboard

Custom Schema Example

Define the structure of the output using Pydantic or Zod:
from pydantic import BaseModel, Field
from scrapegraph_py import Client

class SearchResult(BaseModel):
    title: str = Field(description="The result title")
    summary: str = Field(description="Brief summary of the result")
    url: str = Field(description="Source URL")

client = Client(api_key="your-api-key")

response = client.search(
    query="Latest AI developments 2024",
    num_results=10,
    output_schema=SearchResult,
)

Async Support

import asyncio
from scrapegraph_py import AsyncClient

async def main():
    async with AsyncClient(api_key="your-api-key") as client:
        response = await client.search(
            query="Best practices for web scraping"
        )
        print(response)

asyncio.run(main())

Key Features

AI-Powered Search

Intelligent extraction from search results

Structured Output

Returns clean, structured data in your preferred format

Schema Support

Define custom output schemas using Pydantic or Zod

Flexible Results

Control the number of search results returned

Integration Options

Official SDKs

  • Python SDK - Perfect for data science and backend applications
  • JavaScript SDK - Ideal for web applications and Node.js

AI Framework Integrations

Support & Resources

Documentation

Comprehensive guides and tutorials

API Reference

Detailed API documentation

Community

Join our Discord community

GitHub

Check out our open-source projects