← All posts

Brave Search API Key: Setup, Authentication, and a Working Example

Quick answer: You get a Brave Search API key by signing up at the Brave Search API dashboard (api-dashboard.search.brave.com), subscribing to a plan (there's a free tier), and generating a key under "API Keys." You authenticate by sending that key in the X-Subscription-Token header (not as a Bearer token) against https://api.search.brave.com/res/v1/web/search.

That header name trips up more people than anything else about this API, so let's get a working request in front of you first, then cover the setup details and the gotchas.

The Working Example

curl "https://api.search.brave.com/res/v1/web/search?q=web+scraping+tools" \
  -H "Accept: application/json" \
  -H "X-Subscription-Token: YOUR_API_KEY"

And in Python:

import requests

resp = requests.get(
    "https://api.search.brave.com/res/v1/web/search",
    headers={
        "Accept": "application/json",
        "X-Subscription-Token": "YOUR_API_KEY",
    },
    params={"q": "web scraping tools", "count": 10},
)

for result in resp.json()["web"]["results"]:
    print(result["title"], "-", result["url"])

If you get a 401, it's almost always one of three things: you used Authorization: Bearer instead of X-Subscription-Token, you haven't attached a subscription (even the free plan requires subscribing in the dashboard first), or you generated the key for a different plan than the endpoint you're calling.

Getting the Key, Step by Step

  1. Create an account at the Brave Search API dashboard. This is separate from a regular Brave browser account.
  2. Choose a plan. As of this writing, the Free plan gives you 2,000 queries per month at 1 request/second, and requires a payment card on file even though it's free. Paid tiers raise both the monthly quota and the rate limit.
  3. Subscribe, then go to API Keys and generate a key. Keys are tied to the plan you subscribed to.
  4. Store it like a secret: environment variable or secret manager, never committed to git:
export BRAVE_API_KEY="BSA..."

What You Actually Get Back

Brave's response is JSON with typed result groups: web, news, videos, and sometimes faq or discussions. The useful core is web.results, where each entry has title, url, and description.

Worth knowing: Brave runs its own independent index rather than reselling Google or Bing results. That independence is the main reason to choose it, and also why results for niche queries can feel thinner than Google's. Test with your real query mix before committing.

Useful query parameters:

Param What it does
q The query (required)
count Results per page, up to 20
offset Pagination
country, search_lang Localization
freshness Restrict by recency (e.g. pd = past day)

The Gotchas Nobody Mentions

The rate limit is per second, and it's real. On the free tier, two concurrent requests will get one of them a 429 response. Serialize your calls or add backoff.

Quota math sneaks up on you. 2,000 free queries a month sounds like a lot until you wire it into an AI agent that issues four or five searches per user question. That's ~400 questions a month. Budget accordingly.

No SERP extras. You get Brave's index, not Google's SERP. If what you actually need is Google results (People Also Ask boxes, shopping results, ads data for SEO work), a Brave key can't get you there.

If You Need Google Results Instead

This is a common realization after wiring up Brave: the index is independent, but your use case (rank tracking, PAA mining, shopping data) is Google-shaped. For that, a SERP API is the right tool. link.sc's Search API returns live Google results as structured JSON (organic results, People Also Ask, ads, shopping) with the same one-call simplicity:

curl -X POST https://api.link.sc/v1/search \
  -H "x-api-key: YOUR_LINKSC_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "web scraping tools"}'

The two aren't mutually exclusive. A reasonable stack uses Brave for general-purpose, privacy-friendly search in an app, and a SERP API where you specifically need Google's view of the web.

The Bottom Line

Brave's Search API is one of the easiest search APIs to start with: sign up, subscribe, generate a key, and send it in X-Subscription-Token. Respect the 1 rps limit, keep an eye on your monthly quota, and be clear-eyed about the independent index: it's a feature for privacy and a limitation for coverage, depending on what you're building.


Need structured Google search results for your app or agent? Get a free link.sc API key: 500 requests a month included.