Skip to main content

Overview

Try Our New Interactive Playground

Test search queries and parameters in real time, no API key required.
Perplexity’s Search API provides developers with real-time access to ranked web search results from a continuously refreshed index. Unlike traditional search APIs, Perplexity returns structured results with advanced filtering by domain, language, and region. Use the Search API when you need raw, ranked web results with control over sources, regions, and extracted content. For LLM-generated summaries, use our Agent API or Sonar API.
We recommend using our official SDKs for a more convenient and type-safe way to interact with the Search API.

Installation

Install the SDK for your preferred language:

Authentication

Set your API key as an environment variable. The SDK will automatically read it:
All SDK examples below automatically use the PERPLEXITY_API_KEY environment variable. You can also pass the key explicitly if needed.

Basic Usage

Start with a basic search query to get relevant web results. See the API Reference for complete parameter documentation.
The max_results parameter accepts values from 1 to 20, with a default maximum of 10 results per search. See pricing for details on search costs.
You can refine your search results by specifying a country to get more geographically relevant results:
Use ISO 3166-1 alpha-2 country codes (e.g., “US”, “GB”, “DE”, “JP”) to target specific regions. This is particularly useful for queries about local news, regulations, or region-specific information.
Execute multiple related queries in a single request for comprehensive research:
Multi-query search is ideal for research tasks where you need to explore different angles of a topic. Each query is processed independently, giving you comprehensive coverage.
For single queries, search.results is a flat list. For multi-query requests, results are grouped per query in the same order.
You can include up to 5 queries in a single multi-query request for efficient batch processing.

Domain Filtering for Search Results

The search_domain_filter parameter allows you to limit search results to specific domains (allowlist) or exclude certain domains (denylist) for focused research. The filter works in two modes:
  • Allowlist mode: Include only specified domains (no - prefix)
  • Denylist mode: Exclude specified domains (use - prefix)
Note: You can use either allowlist or denylist mode, but not both simultaneously in the same request.
You can add a maximum of 20 domains to the search_domain_filter list. The filter works in either allowlist mode (include only) or denylist mode (exclude), but not both simultaneously. See the domain filter guide for advanced usage patterns.

Denylisting Example

You can also exclude specific domains from search results:
The search_language_filter parameter allows you to filter search results by language using ISO 639-1 language codes:
Language codes must be valid 2-letter ISO 639-1 codes (e.g., “en”, “ru”, “fr”). You can add a maximum of 10 language codes per request. See the language filter guide for the complete list of supported codes.

Content Extraction Control

The max_tokens_per_page parameter controls how much content is extracted from each webpage during search processing. This allows you to balance between comprehensive content coverage and processing efficiency.
The max_tokens_per_page parameter defaults to 4096 tokens. Higher values provide more comprehensive content extraction but may increase processing time. Lower values enable faster processing with more focused content.
Use lower max_tokens_per_page values (256-512) for quick information retrieval or when processing large result sets.

Total Content Budget Control

The max_tokens parameter sets the maximum total tokens of webpage content returned across all search results. This controls how much content appears in the snippet fields. Use it together with max_tokens_per_page to control content distribution across results. The max_tokens parameter defaults to 10,000 tokens. The maximum allowed value is 1,000,000 tokens.
Search API charges per request only, with no additional token-based pricing.
When to adjust each parameter:
  • max_tokens controls the total content returned across all results—increase for longer snippets
  • max_tokens_per_page controls content per individual result—increase to get more from each page
  • Both parameters work together: max_tokens is the total budget, max_tokens_per_page is the per-result cap

Next Steps

Best Practices

Optimize your queries and implement async patterns

Explore More

API Reference

Complete API documentation for the Perplexity Search API

Perplexity SDK

Type-safe SDK for Python and Typescript

Date & Time Filters

Filter search results by recency and date ranges

Domain Filtering Guide

Advanced domain allowlist and denylist patterns

Agent API

Third-party models from OpenAI, Anthropic, Google, and more with presets and web search tools.

Sonar API

Get AI-generated summaries with built-in search capabilities.