Apify
ApifyTools lets agents run Apify Actors for web scraping, crawling, and data extraction.
Apify Actors give Agno agents web scraping, crawling, data extraction, and web automation capabilities.
What is Apify?
Apify is a platform that provides:
- Data collection services for AI Agents, specializing in extracting data from social media, search engines, online maps, e-commerce sites, travel portals, or general websites
- A marketplace of ready-to-use Actors (specialized tools) for various data tasks
- Infrastructure to run and monetize your own AI Agents
Prerequisites
- Sign up for an Apify account
- Obtain your Apify API token (can be obtained from Apify)
- Install the required packages:
uv pip install agno apify-client openaiBasic Usage
The Agno framework makes it easy to integrate Apify Actors into your agents. Here's a simple example:
from agno.agent import Agent
from agno.tools.apify import ApifyTools
# Create an agent with ApifyTools
agent = Agent(
tools=[
ApifyTools(
actors=["apify/rag-web-browser"], # Specify which Apify Actors to use, use multiple ones if needed
apify_api_token="your_apify_api_key" # Or set the APIFY_API_TOKEN environment variable
)
],
markdown=True
)
# Use the agent to get website content
agent.print_response("What information can you find on https://docs.agno.com/introduction ?", markdown=True)Available Apify Tools
You can easily integrate any Apify Actor as a tool. Here are some examples:
1. RAG Web Browser
The RAG Web Browser Actor is specifically designed for AI and LLM applications. It searches the web for a query or processes a URL, then cleans and formats the content for your agent.
from agno.agent import Agent
from agno.tools.apify import ApifyTools
agent = Agent(
tools=[
ApifyTools(actors=["apify/rag-web-browser"])
],
markdown=True
)
# Search for information and process the results
agent.print_response("What are the latest developments in large language models?", markdown=True)2. Website Content Crawler
This tool uses Apify's Website Content Crawler Actor to extract text content from websites, making it perfect for RAG applications.
from agno.agent import Agent
from agno.tools.apify import ApifyTools
agent = Agent(
tools=[
ApifyTools(actors=["apify/website-content-crawler"])
],
markdown=True
)
# Ask the agent to process web content
agent.print_response("Summarize the content from https://docs.agno.com/introduction", markdown=True)3. Google Places Crawler
The Google Places Crawler extracts data about businesses from Google Maps and Google Places.
from agno.agent import Agent
from agno.tools.apify import ApifyTools
agent = Agent(
tools=[
ApifyTools(actors=["compass/crawler-google-places"])
]
)
# Find business information in a specific location
agent.print_response("What are the top-rated restaurants in San Francisco?", markdown=True)
agent.print_response("Find coffee shops in Prague", markdown=True)The Agent model uses an OpenAI key, separately from any toolkit provider credentials.
Set OpenAI Key
Set your OPENAI_API_KEY as an environment variable. You can get one from OpenAI.
export OPENAI_API_KEY=sk-***Example Scenarios
RAG Web Browser + Google Places Crawler
This example combines web search with local business data to provide comprehensive information about a topic:
from agno.agent import Agent
from agno.tools.apify import ApifyTools
agent = Agent(
tools=[
ApifyTools(actors=[
"apify/rag-web-browser",
"compass/crawler-google-places"
])
]
)
# Get general information and local businesses
agent.print_response(
"""
I'm traveling to Tokyo next month.
1. Research the best time to visit and major attractions
2. Find one good rated sushi restaurants near Shinjuku
Compile a comprehensive travel guide with this information.
""",
markdown=True
)Toolkit Params
| Parameter | Type | Default | Description |
|---|---|---|---|
apify_api_token | str | None | Apify API token (or set via APIFY_API_TOKEN environment variable) |
actors | str or List[str] | None | Single Actor ID or list of Actor IDs to register |