Apify

Use Apify actors as agent tools for web data extraction.

Prerequisites

Install the required dependencies:

uv pip install -U agno apify-client openai requests

Export your Apify and OpenAI API keys:

export APIFY_API_TOKEN=your_apify_api_token
export OPENAI_API_KEY=your_openai_api_key

from agno.agent import Agent
from agno.tools.apify import ApifyTools
# Apify Tools Demonstration Script

# Create an Apify Tools agent with versatile capabilities
agent = Agent(
    name="Web Insights Explorer",
    instructions=[
        "You are a sophisticated web research assistant capable of extracting insights from various online sources. "
        "Use the available tools for your tasks to gather accurate, well-structured information."
    ],
    tools=[
        ApifyTools(
            actors=[
                "apify/rag-web-browser",
                "compass/crawler-google-places",
                "clockworks/free-tiktok-scraper",
            ]
        )
    ],
    markdown=True,
)


def demonstrate_tools():
    print("Apify Tools Exploration")

    # RAG Web Search Demonstrations
    print("\n1.1 RAG Web Search Scenarios:")
    prompt = "Research the latest AI ethics guidelines from top tech companies. Compile a summary from at least 3 different sources comparing their approaches using RAG Web Browser."
    agent.print_response(prompt, show_full_reasoning=True)

    print("\n1.2 RAG Web Search Scenarios:")
    prompt = "Carefully extract the key introduction details from https://docs.agno.com/introduction"  #  Extract content from specific website
    agent.print_response(prompt)

    # Google Places Demonstration
    print("\n2. Google Places Crawler:")
    prompt = "Find the top 5 highest-rated coffee shops in San Francisco with detailed information about each location"
    agent.print_response(prompt)

    # Tiktok Scraper Demonstration
    print("\n3. Tiktok Profile Analysis:")
    prompt = "Analyze two profiles on Tiktok that lately added #AI (hashtag AI), extracting their statistics and recent content trends"
    agent.print_response(prompt)


# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    demonstrate_tools()

Actor registration fetches each Actor's current build and input schema when the toolkit is constructed. Use Actors available to your Apify account and inspect registration errors before running the agent; a failed registration leaves that Actor out of the tool list. Running the agent can start real Actor jobs.

Run the Example

Save the code above as apify_tools.py in your activated environment.

python apify_tools.py

For details, see Apify cookbook.