Overview
Try Our New Interactive Playground
Test search queries and parameters in real time, no API key required.
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:- macOS/Linux
- Windows
.env file in your project:
.env
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.Response
Response
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.Regional Web Search
You can refine your search results by specifying a country to get more geographically relevant results:Multi-Query Web Search
Execute multiple related queries in a single request for comprehensive research: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
Thesearch_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)
Denylisting Example
You can also exclude specific domains from search results:Language Filtering for Web Search
Thesearch_language_filter parameter allows you to filter search results by language using ISO 639-1 language codes:
Content Extraction Control
Themax_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 1024 tokens. Higher values provide more comprehensive content extraction but may increase processing time. Lower values enable faster processing with more focused content.Next Steps
Best Practices
Optimize your queries and implement async patterns