News Search

作者 brave62793e0c49ed無授權條款183 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 週前更新

USE FOR news search. Returns news articles with title, URL, description, age, thumbnail, profile. Supports freshness and date range filtering, SafeSearch filter and Goggles for custom ranking.

AI 產生的概覽

呼叫 Brave 新聞搜尋 API 取得新聞文章,支援時效、日期範圍、安全搜尋與 Goggles 排序選項。

功能
說明如何以 GET 或 POST 呼叫 Brave 新聞搜尋 API 端點,涵蓋身分驗證、查詢參數、時效與日期範圍篩選、安全搜尋、搜尋運算子以及 Goggles 自訂排序。內容描述 JSON 回應結構,包括標題、URL、描述、時間、縮圖與來源資料欄位。產出的是參考說明與範例請求,而非指令碼或檔案。
適用情境
當代理需要檢索某主題的新聞文章、監控突發新聞,或依日期範圍查找歷史新聞時使用。也適合透過 Brave API 建立自訂排序的新聞摘要或多語言新聞查詢。
執行需求
需要 Brave Search API 金鑰(透過 X-Subscription-Token 標頭傳送)、Search 方案訂閱,以及對 api.search.brave.com 的網路存取。未附指令碼,範例使用 cURL。

News Search

Requires API Key: Get one at https://api.search.brave.com

Plan: Included in the Search plan. See https://api-dashboard.search.brave.com/app/subscriptions/subscribe

Quick Start (cURL)

Basic Search

bash
curl -s "https://api.search.brave.com/res/v1/news/search?q=space+exploration" \  -H "Accept: application/json" \  -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}"

Recent News (Past 24 Hours)

bash
curl -s "https://api.search.brave.com/res/v1/news/search" \  -H "Accept: application/json" \  -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" \  -G \  --data-urlencode "q=cybersecurity" \  --data-urlencode "country=US" \  --data-urlencode "freshness=pd" \  --data-urlencode "count=20"

Date Range Filter

bash
curl -s "https://api.search.brave.com/res/v1/news/search" \  -H "Accept: application/json" \  -H "X-Subscription-Token: ${BRAVE_SEARCH_API_KEY}" \  -G \  --data-urlencode "q=climate summit" \  --data-urlencode "freshness=2026-01-01to2026-01-31"

Endpoint

http
GET https://api.search.brave.com/res/v1/news/searchPOST https://api.search.brave.com/res/v1/news/search

Authentication: X-Subscription-Token: <API_KEY> header

Note: Both GET and POST are supported. POST is useful for long queries or complex Goggles.

Parameters

ParameterTypeRequiredDefaultDescription
qstringYes-Search query (1-400 chars, max 50 words)
countrystringNoUSSearch country (2-letter country code or ALL)
search_langstringNoenLanguage preference (2+ char language code)
ui_langstringNoen-USUI language (e.g., "en-US")
countintNo20Number of results (1-50)
offsetintNo0Page offset (0-9)
safesearchstringNostrictAdult content filter (off/moderate/strict)
freshnessstringNo-Time filter (pd/pw/pm/py or date range)
spellcheckboolNotrueAuto-correct query
extra_snippetsboolNo-Up to 5 additional excerpts per result
gogglesstring or arrayNo-Custom ranking filter (URL or inline; repeat param for multiple)
operatorsboolNotrueApply search operators
include_fetch_metadataboolNofalseInclude fetch timestamps in results

Freshness Values

ValueDescription
pdPast day (24 hours) - ideal for breaking news
pwPast week (7 days)
pmPast month (31 days)
pyPast year (365 days)
YYYY-MM-DDtoYYYY-MM-DDCustom date range

Response Format

json
{  "type": "news",  "query": {    "original": "space exploration"  },  "results": [    {      "type": "news_result",      "title": "New Developments in Space Exploration",      "url": "https://news.example.com/space-exploration",      "description": "Recent missions have advanced our understanding of...",      "age": "2 hours ago",      "page_age": "2026-01-15T14:30:00",      "page_fetched": "2026-01-15T15:00:00Z",      "meta_url": {        "scheme": "https",        "netloc": "news.example.com",        "hostname": "news.example.com",        "favicon": "https://imgs.search.brave.com/favicon/news.example.com",        "path": "/space-exploration"      },      "profile": {        "name": "Example Outlet",        "url": "https://news.example.com/space-exploration"      },      "thumbnail": {        "src": "https://imgs.search.brave.com/..."      }    }  ]}

Response Fields

FieldTypeDescription
typestringAlways "news"
query.originalstringThe original search query
query.alteredstring?Spellcheck-corrected query (if changed)
query.cleanedstring?Cleaned/normalized query from spellchecker
query.spellcheck_offbool?Whether spellcheck was disabled
query.show_strict_warningbool?True if strict safesearch blocked results
query.search_operatorsobject?Applied search operators
query.search_operators.appliedboolWhether operators were applied
query.search_operators.cleaned_querystring?Query after operator processing
query.search_operators.siteslist[str]?Domains from site: operators
results[].typestringAlways "news_result"
results[].titlestringArticle title
results[].urlstringSource URL of the article
results[].descriptionstring?Article description/summary
results[].agestring?Human-readable age (e.g. "2 hours ago")
results[].page_agestring?Publication date from source (ISO datetime)
results[].page_fetchedstring?When page was last fetched (ISO datetime)
results[].fetched_content_timestampint?Fetch timestamp (only with include_fetch_metadata=true)
results[].meta_url.schemestring?URL protocol scheme
results[].meta_url.netlocstring?Network location
results[].meta_url.hostnamestring?Lowercased domain name
results[].meta_url.faviconstring?Favicon URL
results[].meta_url.pathstring?URL path
results[].thumbnail.srcstringServed thumbnail URL
results[].thumbnail.originalstring?Original thumbnail URL
results[].extra_snippetslist[str]?Up to 5 additional excerpts per result
results[].profile.namestring?Name of the site
results[].profile.urlstring?The original URL where the profile is available
results[].profile.long_namestring?The long name of the site
results[].profile.imgstring?The served image URL representing the profile

Goggles (Custom Ranking) — Unique to Brave

Goggles let you re-rank news results — boost trusted outlets or suppress unwanted sources.

MethodExample
Hosted--data-urlencode "goggles=https://raw.githubusercontent.com/brave/goggles-quickstart/main/goggles/hacker_news.goggle"
Inline--data-urlencode 'goggles=$discard\n$site=example.com'

Hosted goggles must be on GitHub/GitLab, include ! name:, ! description:, ! author: headers, and be registered at https://search.brave.com/goggles/create. Inline rules need no registration.

Syntax: Rules start with $ + comma-separated options. Actions (pick one): discard, boost[=N], downrank[=N] — N is an integer 1–10. Site filter: site=DOMAIN. Example: $site=example.com,boost=3. Separate rules with \n (%0A).

Allow list: $discard\n$site=docs.python.org\n$site=developer.mozilla.org — Block list: $discard,site=pinterest.com\n$discard,site=quora.com

Resources: Discover · Syntax · Quickstart

Search Operators

Use search operators to refine results:

  • site:local-paper.com - Limit to specific news site
  • "exact phrase" - Match exact phrase
  • -exclude - Exclude term

Set operators=false to disable operator parsing.

Use Cases

  • Breaking news monitoring: Use freshness=pd for the most recent articles on a topic.
  • Custom news feeds with Goggles: Boost trusted sources and discard other sources — unique to Brave.
  • Historical news research: Use freshness=YYYY-MM-DDtoYYYY-MM-DD to find articles from specific time periods.
  • Multilingual news: Combine country, search_lang, and ui_lang for cross-locale results.
  • Data pipelines: Set include_fetch_metadata=true for fetched_content_timestamp on each result.

Notes

  • SafeSearch: Defaults to strict
  • Pagination: Use offset (0-9) with count
  • Extra snippets: Up to 5 additional excerpts when extra_snippets=true

來源與署名

來源:brave/brave-search-skills位於skills/news-search提交62793e0

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架