Docs
WebSearchAPI.ai Search API Reference

WebSearchAPI.ai Search API Reference

Complete reference for the WebSearchAPI.ai Search endpoint with examples, parameters, and response details

WebSearchAPI.ai offers a powerful search API built on Google's search infrastructure, enhanced with AI-powered content extraction capabilities. This reference provides comprehensive details about the API endpoints, parameters, response formats, and usage examples.

Introduction

The WebSearchAPI.ai Search API allows you to:

  • Execute Google-powered search queries programmatically
  • Retrieve high-quality search results with relevance scoring
  • Automatically extract and structure content from result pages
  • Generate AI-created summaries of search results
  • Customize search parameters for regional and language preferences

Endpoint Details

POST

/ai-search

Base URL: https://api.websearchapi.ai

Full Endpoint: https://api.websearchapi.ai/ai-search

Authentication

Authentication Required

All API requests require authentication using your API key in the Authorization header.

Include your API key in the Authorization header using the Bearer token format:

Authorization: Bearer YOUR_API_KEY

You can obtain an API key by signing up for a WebSearchAPI.ai account. Each account receives 1,000 free API credits monthly.

Request Format

All requests to the Search API should be made as HTTP POST requests with a JSON body containing the search parameters.

Required Headers

HeaderValue
Content-Typeapplication/json
AuthorizationBearer YOUR_API_KEY

Request Body

The request body should be a JSON object containing your search parameters:

{
  "query": "your search query",
  "maxResults": 5,
  "includeContent": true,
  "country": "us",
  "language": "en",
  "timeframe": "month",
  "includeAnswer": true,
  "safeSearch": true
}

Request Parameters

Example Requests

curl --request POST \
  --url https://api.websearchapi.ai/ai-search \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "latest advancements in AI",
  "maxResults": 5,
  "includeContent": true,
  "contentLength": "medium",
  "country": "us",
  "language": "en",
  "timeframe": "month",
  "includeAnswer": true,
  "safeSearch": true,
  "includeDomains": [],
  "excludeDomains": []
}'

Response Format

Success Response (200 OK)

A successful API call returns a JSON object with the following structure:

{
  "searchParameters": {
    "query": "latest advancements in AI",
    "maxResults": 5,
    "includeContent": true,
    "contentLength": "medium",
    "country": "us",
    "language": "en",
    "timeframe": "month",
    "includeAnswer": true,
    "safeSearch": true,
    "includeDomains": [],
    "excludeDomains": []
  },
  "answer": "Recent advancements in AI include significant improvements in large language models with systems like GPT-4 and Claude 3, breakthroughs in AI-generated content with text-to-image models like Midjourney v6 and DALL-E 3, and progress in multimodal AI systems that can process text, images, audio, and video simultaneously. These advancements are enhancing AI's capabilities across various domains, from creative content generation to scientific research and business applications.",
  "organic": [
    {
      "title": "Breakthrough AI Research: Recent Advancements and Future Directions",
      "url": "https://example.com/ai-research-advancements",
      "description": "An exploration of the latest breakthroughs in artificial intelligence research, including large language models, multimodal AI, and emerging architectures...",
      "content": "# Recent Advancements in AI Research\n\nThe field of artificial intelligence continues to evolve at a rapid pace, with several significant breakthroughs achieved in recent months.\n\n## Large Language Models\n\nLarge language models have seen remarkable improvements in their capabilities, with new benchmarks being set in reasoning, knowledge representation, and problem-solving abilities. Research teams have developed more efficient training methods that reduce computational requirements while maintaining or improving performance.\n\n## Multimodal AI Systems\n\nOne of the most promising directions in current AI research is the development of multimodal systems that can process and generate content across different types of media - text, images, audio, and video. These systems are showing unprecedented abilities to understand context across modalities.\n\n## Efficient AI Architectures\n\nResearchers have made significant progress in creating more efficient neural network architectures that require less computational resources while maintaining high performance. These advancements are particularly important for deploying AI systems on edge devices with limited processing capabilities.",
      "position": 1,
      "score": 0.94
    }
  ],
  "responseTime": 1.24
}

Response Fields

Error Responses

WebSearchAPI.ai returns standard HTTP status codes with JSON error details:

{
  "error": "Bad Request",
  "message": "Invalid request parameters",
  "details": {
    "query": "This field is required"
  }
}

Returned when the request contains invalid or missing parameters.

Rate Limits and Quotas

WebSearchAPI.ai uses a credit-based system for API usage. Each account receives 1,000 free API credits monthly. Usage is calculated as follows:

OperationCredits
Basic search without content1 credit
Search with content extraction2 credits
Search with answer generation+1 credit

Pro Tip: Optimize Credit Usage

Only enable includeContent and includeAnswer when you need these features. For exploratory searches or when you only need URLs and titles, keep these options disabled to conserve credits.

Advanced Features

Content Extraction

When includeContent is set to true, WebSearchAPI.ai not only performs a search but also:

  1. Retrieves each page in the search results
  2. Extracts the main content from the page, removing ads, navigation, footers, etc.
  3. Processes the content to create a clean, structured representation
  4. Returns the content in your preferred format (markdown, text, or HTML)

This content extraction capability eliminates the need for separate web scraping and content cleaning steps in your workflow.

How Content Extraction Works

Our advanced content extraction system:

  • Uses machine learning algorithms to identify the primary content on a page
  • Preserves important structural elements (headings, lists, tables, etc.)
  • Removes noise like ads, popups, navigation elements, and irrelevant sidebars
  • Intelligently processes images and captions when relevant to the main content
  • Converts the extracted content into a clean, consistent format (default: markdown)
  • Optimizes the content for consumption by AI models

This automated process ensures you receive high-quality, structured content that's immediately usable in your applications without additional cleaning or processing steps.

Content Format Options

You can specify how you want the extracted content formatted using the contentFormat parameter:

FormatDescription
markdownWell-structured markdown format ideal for LLMs and text processing (default)
textPlain text with basic formatting preserved but all markup removed
htmlClean HTML with essential elements preserved but extraneous tags removed

Advanced Search Options

The Search API supports various advanced search options:

  • Time-based filtering: Limit results to recent content using the timeframe parameter
  • Domain filtering: Include or exclude specific domains with includeDomains and excludeDomains
  • Site search: Restrict results to a specific website with siteSearch
  • Exact matching: Find pages containing exact phrases with exactTerms
  • Exclusions: Exclude pages containing specific terms with excludeTerms
  • File type filtering: Find specific document types with fileType

These options allow you to create highly targeted searches for specific use cases.

Use Cases

AI Agents & Assistants

Power AI agents with real-time, factual information from the web to provide accurate, up-to-date responses.

Research & Insights

Automatically gather and analyze content from multiple sources for market research, competitive analysis, or academic research.

Content Generation

Create content based on current information with citations and references automatically pulled from reliable sources.

News Monitoring

Track news and developments around specific topics with time-filtered searches and automatic content extraction.

Knowledge Management

Keep knowledge bases and documentation up-to-date with the latest information from trusted sources.

Fact Checking

Verify claims against multiple reliable sources using the power of Google search with automated content extraction.