Skip to main content

An integration package connecting You.com and LangChain

Project description

langchain-youdotcom

PyPI - Version PyPI - License PyPI - Downloads

LangChain partner package for You.com search, content extraction, research, and finance research APIs.

Installation | Credentials | Tools | Retriever | API Wrapper | Resources

Installation

pip install -U langchain-youdotcom

Credentials

Get an API key at you.com/platform/api-keys, then set it as an environment variable:

export YDC_API_KEY="your-api-key"

Or pass it directly when instantiating any component:

from langchain_youdotcom import YouSearchTool, YouAPIWrapper

tool = YouSearchTool(api_wrapper=YouAPIWrapper(ydc_api_key="your-api-key"))

Tools

YouSearchTool

Search the web with up to date results. Supports geographic filtering, freshness controls, and optional live-crawling for full page content. Great for monitoring mentions, pulling recent news, or feeding live data into agent workflows.

Instantiation parameters (set on YouAPIWrapper):

Parameter Type Default Description
count int | None None Max results per section, 1-100
country str | None None Two-letter country code to focus results geographically
freshness str | None None Filter by recency: day, week, month, or year
language str | None None BCP-47 language code for results
livecrawl str | None None Fetch full page content: web, news, or all
livecrawl_formats str | None None Format for livecrawled content: html or markdown
offset int | None None Pagination offset, 0-9
safesearch str | None None Content filter: off, moderate, or strict
k int | None None Max documents to return

Invocation args:

  • query (required, str): The search query.
from langchain_youdotcom import YouSearchTool, YouAPIWrapper

tool = YouSearchTool(
    api_wrapper=YouAPIWrapper(
        count=5,
        country="US",
        freshness="week",
        livecrawl="web",
        livecrawl_formats="markdown",
    ),
)

# invoke directly
result = tool.invoke("latest AI news")
print(result)

Using with an agent:

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

from langchain_youdotcom import YouSearchTool

tools = [YouSearchTool()]
agent = create_react_agent(ChatOpenAI(model="gpt-4o"), tools)

response = agent.invoke(
    {"messages": [{"role": "user", "content": "what happened in AI today?"}]}
)

YouContentsTool

Extract clean, structured content from one or more web pages. Returns page text as markdown or HTML, plus metadata like JSON-LD, OpenGraph, and Twitter Cards. Useful for scraping product pages, pulling article text, or extracting structured data from any URL.

Instantiation parameters (set on YouAPIWrapper):

No tool-level configuration. All parameters are passed at invocation time.

Invocation args:

  • urls (required, list[str]): URLs to fetch content from.

Content format and timeout are configured when calling the wrapper directly (see YouAPIWrapper).

Parameter Type Default Description
urls list[str] URLs to extract content from (required)
formats list[str] | None ["markdown", "metadata"] Output formats: markdown, html, and/or metadata
crawl_timeout float | None None Per-URL crawl timeout in seconds
from langchain_youdotcom import YouContentsTool

tool = YouContentsTool()
result = tool.invoke({"urls": ["https://example.com"]})
print(result)

YouResearchTool

Get a comprehensive, cited answer to a complex question. The Research API searches the web, reads multiple sources, and synthesizes a detailed markdown response with inline numbered citations. Perfect for competitive analysis, market research, technical due diligence, or any question that needs more than a simple search result.

Instantiation parameters (set on YouAPIWrapper):

Parameter Type Default Description
research_effort str | None None Controls depth and speed (see levels below)

Research effort levels:

Level Description
lite Quick answers for straightforward questions
standard Balanced speed and depth (default)
deep More time researching and cross-referencing sources
exhaustive Most thorough option for complex research tasks

Invocation args:

  • query (required, str): The research question.
from langchain_youdotcom import YouResearchTool, YouAPIWrapper

# default effort
tool = YouResearchTool()
result = tool.invoke("what are the latest advances in quantum computing")
print(result)

# deep research
tool = YouResearchTool(
    api_wrapper=YouAPIWrapper(research_effort="deep"),
)
result = tool.invoke("compare transformer architectures for long-context tasks")
print(result)

YouFinanceResearchTool

Get a comprehensive, citation-backed answer to a financial question. The Finance Research API works like the Research API but searches a finance-optimized index covering SEC filings, earnings reports, equity prices, macro indicators, and financial news. Ideal for earnings analysis, competitive benchmarking, due diligence, and market research.

Instantiation parameters (set on YouAPIWrapper):

Parameter Type Default Description
research_effort str | None None Controls depth (shared with YouResearchTool; see levels below)

Finance research only accepts deep and exhaustive. Other values raise ValueError.

Level Description
deep Multi-source analysis, earnings summaries, competitive benchmarking (default)
exhaustive Comprehensive research, deep due diligence, full 10-K analysis

Invocation args:

  • query (required, str): The financial research question.
from langchain_youdotcom import YouFinanceResearchTool, YouAPIWrapper

tool = YouFinanceResearchTool()
result = tool.invoke("what were NVIDIA's key revenue drivers in FY2025")
print(result)

# exhaustive research for complex due diligence
tool = YouFinanceResearchTool(
    api_wrapper=YouAPIWrapper(research_effort="exhaustive"),
)
result = tool.invoke("compare gross margins of Apple, Microsoft, and Google over the past three fiscal years")
print(result)

Retriever

The simplest way to get You.com search results as LangChain documents. Accepts all search parameters from YouSearchTool.

from langchain_youdotcom import YouRetriever

retriever = YouRetriever()
docs = retriever.invoke("latest AI news")

for doc in docs:
    print(doc.metadata["title"])
    print(doc.page_content[:200])
    print()

With search parameters:

retriever = YouRetriever(
    k=5,
    count=10,
    livecrawl="web",
    livecrawl_formats="markdown",
    country="US",
    freshness="week",
    safesearch="moderate",
)

YouAPIWrapper

Lower-level wrapper that powers the tools and retriever under the hood. Use it directly when you need full control over API calls and response formats.

Search:

from langchain_youdotcom import YouAPIWrapper

wrapper = YouAPIWrapper()

# search -> list[Document]
docs = wrapper.results("latest AI news")

# raw SDK response
raw = wrapper.raw_results("latest AI news")

Contents:

pages = wrapper.contents(
    ["https://example.com"],
    formats=["markdown", "metadata"],
    crawl_timeout=30,
)

Research:

# research -> formatted markdown with sources
text = wrapper.research_text("explain quantum entanglement")

# raw SDK response
raw = wrapper.raw_research("explain quantum entanglement")

Finance Research:

# finance research -> formatted markdown with sources
text = wrapper.finance_text("what drove NVIDIA's revenue growth in FY2025")

# raw response (parsed from JSON)
raw = wrapper.raw_finance("compare AAPL and MSFT gross margins")

Async variants are available for all methods: results_async, raw_results_async, contents_async, research_text_async, raw_research_async, finance_text_async, raw_finance_async.

Resources

Development

uv sync --all-groups
make format            # ruff format + fix
make lint              # ruff check + format diff + mypy
make test              # unit tests
make integration_tests # requires YDC_API_KEY
make check_imports     # verify all modules importable

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_youdotcom-0.3.1.tar.gz (104.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_youdotcom-0.3.1-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file langchain_youdotcom-0.3.1.tar.gz.

File metadata

  • Download URL: langchain_youdotcom-0.3.1.tar.gz
  • Upload date:
  • Size: 104.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langchain_youdotcom-0.3.1.tar.gz
Algorithm Hash digest
SHA256 dd0ad3358ad3590c0fffe673d0de173ce6d0e7930792893f0c5a5019b0b042b4
MD5 6058c518c9fb44eee52a733beba12856
BLAKE2b-256 789e4d6fe20f509f04b245502b0816b2282232b4ef4ade14d98ec2d79b1869a4

See more details on using hashes here.

File details

Details for the file langchain_youdotcom-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: langchain_youdotcom-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langchain_youdotcom-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b76a01bdb2e7668ef3649370a625eeedd65a34a8fd68fbb997c74fd0d232b518
MD5 51bd4681024c14341875d994ac66d226
BLAKE2b-256 b3e75e772c2ca51cf4fbe9d3dc606faae8f2024b3c08243f2d664b445ae6aff6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page