Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
Search News Monitor
A command-line tool that uses Perplexity’s Search API (client.search.create(...)) to monitor real-time news across multiple topics. Configure topics, domain filters, and recency windows to build a continuous news monitoring pipeline.
Features
- Monitor multiple topics in a single run using the Search API
- Filter results by domain with
search_domain_filter(allowlist or denylist) - Control recency with
search_recency_filter(day, week, month, year) - Access structured result fields:
title,url,snippet,date - Configurable polling interval for continuous monitoring
- Output as formatted text or JSON for downstream processing
Installation
API Key Setup
Set your Perplexity API key as an environment variable. The SDK reads it automatically:Usage
How It Works
- The CLI accepts a list of topics and optional filtering parameters.
- For each topic, it calls
client.search.create(query=..., max_results=...)with the configured domain and recency filters. - Each search result contains
title,url,snippet, anddatefields, which are extracted and formatted. - In watch mode, the tool repeats the search at a configurable interval, displaying only new results since the last poll.
Full Code
Example Output
The Search API returns structured results with
title, url, snippet, and date fields. Unlike the Agent API or Sonar API, it does not generate AI summaries — it returns raw ranked web results. See the Search API quickstart for full details.Continuous Monitoring Tips
- Set appropriate intervals. For breaking news, use 60-120 second intervals. For general topic monitoring, 300-600 seconds is sufficient.
- Combine recency with domain filters. Use
--recency daywith trusted news domains for a curated news feed. - Pipe JSON output to other tools. Use
--jsonwith tools likejqor downstream scripts for alerting and aggregation. - Track seen URLs. The watch mode automatically deduplicates results across polling cycles using URL tracking.
Limitations
- The Search API charges per request. Frequent polling across many topics will increase costs.
- The
search_recency_filteris relative to the current time and cannot specify exact date ranges. For precise date filtering, usesearch_after_date_filterandsearch_before_date_filterinstead. - Search result availability depends on web indexing. Very recent content (within minutes) may not appear immediately.
- The
snippetfield length varies by result and may be truncated for long pages.