Get started with Brave Search API
Brave Search API is a REST API to query Brave Search and get back search results from the web. The following sections describe how to curate requests, including parameters and headers, to Brave Search API and get a JSON response back.
Endpoints
Brave Search API exposes multiple endpoints for specific types of data, based on the level of your subscription. If you don’t see the endpoint you’re interested in, you may need to change your subscription.
Brave Web Search API
Brave Web Search API is currently available at the following endpoint and exposes an API to query general web.
Endpoint
https://api.search.brave.com/res/v1/web/search
Get started immediately with CURL. An example request will look something like this:
Curl
curl -s --compressed "$https://api.search.brave.com/res/v1/web/search?q=brave+search" \
-H "Accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "X-Subscription-Token: <YOUR_API_KEY>"
The response specification for Web Search API can be seen in the WebSearchApiResponse model.
Brave Summarizer Search API
Brave Summarizer Search API is currently available at the following endpoint and exposes an API to get summarized content for web search queries.
Endpoint
https://api.search.brave.com/res/v1/summarizer/search
To utilize the Summarizer, follow the steps outlined below.
An initial request has to be made to web search endpoint with a given query. An example request is given below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/web/search?q=what+is+the+second+highest+mountain&summary=1" \
-H "Accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "X-Subscription-Token: <YOUR_API_KEY>"
If the query is eligible for a summary or an answer, as in this case, a summarizer key is provided in the response.
2023-08-25
is deprecated. Please use the
version 2024-04-23
onwards.For API version 2024-04-23
onwards, the
key
is equal to summarizer key (key) as part of the (Summarizer) response model. An example is below.
Response
{
"summarizer": {
"type": "summarizer",
"key": "{\"query\":\"what is the second highestmountain\",\"country\":\"us\",\"language\":\"en\",\"safesearch\":\"moderate\",\"results_hash\":\"a51e129180225a2f4fe1a00984bcbf58f0ae0625c97723aae43c2c6e3440715b\"}"
}
}
The key can be used to poll the summarizer endpoint for the summarized content. Requests to summarizer are not counted towards your plan and only the initial request to web search endpoint is billed based on the selected plan. An example request is below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/summarizer/search?key=%7B%22query%22%3A%22what%20is%20the%20second%20highest%20mountain%22%2C%22country%22%3A%22us%22%2C%22language%22%3A%22en%22%2C%22safesearch%22%3A%22moderate%22%2C%22results_hash%22%3A%22a51e129180225a2f4fe1a00984bcbf58f0ae0625c97723aae43c2c6e3440715b%22%7D&entity_info=1" \
-H "accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "x-subscription-token: <YOUR_API_KEY>"
For API version 2023-08-25
, the key is equal to summarizer key (summary_key) which is provided in the response to a web search query when it is eligible for a summary
or an answer. The key is part of the query (Query) response model. API version 2023-08-25
is now deprecated. An example is
below.
Response
{"query": {"summary_key": "what is the second highest mountain:us:en"}}
This key can be used to poll the summarizer endpoint for the summarized content. Polling requests to summarizer endpoint are not counted towards your plan and only the initial request to web search endpoint is billed based on the selected plan. An example poll request is below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/summarizer/search?key=what%20is%20the%20second%20highest%20mountain:us:en" \
-H "Accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "X-Subscription-Token: <YOUR_API_KEY>"
The response specification for Summarizer Search API can be seen in the SummarizerSearchApiResponse model.
Brave Local Search API
Brave Local Search API is currently available at the following endpoints and exposes an API to get extra information about a location, including pictures and related web results.
Endpoint
https://api.search.brave.com/res/v1/local/pois
The local API also includes an endpoint to get an AI generated description for a location.
Endpoint
https://api.search.brave.com/res/v1/local/descriptions
To utilize the Local API, follow the steps outlined below.
An initial request has to be made to web search endpoint with a given query. An example request is given below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/web/search?q=greek+restaurants+in+san+francisco" \
-H "Accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "X-Subscription-Token: <YOUR_API_KEY>"
If the query returns a list of locations, as in this case, each location result has an id field, which is a temporary ID that can be used to retrieve extra information about the location. An example from the locations result is given below.
Response
{ "locations": { "results": [ { "id": "1520066f3f39496780c5931d9f7b26a6",
"title": "Pangea Banquet Mediterranean Food" }, { "id":
"d00b153c719a427ea515f9eacf4853a2", "title": "Park Mediterranean Grill" }, { "id":
"4b943b378725432aa29f019def0f0154", "title": "The Halal Mediterranean Co." } ] }
}
The id
value can be used to further fetch extra information about the location.
An example request is given below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/local/pois?ids=1520066f3f39496780c5931d9f7b26a6&ids=d00b153c719a427ea515f9eacf4853a2" \
-H "accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "x-subscription-token: <YOUR_API_KEY>"
An AI generated description associated with a location can be further fetched using the example below.
Curl
curl -s --compressed "https://api.search.brave.com/res/v1/local/descriptions?ids=1520066f3f39496780c5931d9f7b26a6&ids=d00b153c719a427ea515f9eacf4853a2" \
-H "accept: application/json" \
-H "Accept-Encoding: gzip" \
-H "x-subscription-token: <YOUR_API_KEY>"
The response specification for Local Search API can be seen in the LocalPoiSearchApiResponse and LocalDescriptionsSearchApiResponse models.
Next steps
To learn what parameters are available and what responses can be expected while querying Brave Search, please review the following pages: