LangChain integration for TinyFish Web Agent - AI-powered web automation
Project description
TinyFish Web Agent for LangChain
This package provides a LangChain Tool to run the TinyFish Web Agent directly within your LangChain Agents and Workflows.
TinyFish is a platform for executing complex, goal-oriented tasks on the live web. Unlike traditional scrapers or local browser automation, TinyFish uses a fleet of remote, AI-powered web agents that can navigate complex sites, handle anti-bot protection, and return clean, structured JSON data.
Installation
pip install langchain-tinyfish
Configuration
- Get your TinyFish API key from agent.tinyfish.ai/api-keys.
- Set it as an environment variable:
export TINYFISH_API_KEY="YOUR_API_KEY"
Quick Start
Here is a simple example of how to use the TinyFish Web Agent to extract the current stock price of NVIDIA from Yahoo Finance.
from langchain_tinyfish import TinyFishWebAutomation
tool = TinyFishWebAutomation()
result = tool.invoke({
"url": "https://finance.yahoo.com/quote/NVDA/",
"goal": "Extract the current stock price of NVIDIA",
})
print(result)
# Output: {"stock_price": 950.02}
Search, Fetch, and Browser Sessions
The package also exposes SDK-backed tools for TinyFish Search, Fetch, and Browser sessions:
from langchain_tinyfish import (
TinyFishBrowserSession,
TinyFishFetch,
TinyFishSearch,
)
search = TinyFishSearch()
fetch = TinyFishFetch()
browser = TinyFishBrowserSession()
search_results = search.invoke({"query": "TinyFish Web Agent docs"})
page_content = fetch.invoke({"urls": ["https://docs.tinyfish.ai"], "format": "markdown"})
session = browser.invoke({"url": "https://example.com"})
With a LangChain Agent
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from langchain_tinyfish import TinyFishFetch, TinyFishSearch, TinyFishWebAutomation
llm = ChatOpenAI(model="gpt-4o")
tools = [
TinyFishWebAutomation(),
TinyFishSearch(),
TinyFishFetch(),
]
agent = create_react_agent(llm, tools)
result = agent.invoke({
"messages": [("user", "Go to scrapeme.live/shop and extract the first 5 product names and prices")]
})
for message in result["messages"]:
print(message.content)
Stealth Mode + Proxy
For sites with bot protection (Cloudflare, CAPTCHAs, etc.):
from langchain_tinyfish import TinyFishAPIWrapper, TinyFishWebAutomation
tool = TinyFishWebAutomation(
api_wrapper=TinyFishAPIWrapper(
browser_profile="stealth",
proxy_enabled=True,
proxy_country_code="US", # Also: GB, CA, DE, FR, JP, AU
)
)
Async Usage
import asyncio
from langchain_tinyfish import TinyFishWebAutomation
async def main():
tool = TinyFishWebAutomation()
result = await tool.ainvoke({
"url": "https://example.com",
"goal": "Extract the page title",
})
print(result)
asyncio.run(main())
Use Cases
- AI Agent Enablement: Give your AI agent the ability to perform deep research on the web.
- Workflow Automation: Monitor a competitor's pricing page and get a Slack notification when it changes.
- Data Extraction: Extract job postings, product details, or contact information into a structured format.
Configuration Options
All parameters are set on the TinyFishAPIWrapper:
| Parameter | Default | Description |
|---|---|---|
api_key |
$TINYFISH_API_KEY |
Your TinyFish API key |
browser_profile |
"lite" |
"lite" (fast) or "stealth" (anti-detection) |
proxy_enabled |
False |
Enable proxy routing |
proxy_country_code |
"US" |
Proxy country: US, GB, CA, DE, FR, JP, AU |
timeout |
300 |
Request timeout in seconds |
from langchain_tinyfish import TinyFishAPIWrapper, TinyFishWebAutomation
wrapper = TinyFishAPIWrapper(
api_key="sk-mino-...",
browser_profile="stealth",
timeout=600,
)
tool = TinyFishWebAutomation(api_wrapper=wrapper)
Development
# Install package + dev dependencies
pip install -e .
pip install -r requirements-dev.txt
# Run unit tests
make test
# Run linter
make lint
# Run integration tests (requires TINYFISH_API_KEY)
make integration_test
Support
If you have any questions or need help, please reach out to support@tinyfish.ai or join our Discord community.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_tinyfish-0.1.0.tar.gz.
File metadata
- Download URL: langchain_tinyfish-0.1.0.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62676a4c9cedcd3a33e7631ffff7575b4acdfbe6badeb07c18c6cbbaf2e487a1
|
|
| MD5 |
2612484db28c361c72485a00327f2ef3
|
|
| BLAKE2b-256 |
3ef0885bdaf65b0ff1fa470da51b92025a93fa71941065564f5c482629567a9b
|
File details
Details for the file langchain_tinyfish-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_tinyfish-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd7844ac46416014680c22647196e2aac5cfcffecf63d53c8fa104403c084ac0
|
|
| MD5 |
e0cae43ecf5c945110a7e12996bff0e9
|
|
| BLAKE2b-256 |
9ad1f0c52e68a5b9648127ee862ea65e9b8e9a1473a1062f4e7e8faf99f30494
|