Brave Search Python Client supporting Web, Image, News and Video search.
Use Cases:
Integrate into your Python code to help users find what they’re looking for.
Add to your AI applications to give LLMs access to current web information.
Use the built-in CLI in shell scripts to get search results in JSON format.
Overview¶
Adding Brave Search Python Client to your project as a dependency is easy.
uv add brave-search-python-client # add dependency to your project
If you don’t have uv installed follow these instructions. If you still prefer pip over the modern and fast package manager uv, you can install the library like this:
pip install brave-search-python-client # add dependency to your project
Obtain your Brave Search API key by signing up here - the free tier includes 2,000 requests per month. For guidance on how to integrate the Brave Search Python client into your code base check out the examples below and explore the reference documentation. If you just want to try out the client without having to write code you can use the integrated CLI:
export BRAVE_SEARCH_API_KEY=YOUR_API_KEY # replace YOUR_API_KEY
uvx brave-search-python-client web "hello world" # search for hello world
All advanced search options of Brave Search are supported by the client and in the CLI:
# Find all German content about AI added in the last 24 hours
uvx brave-search-python-client web --country=DE --search-lang=de --units=metric --freshness=pd ai
The CLI provides extensive help:
uvx brave-search-python-client --help # all CLI commands
uvx brave-search-python-client web --help # all options for web search
uvx brave-search-python-client images --help # all options image search
uvx brave-search-python-client videos --help # all options video search
uvx brave-search-python-client news --help # all options news search
Operational Excellence¶
This project is designed with operational excellence in mind, using modern Python tooling and practices. It includes:
Various examples demonstrating usage: a. Simple Python script b. Streamlit web application deployed on Streamlit Community Cloud c. Jupyter and Marimo notebook
Complete reference documentation on Read the Docs
Transparent test coverage including unit and E2E tests (reported on Codecov)
Matrix tested with multiple python versions to ensure compatibility (powered by Nox)
Compliant with modern linting and formatting standards (powered by Ruff)
Up-to-date dependencies (monitored by Renovate and Dependabot)
A-grade code quality in security, maintainability, and reliability with low technical debt and codesmell (verified by SonarQube)
Additional code security checks using CodeQL
License compliant with the Open Source Initiative (OSI)
1-liner for installation and execution of command line interface (CLI) via uv(x) or Docker
Setup for developing inside a devcontainer included (supports VSCode and GitHub Codespaces)
Usage Examples¶
Streamlit App¶
Minimal Python Script:¶
"""
Example script demonstrating the usage of the Brave Search Python Client.
For web, image, video and news search.
"""
import asyncio
import os
from dotenv import load_dotenv
from rich.console import Console
from brave_search_python_client import (
BraveSearch,
CountryCode,
ImagesSearchRequest,
LanguageCode,
NewsSearchRequest,
VideosSearchRequest,
WebSearchRequest,
)
# Load .env file and get Brave Search API key from environment
load_dotenv()
api_key = os.getenv("BRAVE_SEARCH_API_KEY")
if not api_key:
msg = "BRAVE_SEARCH_API_KEY not found in environment"
raise ValueError(msg)
async def search() -> None:
"""Run various searches using the Brave Search Python Client (see https://brave-search-python-client.readthedocs.io/en/latest/lib_reference.html)."""
# Initialize the Brave Search Python client, using the API key from the environment
bs = BraveSearch()
# Perform a web search
response = await bs.web(WebSearchRequest(q="jupyter"))
# Print results as JSON
# Iterate over web hits and render links in markdown
for _result in response.web.results if response.web else []:
pass
# Advanced search with parameters
response = await bs.web(
WebSearchRequest(
q="python programming",
country=CountryCode.DE,
search_lang=LanguageCode.DE,
),
)
for _result in response.web.results if response.web else []:
pass
# Search and render images
response = await bs.images(ImagesSearchRequest(q="cute cats"))
for _image in response.results or []:
pass
# Search and render videos
response = await bs.videos(VideosSearchRequest(q="singularity is close"))
for _video in response.results or []:
pass
# Search and render news
response = await bs.news(NewsSearchRequest(q="AI"))
for _item in response.results or []:
pass
# Run the async search function
# Alternatively use await search() from an async function
asyncio.run(search())
Read the library reference documentation for an explanation of available classes and methods.
Jupyter Notebook¶
Command Line Interface (CLI)¶
Run with uvx¶
Add Brave Search API key to the environment
export BRAVE_SEARCH_API_KEY=YOUR_API_KEY
Show available commands:
uvx brave-search-python-client --help
Search the web for “hello world”:
uvx brave-search-python-client web "hello world"
Show options for web search
uvx brave-search-python-client web --help
Search images:
uvx brave-search-python-client images "hello world"
Show options for image search
uvx brave-search-python-client images --help
Search videos:
uvx brave-search-python-client videos "hello world"
Show options for videos search
uvx brave-search-python-client videos --help
Search news:
uvx brave-search-python-client news "hello world"
Show options for news search
uvx brave-search-python-client news --help
Read the CLI reference documentation for an explanation of all commands and options.
Run with Docker¶
Note: Replace YOUR_BRAVE_SEARCH_API_KEY with your API key in the following examples.
Show available commands:
docker run helmuthva/brave-search-python-client --help
Search the web:
docker run --env BRAVE_SEARCH_API_KEY=YOUR_BRAVE_SEARCH_API_KEY helmuthva/brave-search-python-client web "hello world"
Show options for web search
docker run helmuthva/brave-search-python-client web --help
Search images:
docker run --env BRAVE_SEARCH_API_KEY=YOUR_BRAVE_SEARCH_API_KEY helmuthva/brave-search-python-client images "hello world"
Show options for image search
docker run helmuthva/brave-search-python-client images --help
Search videos:
docker run --env BRAVE_SEARCH_API_KEY=YOUR_BRAVE_SEARCH_API_KEY helmuthva/brave-search-python-client videos "hello world"
Show options for video search
docker run helmuthva/brave-search-python-client videos --help
Search news:
docker run --env BRAVE_SEARCH_API_KEY=YOUR_BRAVE_SEARCH_API_KEY helmuthva/brave-search-python-client news "hello world"
Show options for news search
docker run helmuthva/brave-search-python-client news --help
Or use docker compose
File .env is passed through
docker compose up
docker compose run brave-search-python-client --help
- Overview
- Operational Excellence
- Usage Examples
- Jupyter Notebook
- Command Line Interface (CLI)
- CLI Reference
- Library Reference
BraveSearchBraveSearchAPIErrorBraveSearchClientErrorBraveSearchErrorCountryCodeFreshnessTypeImageSearchApiResponseImagesSafeSearchTypeImagesSearchRequestLanguageCodeMarketCodeNewsSafeSearchTypeNewsSearchApiResponseNewsSearchRequestSearchTypeUnitsTypeVideoSearchApiResponseVideosSearchRequestWebSafeSearchTypeWebSearchApiResponseWebSearchRequest
- Contributing
- Code Style
- Release Notes
- 0.4.25 - 2025-04-27
- 0.4.24 - 2025-04-25
- 0.4.23 - 2025-04-24
- 0.4.22 - 2025-04-24
- 0.4.21 - 2025-04-08
- 0.4.20 - 2025-04-08
- 0.4.17 - 2025-04-07
- 0.4.15 - 2025-04-07
- 0.4.13 - 2025-04-07
- 0.4.11 - 2025-04-04
- 0.4.10 - 2025-04-04
- 0.4.7 - 2025-03-25
- 0.4.5 - 2025-03-25
- 0.4.0 - 2025-03-16
- 0.3.19 - 2025-03-14
- 0.3.9 - 2025-03-13
- 0.3.12 - 2025-03-08
- 0.3.11 - 2025-03-08
- 0.3.7 - 2025-03-08
- 0.3.6 - 2025-03-08
- 0.3.5 - 2025-03-08
- 0.3.3 - 2025-03-08
- 0.3.2 - 2025-03-07
- 0.3.1 - 2025-03-07
- 0.3.0 - 2025-03-07
- 0.2.25 - 2025-03-02
- 0.2.24 - 2025-02-25
- 0.2.22 - 2025-01-05
- 0.2.21 - 2025-01-05
- 0.2.20 - 2025-01-05
- 0.2.19 - 2025-01-04
- 0.2.18 - 2025-01-04
- 0.2.17 - 2025-01-04
- 0.2.16 - 2025-01-04
- 0.2.15 - 2025-01-03
- 0.2.14 - 2025-01-03
- 0.2.13 - 2025-01-02
- 0.2.12 - 2025-01-02
- 0.2.11 - 2025-01-02
- 0.2.10 - 2025-01-02
- 0.2.9 - 2025-01-02
- 0.2.8 - 2025-01-02
- 0.2.7 - 2025-01-02
- 0.2.6 - 2025-01-02
- 0.2.5 - 2025-01-02
- 0.2.4 - 2025-01-02
- 0.2.3 - 2025-01-02
- 0.2.1 - 2025-01-02
- 0.2.0 - 2025-01-02
- 0.1.12 - 2025-01-02
- 0.1.11 - 2025-01-02
- 0.1.10 - 2025-01-02
- 0.1.9 - 2025-01-02
- 0.1.8 - 2025-01-02
- 0.1.7 - 2025-01-01
- 0.1.6 - 2025-01-01
- 0.1.5 - 2025-01-01
- 0.1.4 - 2025-01-01
- 0.1.3 - 2025-01-01
- 0.1.2 - 2025-01-01
- 0.1.1 - 2025-01-01
- 0.0.12 - 2025-01-01
- 0.0.11 - 2025-01-01
- 0.0.10 - 2025-01-01
- 0.0.9 - 2025-01-01
- 0.0.8 - 2025-01-01
- 0.0.7 - 2025-01-01
- 0.0.6 - 2025-01-01
- 0.0.5 - 2025-01-01
- 0.0.4 - 2025-01-01
- 0.0.3 - 2024-12-31
- 0.0.2 - 2024-12-31
- [0.0.1] - 2024-12-31
- New Contributors ❤️
- Security Policy
- License
- Attributions
- CacheControl (0.14.1) - Apache Software License
- DataProperty (1.1.0) - MIT License
- GitPython (3.1.43) - BSD License
- Jinja2 (3.1.6) - BSD License
- Markdown (3.7) - BSD License
- MarkupSafe (3.0.2) - BSD License
- PySocks (1.7.1) - BSD
- PyYAML (6.0.2) - MIT License
- Pygments (2.18.0) - BSD License
- Send2Trash (1.8.3) - BSD License
- Sphinx (8.2.3) - UNKNOWN
- alabaster (1.0.0) - BSD License
- altair (5.5.0) - BSD License
- annotated-types (0.7.0) - MIT License
- anyio (4.7.0) - MIT License
- apeye (1.4.1) - GNU Lesser General Public License v3 or later (LGPLv3+)
- apeye-core (1.1.5) - BSD License
- appnope (0.1.4) - BSD License
- argcomplete (3.5.2) - Apache Software License
- argon2-cffi (23.1.0) - MIT License
- argon2-cffi-bindings (21.2.0) - MIT License
- arrow (1.3.0) - Apache Software License
- asttokens (3.0.0) - Apache 2.0
- async-lru (2.0.4) - MIT License
- attrs (24.3.0) - UNKNOWN
- autodoc_pydantic (2.2.0) - MIT License
- autodocsumm (0.2.14) - Apache Software License
- babel (2.16.0) - BSD License
- beautifulsoup4 (4.12.3) - MIT License
- bleach (6.2.0) - Apache Software License
- blinker (1.9.0) - MIT License
- boolean.py (4.0) - BSD-2-Clause
- bracex (2.5.post1) - MIT License
- brave-search-python-client (0.4.26) - MIT License
- bump-my-version (1.1.2) - MIT License
- cachetools (5.5.0) - MIT License
- certifi (2024.12.14) - Mozilla Public License 2.0 (MPL 2.0)
- cffi (1.17.1) - MIT License
- cfgv (3.4.0) - MIT License
- chardet (5.2.0) - GNU Lesser General Public License v2 or later (LGPLv2+)
- charset-normalizer (3.4.1) - MIT License
- click (8.1.8) - BSD License
- cloudpickle (3.1.1) - BSD License
- colorama (0.4.6) - BSD License
- colorlog (6.9.0) - MIT License
- comm (0.2.2) - BSD License
- contourpy (1.3.1) - BSD License
- coverage (7.6.10) - Apache Software License
- cssutils (2.11.1) - GNU Library or Lesser General Public License (LGPL)
- cycler (0.12.1) - BSD License
- cyclonedx-bom (4.6.1) - Apache Software License
- cyclonedx-py (1.0.1) - UNKNOWN
- cyclonedx-python-lib (7.6.2) - Apache Software License
- debugpy (1.8.11) - MIT License
- decorator (5.1.1) - BSD License
- defusedxml (0.7.1) - Python Software Foundation License
- dependency-groups (1.3.0) - UNKNOWN
- detect-secrets (1.5.0) - Apache Software License
- dict2css (0.3.0.post1) - MIT License
- distlib (0.3.9) - Python Software Foundation License
- docutils (0.21.2) - BSD License; GNU General Public License (GPL); Public Domain; Python Software Foundation License
- domdf-python-tools (3.9.0) - MIT License
- enum-tools (0.13.0) - GNU Lesser General Public License v3 or later (LGPLv3+)
- execnet (2.1.1) - MIT License
- executing (2.1.0) - MIT License
- fastjsonschema (2.21.1) - BSD License
- filelock (3.16.1) - The Unlicense (Unlicense)
- fonttools (4.55.3) - MIT License
- fqdn (1.5.1) - Mozilla Public License 2.0 (MPL 2.0)
- furo (2024.8.6) - MIT License
- git-cliff (2.8.0) - MIT OR Apache-2.0
- gitdb (4.0.11) - BSD License
- h11 (0.16.0) - MIT License
- html5lib (1.1) - MIT License
- httpcore (1.0.7) - BSD License
- httpx (0.28.1) - BSD License
- identify (2.6.4) - MIT License
- idna (3.10) - BSD License
- imagesize (1.4.1) - MIT License
- iniconfig (2.0.0) - MIT License
- ipykernel (6.29.5) - BSD License
- ipython (8.31.0) - BSD License
- ipywidgets (8.1.5) - BSD License
- isoduration (20.11.0) - ISC License (ISCL)
- itsdangerous (2.2.0) - BSD License
- jedi (0.19.2) - MIT License
- json5 (0.10.0) - Apache Software License
- jsonpointer (3.0.0) - BSD License
- jsonschema (4.23.0) - MIT License
- jsonschema-specifications (2024.10.1) - MIT License
- jupyter (1.1.1) - BSD License
- jupyter-console (6.6.3) - BSD License
- jupyter-events (0.11.0) - BSD License
- jupyter-lsp (2.2.5) - BSD License
- jupyter_client (8.6.3) - BSD License
- jupyter_core (5.7.2) - BSD License
- jupyter_server (2.15.0) - BSD License
- jupyter_server_terminals (0.5.3) - BSD License
- jupyterlab (4.3.4) - BSD License
- jupyterlab_pygments (0.3.0) - BSD License
- jupyterlab_server (2.27.3) - BSD License
- jupyterlab_widgets (3.0.13) - BSD License
- kiwisolver (1.4.8) - BSD License
- license-expression (30.4.0) - Apache-2.0
- lxml (5.3.0) - BSD License
- marimo (0.13.1) - Apache Software License
- markdown-it-py (3.0.0) - MIT License
- matplotlib (3.10.1) - Python Software Foundation License
- matplotlib-inline (0.1.7) - BSD License
- mbstrdecoder (1.1.4) - MIT License
- mdurl (0.1.2) - MIT License
- mistune (3.1.0) - BSD License
- more-itertools (10.5.0) - MIT License
- msgpack (1.1.0) - Apache Software License
- mypy (1.15.0) - MIT License
- mypy-extensions (1.0.0) - MIT License
- narwhals (1.20.1) - MIT License
- natsort (8.4.0) - MIT License
- nbclient (0.10.2) - BSD License
- nbconvert (7.16.4) - BSD License
- nbformat (5.10.4) - BSD License
- nest-asyncio (1.6.0) - BSD License
- nodeenv (1.9.1) - BSD License
- notebook (7.3.2) - BSD License
- notebook_shim (0.2.4) - BSD License
- nox (2025.2.9) - Apache Software License
- numpy (2.2.1) - BSD License
- outcome (1.3.0.post0) - Apache Software License; MIT License
- overrides (7.7.0) - Apache License, Version 2.0
- packageurl-python (0.16.0) - MIT License
- packaging (24.2) - Apache Software License; BSD License
- pandas (2.2.3) - BSD License
- pandocfilters (1.5.1) - BSD License
- parso (0.8.4) - MIT License
- pathvalidate (3.2.3) - MIT License
- pexpect (4.9.0) - ISC License (ISCL)
- pillow (11.0.0) - CMU License (MIT-CMU)
- pip (24.3.1) - MIT License
- pip-api (0.0.34) - Apache Software License
- pip-licenses (5.0.0) - MIT License
- pip-requirements-parser (32.0.1) - MIT
- pip_audit (2.9.0) - Apache Software License
- platformdirs (4.3.6) - MIT License
- pluggy (1.5.0) - MIT License
- pre_commit (4.1.0) - MIT License
- prettytable (3.12.0) - BSD License
- prometheus_client (0.21.1) - Apache Software License
- prompt_toolkit (3.0.48) - BSD License
- protobuf (5.29.2) - 3-Clause BSD License
- psutil (7.0.0) - BSD License
- ptyprocess (0.7.0) - ISC License (ISCL)
- pure_eval (0.2.3) - MIT License
- py-serializable (1.1.2) - Apache Software License
- pyarrow (18.1.0) - Apache Software License
- pycparser (2.22) - BSD License
- pycrdt (0.11.1) - MIT License
- pydantic (2.11.2) - MIT License
- pydantic-settings (2.9.1) - MIT License
- pydantic_core (2.33.1) - MIT License
- pydeck (0.9.1) - Apache License 2.0
- pymdown-extensions (10.14.3) - MIT License
- pyparsing (3.2.0) - MIT License
- pyright (1.1.400) - MIT
- pytablewriter (1.2.1) - MIT License
- pytest (8.3.5) - MIT License
- pytest-asyncio (0.26.0) - UNKNOWN
- pytest-base-url (2.1.0) - Mozilla Public License 2.0 (MPL 2.0)
- pytest-cov (6.1.1) - MIT License
- pytest-datadir (1.5.0) - MIT License
- pytest-docker (3.2.1) - MIT License
- pytest-env (1.1.5) - MIT License
- pytest-html (4.1.1) - MIT License
- pytest-md-report (0.6.3) - MIT License
- pytest-metadata (3.1.1) - Mozilla Public License 2.0 (MPL 2.0)
- pytest-regressions (2.7.0) - MIT License
- pytest-selenium (4.1.0) - Mozilla Public License 2.0 (MPL 2.0)
- pytest-subprocess (1.5.3) - MIT License
- pytest-timeout (2.3.1) - DFSG approved; MIT License
- pytest-variables (3.1.0) - Mozilla Public License 2.0 (MPL 2.0)
- pytest-watcher (0.4.3) - MIT License
- pytest-xdist (3.6.1) - MIT License
- python-dateutil (2.9.0.post0) - Apache Software License; BSD License
- python-dotenv (1.1.0) - BSD License
- python-json-logger (3.2.1) - BSD License
- pytz (2024.2) - MIT License
- pyzmq (26.2.0) - BSD License
- questionary (2.1.0) - MIT License
- referencing (0.35.1) - MIT License
- requests (2.32.3) - Apache Software License
- rfc3339-validator (0.1.4) - MIT License
- rfc3986-validator (0.1.1) - MIT License
- rich (13.9.4) - MIT License
- rich-click (1.8.5) - MIT License
- roman-numerals-py (3.1.0) - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication; Zero-Clause BSD (0BSD)
- rpds-py (0.22.3) - MIT License
- ruamel.yaml (0.18.8) - MIT License
- ruff (0.11.6) - MIT License
- scalene (1.5.51) - Apache Software License
- selenium (4.31.0) - Apache Software License
- setuptools (75.6.0) - MIT License
- shellingham (1.5.4) - ISC License (ISCL)
- six (1.17.0) - MIT License
- smmap (5.0.1) - BSD License
- sniffio (1.3.1) - Apache Software License; MIT License
- snowballstemmer (2.2.0) - BSD License
- sortedcontainers (2.4.0) - Apache Software License
- soupsieve (2.6) - MIT License
- sphinx-autobuild (2024.10.3) - MIT License
- sphinx-autodoc-typehints (3.0.0) - MIT License
- sphinx-basic-ng (1.0.0b2) - MIT License
- sphinx-copybutton (0.5.2) - MIT License
- sphinx-jinja2-compat (0.3.0) - MIT License
- sphinx-prompt (1.9.0) - BSD License
- sphinx-rtd-theme (3.0.2) - MIT License
- sphinx-tabs (3.4.5) - MIT License
- sphinx-toolbox (3.9.0) - MIT License
- sphinx_inline_tabs (2023.4.21) - UNKNOWN
- sphinx_mdinclude (0.6.2) - MIT License
- sphinx_selective_exclude (1.0.3) - MIT license
- sphinxcontrib-applehelp (2.0.0) - BSD License
- sphinxcontrib-devhelp (2.0.0) - BSD License
- sphinxcontrib-htmlhelp (2.1.0) - BSD License
- sphinxcontrib-jquery (4.1) - BSD License
- sphinxcontrib-jsmath (1.0.1) - BSD License
- sphinxcontrib-qthelp (2.0.0) - BSD License
- sphinxcontrib-serializinghtml (2.0.0) - BSD License
- sphinxext-opengraph (0.9.1) - BSD License
- stack-data (0.6.3) - MIT License
- standard-imghdr (3.10.14) - Python Software Foundation License
- starlette (0.46.2) - BSD License
- streamlit (1.44.1) - Apache Software License
- swagger-plugin-for-sphinx (5.1.0) - Apache Software License
- tabledata (1.3.4) - MIT License
- tabulate (0.9.0) - MIT License
- tcolorpy (0.1.7) - MIT License
- tenacity (9.1.2) - Apache Software License
- terminado (0.18.1) - BSD License
- tinycss2 (1.4.0) - BSD License
- toml (0.10.2) - MIT License
- tomli (2.2.1) - MIT License
- tomlkit (0.13.2) - MIT License
- tornado (6.4.2) - Apache Software License
- traitlets (5.14.3) - BSD License
- trio (0.30.0) - UNKNOWN
- trio-websocket (0.12.2) - MIT License
- typepy (1.3.4) - MIT License
- typer (0.15.2) - MIT License
- types-PyYAML (6.0.12.20250402) - UNKNOWN
- types-python-dateutil (2.9.0.20241206) - Apache Software License
- types-requests (2.32.0.20250328) - Apache Software License
- typing-inspection (0.4.0) - MIT License
- typing_extensions (4.12.2) - Python Software Foundation License
- tzdata (2024.2) - Apache Software License
- uri-template (1.3.0) - MIT License
- urllib3 (2.3.0) - MIT License
- uv (0.5.13) - Apache Software License; MIT License
- uvicorn (0.34.0) - BSD License
- virtualenv (20.28.0) - MIT License
- watchdog (6.0.0) - Apache Software License
- watchfiles (1.0.3) - MIT License
- wcmatch (10.0) - MIT License
- wcwidth (0.2.13) - MIT License
- webcolors (24.11.1) - BSD License
- webencodings (0.5.1) - BSD License
- websocket-client (1.8.0) - Apache Software License
- websockets (14.1) - BSD License
- wheel (0.45.1) - MIT License
- widgetsnbextension (4.0.13) - BSD License
- wsproto (1.2.0) - MIT License