# Tavily Python Wrapper
[](https://github.com/tavily-ai/tavily-python/stargazers)
[](https://pypi.org/project/tavily-python/)
[](https://github.com/tavily-ai/tavily-python/blob/main/LICENSE)
[](https://github.com/tavily-ai/tavily-python/actions)
The Tavily Python wrapper allows for easy interaction with the Tavily API, offering the full range of our search and extract functionalities directly from your Python programs. Easily integrate smart search and content extraction capabilities into your applications, harnessing Tavily's powerful search and extract features.
## Installing
```bash
pip install tavily-python
```
# Tavily Search
Search lets you search the web for a given query.
## Usage
Below are some code snippets that show you how to interact with our search API. The different steps and components of this code are explained in more detail in the API Methods section further down.
### Getting and printing the full Search API response
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Executing a simple search query
response = tavily_client.search("Who is Leo Messi?")
# Step 3. That's it! You've done a Tavily Search!
print(response)
```
This is equivalent to directly querying our REST API.
### Generating context for a RAG Application
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Executing a context search query
context = tavily_client.get_search_context(query="What happened during the Burning Man floods?")
# Step 3. That's it! You now have a context string that you can feed directly into your RAG Application
print(context)
```
This is how you can generate precise and fact-based context for your RAG application in one line of code.
### Getting a quick answer to a question
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Executing a Q&A search query
answer = tavily_client.qna_search(query="Who is Leo Messi?")
# Step 3. That's it! Your question has been answered!
print(answer)
```
This is how you get accurate and concise answers to questions, in one line of code. Perfect for usage by LLMs!
# Tavily Extract
Extract web page content from one or more specified URLs.
## Usage
Below are some code snippets that demonstrate how to interact with our Extract API. Each step and component of this code is explained in greater detail in the API Methods section below.
### Extracting Raw Content from Multiple URLs using Tavily Extract API
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Defining the list of URLs to extract content from
urls = [
"https://en.wikipedia.org/wiki/Artificial_intelligence",
"https://en.wikipedia.org/wiki/Machine_learning",
"https://en.wikipedia.org/wiki/Data_science",
"https://en.wikipedia.org/wiki/Quantum_computing",
"https://en.wikipedia.org/wiki/Climate_change"
] # You can provide up to 20 URLs simultaneously
# Step 3. Executing the extract request
response = tavily_client.extract(urls=urls, include_images=True)
# Step 4. Printing the extracted raw content
for result in response["results"]:
print(f"URL: {result['url']}")
print(f"Raw Content: {result['raw_content']}")
print(f"Images: {result['images']}\n")
# Note that URLs that could not be extracted will be stored in response["failed_results"]
```
# Tavily Crawl (Open-Access Beta)
Crawl lets you traverse a website's content starting from a base URL.
> **Note**: Crawl is currently available on an invite-only basis. For more information, please visit [crawl.tavily.com](https://crawl.tavily.com)
## Usage
Below are some code snippets that demonstrate how to interact with our Crawl API. Each step and component of this code is explained in greater detail in the API Methods section below.
### Crawling a website with instructions
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Defining the starting URL
start_url = "https://wikipedia.org/wiki/Lemon"
# Step 3. Executing the crawl request with instructions to surface only pages about citrus fruits
response = tavily_client.crawl(
url=start_url,
max_depth=3,
limit=50,
instructions="Find all pages on citrus fruits"
)
# Step 4. Printing pages matching the query
for result in response["results"]:
print(f"URL: {result['url']}")
print(f"Snippet: {result['raw_content'][:200]}...\n")
```
# Tavily Map (Open-Access Beta)
Map lets you discover and visualize the structure of a website starting from a base URL.
## Usage
Below are some code snippets that demonstrate how to interact with our Map API. Each step and component of this code is explained in greater detail in the API Methods section below.
### Mapping a website with instructions
```python
from tavily import TavilyClient
# Step 1. Instantiating your TavilyClient
tavily_client = TavilyClient(api_key="tvly-YOUR_API_KEY")
# Step 2. Defining the starting URL
start_url = "https://wikipedia.org/wiki/Lemon"
# Step 3. Executing the map request with parameters to focus on specific pages
response = tavily_client.map(
url=start_url,
max_depth=2,
limit=30,
instructions="Find pages on citrus fruits"
)
# Step 4. Printing the site structure
for result in response["results"]:
print(f"URL: {result['url']}")
```
## Documentation
For a complete guide on how to use the different endpoints and their parameters, please head to our [Python API Reference](https://docs.tavily.com/sdk/python/reference).
## Cost
Tavily is free for personal use for up to 1,000 credits per month.
Head to the [Credits & Pricing](https://docs.tavily.com/documentation/api-credits) in our documentation to learn more about how many API credits each request costs.
## License
This project is licensed under the terms of the MIT license.
## Contact
If you are encountering issues while using Tavily, please email us at support@tavily.com. We'll be happy to help you.
If you want to stay updated on the latest Tavily news and releases, head to our [Developer Community](https://community.tavily.com) to learn more!
Raw data
{
"_id": null,
"home_page": "https://github.com/tavily-ai/tavily-python",
"name": "tavily-python",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Tavily AI",
"author_email": "support@tavily.com",
"download_url": "https://files.pythonhosted.org/packages/bb/a4/2b816cbb287c6417e7997195a2b8ce32200ea2acc7099fba1ddf37d0d051/tavily_python-0.7.11.tar.gz",
"platform": null,
"description": "# Tavily Python Wrapper\n\n[](https://github.com/tavily-ai/tavily-python/stargazers)\n[](https://pypi.org/project/tavily-python/)\n[](https://github.com/tavily-ai/tavily-python/blob/main/LICENSE)\n[](https://github.com/tavily-ai/tavily-python/actions)\n\nThe Tavily Python wrapper allows for easy interaction with the Tavily API, offering the full range of our search and extract functionalities directly from your Python programs. Easily integrate smart search and content extraction capabilities into your applications, harnessing Tavily's powerful search and extract features.\n\n## Installing\n\n```bash\npip install tavily-python\n```\n\n# Tavily Search\nSearch lets you search the web for a given query.\n\n## Usage\n\nBelow are some code snippets that show you how to interact with our search API. The different steps and components of this code are explained in more detail in the API Methods section further down.\n\n### Getting and printing the full Search API response\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Executing a simple search query\nresponse = tavily_client.search(\"Who is Leo Messi?\")\n\n# Step 3. That's it! You've done a Tavily Search!\nprint(response)\n```\n\nThis is equivalent to directly querying our REST API.\n\n### Generating context for a RAG Application\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Executing a context search query\ncontext = tavily_client.get_search_context(query=\"What happened during the Burning Man floods?\")\n\n# Step 3. That's it! You now have a context string that you can feed directly into your RAG Application\nprint(context)\n```\n\nThis is how you can generate precise and fact-based context for your RAG application in one line of code.\n\n### Getting a quick answer to a question\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Executing a Q&A search query\nanswer = tavily_client.qna_search(query=\"Who is Leo Messi?\")\n\n# Step 3. That's it! Your question has been answered!\nprint(answer)\n```\n\nThis is how you get accurate and concise answers to questions, in one line of code. Perfect for usage by LLMs!\n\n# Tavily Extract\nExtract web page content from one or more specified URLs.\n\n## Usage\n\nBelow are some code snippets that demonstrate how to interact with our Extract API. Each step and component of this code is explained in greater detail in the API Methods section below.\n\n### Extracting Raw Content from Multiple URLs using Tavily Extract API\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Defining the list of URLs to extract content from\nurls = [\n \"https://en.wikipedia.org/wiki/Artificial_intelligence\",\n \"https://en.wikipedia.org/wiki/Machine_learning\",\n \"https://en.wikipedia.org/wiki/Data_science\",\n \"https://en.wikipedia.org/wiki/Quantum_computing\",\n \"https://en.wikipedia.org/wiki/Climate_change\"\n] # You can provide up to 20 URLs simultaneously\n\n# Step 3. Executing the extract request\nresponse = tavily_client.extract(urls=urls, include_images=True)\n\n# Step 4. Printing the extracted raw content\nfor result in response[\"results\"]:\n print(f\"URL: {result['url']}\")\n print(f\"Raw Content: {result['raw_content']}\")\n print(f\"Images: {result['images']}\\n\")\n\n# Note that URLs that could not be extracted will be stored in response[\"failed_results\"]\n```\n\n# Tavily Crawl (Open-Access Beta)\n\nCrawl lets you traverse a website's content starting from a base URL.\n\n> **Note**: Crawl is currently available on an invite-only basis. For more information, please visit [crawl.tavily.com](https://crawl.tavily.com)\n\n## Usage\n\nBelow are some code snippets that demonstrate how to interact with our Crawl API. Each step and component of this code is explained in greater detail in the API Methods section below.\n\n### Crawling a website with instructions\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Defining the starting URL\nstart_url = \"https://wikipedia.org/wiki/Lemon\"\n\n# Step 3. Executing the crawl request with instructions to surface only pages about citrus fruits\nresponse = tavily_client.crawl(\n url=start_url,\n max_depth=3,\n limit=50,\n instructions=\"Find all pages on citrus fruits\"\n)\n\n# Step 4. Printing pages matching the query\nfor result in response[\"results\"]:\n print(f\"URL: {result['url']}\")\n print(f\"Snippet: {result['raw_content'][:200]}...\\n\")\n\n```\n\n# Tavily Map (Open-Access Beta)\n\nMap lets you discover and visualize the structure of a website starting from a base URL.\n\n## Usage\n\nBelow are some code snippets that demonstrate how to interact with our Map API. Each step and component of this code is explained in greater detail in the API Methods section below.\n\n### Mapping a website with instructions\n\n```python\nfrom tavily import TavilyClient\n\n# Step 1. Instantiating your TavilyClient\ntavily_client = TavilyClient(api_key=\"tvly-YOUR_API_KEY\")\n\n# Step 2. Defining the starting URL\nstart_url = \"https://wikipedia.org/wiki/Lemon\"\n\n# Step 3. Executing the map request with parameters to focus on specific pages\nresponse = tavily_client.map(\n url=start_url,\n max_depth=2,\n limit=30,\n instructions=\"Find pages on citrus fruits\"\n)\n\n# Step 4. Printing the site structure\nfor result in response[\"results\"]:\n print(f\"URL: {result['url']}\")\n\n```\n\n## Documentation\n\nFor a complete guide on how to use the different endpoints and their parameters, please head to our [Python API Reference](https://docs.tavily.com/sdk/python/reference).\n\n## Cost\n\nTavily is free for personal use for up to 1,000 credits per month.\nHead to the [Credits & Pricing](https://docs.tavily.com/documentation/api-credits) in our documentation to learn more about how many API credits each request costs.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n\n## Contact\n\nIf you are encountering issues while using Tavily, please email us at support@tavily.com. We'll be happy to help you.\n\nIf you want to stay updated on the latest Tavily news and releases, head to our [Developer Community](https://community.tavily.com) to learn more!\n",
"bugtrack_url": null,
"license": null,
"summary": "Python wrapper for the Tavily API",
"version": "0.7.11",
"project_urls": {
"Homepage": "https://github.com/tavily-ai/tavily-python"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8553371a39e17f02e3df8ab3493c77453b0f8f0d2783bd23d6e0fc879d211217",
"md5": "e6e4f46c96c7e028248b43312747f964",
"sha256": "50559d8b605b6854fd85b1b785c603851b86eb4d0e9fd29154f81b54b734dd6e"
},
"downloads": -1,
"filename": "tavily_python-0.7.11-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e6e4f46c96c7e028248b43312747f964",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 15826,
"upload_time": "2025-08-18T23:56:52",
"upload_time_iso_8601": "2025-08-18T23:56:52.203590Z",
"url": "https://files.pythonhosted.org/packages/85/53/371a39e17f02e3df8ab3493c77453b0f8f0d2783bd23d6e0fc879d211217/tavily_python-0.7.11-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bba42b816cbb287c6417e7997195a2b8ce32200ea2acc7099fba1ddf37d0d051",
"md5": "ca4d1bf07012d7fdca043825fbac5936",
"sha256": "58c3ab71bb62820ade5498acc17bc372f436e88151389912672add6bf6d31aed"
},
"downloads": -1,
"filename": "tavily_python-0.7.11.tar.gz",
"has_sig": false,
"md5_digest": "ca4d1bf07012d7fdca043825fbac5936",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 19278,
"upload_time": "2025-08-18T23:56:57",
"upload_time_iso_8601": "2025-08-18T23:56:57.899257Z",
"url": "https://files.pythonhosted.org/packages/bb/a4/2b816cbb287c6417e7997195a2b8ce32200ea2acc7099fba1ddf37d0d051/tavily_python-0.7.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-18 23:56:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tavily-ai",
"github_project": "tavily-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "tavily-python",
"specs": []
},
{
"name": "openai",
"specs": []
}
],
"lcname": "tavily-python"
}