Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 131 additions & 22 deletions tools/toolkits/others/apify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,157 @@
title: Apify
---

**ApifyTools** enable an Agent to access the Apify API and run actors.
This guide demonstrates how to integrate and use [Apify](https://apify.com/actors) Actors within the Agno framework to enhance your AI agents with web scraping, crawling, data extraction, and web automation capabilities.

## What is Apify?

[Apify](https://apify.com/) 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 our own AI Agents

## Prerequisites

The following example requires the `apify-client` library and an API token which can be obtained from [Apify](https://apify.com/).
1. Sign up for an [Apify account](https://console.apify.com/sign-up)
2. Obtain your Apify API token (can be obtained from [Apify](https://docs.apify.com/platform/integrations/api))
3. Install the required packages:

```shell
pip install -U apify-client
```bash
pip install agno apify-client
```

```shell
export MY_APIFY_TOKEN=***
## Basic Usage

The Agno framework makes it easy to integrate Apify Actors into your agents. Here's a simple example:

```python
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
)
],
show_tool_calls=True,
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)
```

## Example
## Available Apify Tools

You can easily integrate any Apify Actor as a tool. Here are some examples:

### 1. RAG Web Browser

The following agent will use Apify to crawl the webpage: https://docs.agno.com/introduction and summarize it.
The [RAG Web Browser](https://apify.com/apify/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. This tool is enabled by default.

```python cookbook/tools/apify_tools.py
```python
from agno.agent import Agent
from agno.tools.apify import ApifyTools

agent = Agent(tools=[ApifyTools()], show_tool_calls=True)
agent.print_response("Tell me about https://docs.agno.com/introduction", markdown=True)
agent = Agent(
tools=[
ApifyTools(actors=["apify/rag-web-browser"])
],
show_tool_calls=True,
markdown=True
)

# Search for information and process the results
agent.print_response("What are the latest developments in large language models?", markdown=True)
```

## Toolkit Params
### 2. Website Content Crawler

| Parameter | Type | Default | Description |
| ------------------------- | ------ | ------- | --------------------------------------------------------------------------------- |
| `api_key` | `str` | - | API key for authentication purposes. |
| `website_content_crawler` | `bool` | `True` | Enables the functionality to crawl a website using website-content-crawler actor. |
| `web_scraper` | `bool` | `False` | Enables the functionality to crawl a website using web_scraper actor. |
This tool uses Apify's [Website Content Crawler](https://apify.com/apify/website-content-crawler) Actor to extract text content from websites, making it perfect for RAG applications.

## Toolkit Functions
```python
from agno.agent import Agent
from agno.tools.apify import ApifyTools

| Function | Description |
| ------------------------- | ------------------------------------------------------------- |
| `website_content_crawler` | Crawls a website using Apify's website-content-crawler actor. |
| `web_scrapper` | Scrapes a website using Apify's web-scraper actor. |
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](https://apify.com/compass/crawler-google-places) extracts data about businesses from Google Maps and Google Places.

```python
from agno.agent import Agent
from agno.tools.apify import ApifyTools

agent = Agent(
tools=[
ApifyTools(actors=["compass/crawler-google-places"])
],
show_tool_calls=True
)

# 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)
```

## Example Scenarios

### RAG Web Browser + Google Places Crawler
This example combines web search with local business data to provide comprehensive information about a topic:

```python
from agno.agent import Agent
from agno.tools.apify import ApifyTools

agent = Agent(
tools=[
ApifyTools(actors=[
"apify/rag-web-browser",
"compass/crawler-google-places"
])
],
show_tool_calls=True
)

# 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 |

## Developer Resources

- View [Tools](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/apify.py)
- View [Cookbook](https://github.com/agno-agi/agno/blob/main/cookbook/tools/apify_tools.py)

## Resources

- [Apify Actor Documentation](https://docs.apify.com/Actors)
- [Apify Store - Browse available Actors](https://apify.com/store)
- [How to build and monetize an AI agent on Apify](https://blog.apify.com/how-to-build-an-ai-agent/)