langchain-oxylabs
This package contains the LangChain integration with Oxylabs, providing tools to scrape Google search results with Oxylabs Web Scraper API using LangChain's framework.
Installation
pip install -U langchain-oxylabs
Credentials
Create your API user credentials: Sign up for a free trial or purchase the product in the Oxylabs dashboard to create your API user credentials.
Configure your Oxylabs credentials by setting the following environment variables:
OXYLABS_USERNAME- Your Oxylabs API usernameOXYLABS_PASSWORD- Your Oxylabs API password
Requirements
- Python 3.10 or newer
- Works with both
langchain-core0.3.x and LangChain v1 (langchain-core1.x)
Usage
langchain_oxylabs package provides the following classes:
OxylabsSearchRun- A tool that returns scraped Google search results in a formatted textOxylabsSearchResults- A tool that returns scraped Google search results in a JSON formatOxylabsSearchAPIWrapper- An API wrapper for initializing Oxylabs APIOxylabsLoader- A document loader that scrapes URLs or search queries into LangChainDocumentobjects
Search tools
Here is an example usage of these classes:
import json
from langchain_oxylabs import OxylabsSearchRun, OxylabsSearchResults, OxylabsSearchAPIWrapper
# Initialize the API wrapper
oxylabs_wrapper = OxylabsSearchAPIWrapper()
# Initialize the search run tool
run_tool = OxylabsSearchRun(wrapper=oxylabs_wrapper)
# Invoke the tool and print results
results_text = run_tool.invoke({"query": "Visit restaurants in Vilnius."})
print(results_text)
# Initialize the search results tool
results_tool = OxylabsSearchResults(wrapper=oxylabs_wrapper)
# Invoke the tool and print results
response_results = results_tool.invoke({"query": "Visit restaurants in Paris."})
response_results = json.loads(response_results)
for result in response_results:
for key, value in result.items():
print(f"{key}: {value}")
Geo-targeted results
Pass geo_location to scope results to a location. It can be supplied per call
(an agent may set it from the user's question), or configured once on the wrapper
as a default for every search:
# Per call -- takes precedence
run_tool.invoke({"query": "best coffee", "geo_location": "Vilnius,Lithuania"})
# Or as a default for this wrapper
oxylabs_wrapper = OxylabsSearchAPIWrapper(
params={"geo_location": "Vilnius,Lithuania"}
)
Document loader
OxylabsLoader scrapes content into LangChain Document objects, which makes it
convenient for retrieval-augmented generation. Pass either urls or queries,
plus any Oxylabs Web Scraper API parameters.
from langchain_oxylabs import OxylabsLoader
# Scrape specific URLs as markdown
loader = OxylabsLoader(
urls=[
"https://sandbox.oxylabs.io/products/1",
"https://sandbox.oxylabs.io/products/2",
],
params={"markdown": True},
)
for document in loader.lazy_load():
print(document.metadata)
print(document.page_content[:250])
# Or scrape parsed search results for a list of queries
loader = OxylabsLoader(
queries=["gaming headset", "gaming chair"],
params={
"source": "amazon_search",
"parse": True,
"geo_location": "DE",
"currency": "EUR",
"pages": 3,
},
)
documents = loader.load()
lazy_load() issues one request per URL or query and yields documents as they
arrive, so it is preferable to load() for large batches.
Using with an agent
The search tools work with LangChain's agents. create_agent decides when to
search and with what geo_location:
from langchain.agents import create_agent
from langchain_oxylabs import OxylabsSearchAPIWrapper, OxylabsSearchRun
tool = OxylabsSearchRun(wrapper=OxylabsSearchAPIWrapper())
agent = create_agent(model="anthropic:claude-sonnet-5", tools=[tool])
result = agent.invoke(
{"messages": [{"role": "user", "content": "Find good coffee in Vilnius"}]}
)
print(result["messages"][-1].content)
Development
poetry install --with test,lint,typing
make test # unit tests, no network access
make lint # ruff + mypy
make integration_tests # live API calls, requires credentials
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for langchain-oxylabs 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| langchain_oxylabs-0.3.0.tar.gz | 15.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langchain_oxylabs-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.1 kB
Release files / langchain_oxylabs-0.3.0.tar.gz
| Download URL | langchain_oxylabs-0.3.0.tar.gz |
|---|---|
| Size | 15.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d7f5080a2030b8d83f9332e25d79665605999a5a69c98028fec63febeba7696
|
|
BLAKE2b-256 checksum How to use checksums |
be101afb19c8df88c0c926a11370c643771d9e329159d5484c560ebc267bd6eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.3 Darwin/25.3.0
|
Release files / langchain_oxylabs-0.3.0-py3-none-any.whl
| Download URL | langchain_oxylabs-0.3.0-py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f216db36da95eaa0c15527e35437f2d09e263a6f8c97cad8a3f287e2b1186909
|
|
BLAKE2b-256 checksum How to use checksums |
27704da451570ab8772feaabb7539c0288d516f106d0e3e4dc77affacc7e49a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.3 Darwin/25.3.0
|
Security for langchain-oxylabs 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.