Give a CrewAI agent any Apify Actor

Install crewai[tools] with langchain-apify, set APIFY_API_TOKEN (CrewAI's name for the Apify token) and pass ApifyActorsTool(actor_name="owner/name") in an agent's tools. A task that asks for the data makes the agent call the Actor and work with the records.

Route: Actor tool. Install: pip install 'crewai[tools]' langchain-apify

Working snippets

Each one is run against the current package before the site publishes it (with a stub Apify API, so nothing is billed). Every Actor page has the same snippet for its own Actor and input, under "In an agent framework".

Install: pip install 'crewai[tools]' langchain-apify

Google Maps

# Reads APIFY_API_TOKEN (Apify token) and OPENAI_API_KEY from the environment.
from crewai import Agent, Crew, Task
from crewai_tools import ApifyActorsTool

tool = ApifyActorsTool(actor_name="vexaloom-labs/google-maps-business-lead-finder-with-email")
agent = Agent(
    role="Data researcher",
    goal="Collect records with the Apify Actor and summarise them",
    backstory="You call Apify Actors to get live web data.",
    tools=[tool],
)
task = Task(
    description="Use Google Maps Business Lead Finder with Email & Social Links to get a few records and summarise what came back, with links. Call the tool with this run_input: {\"mode\":\"searchPlaces\",\"searchQueries\":[\"coffee shops in Austin TX\"],\"maxPlacesPerSearch\":3,\"language\":\"en\",\"extractEmailsFromWebsite\":true,\"maxEmailsPerWebsite\":5,\"maxContactPagesPerWebsite\":2,\"onlySaveResults\":\"allPlaces\",\"websiteFilter\":\"allPlaces\",\"skipClosedPlaces\":false}",
    agent=agent,
    expected_output="A short summary of the records with their links.",
)
print(Crew(agents=[agent], tasks=[task]).kickoff())

Good to know

  • CrewAI reads the Apify token from APIFY_API_TOKEN, not APIFY_TOKEN.
  • crewai needs Python 3.10 to 3.13.
  • Put the Actor input in the task description, or let the agent build it from the tool's schema; keep result limits small on the first run.

Actors to start with

Other frameworks

Troubleshooting

Why does the workflow or script stop with HTTP 408?

The synchronous endpoint waits at most 300 seconds. After that it answers 408 while the run keeps going in Apify. Lower the result limit, or start the run asynchronously, wait for it to finish and then read its dataset.

Source: Apify API: run Actor synchronously and get dataset items. This fix on its own page

What do 400, 401, 402 and 403 from the Apify API mean?

Read error.type in the response body. 400 is invalid Actor input. 401 (user-or-token-not-found) means a token reached Apify but it is wrong or revoked. 402 with x402-payment-required means no token reached Apify at all: the n8n credential or the Authorization: Bearer header is missing, and Apify is offering its pay-per-run x402 route for agents instead; any other 402 is an exhausted usage limit on the account that pays for the run. 403 is a token without permission for that Actor or storage.

Source: Apify API: authentication; Apify documentation: agentic payments with x402; Apify API: run Actor synchronously and get dataset items. This fix on its own page

Why does starting an Actor through the API return run information instead of scraped results?

The Run Actor endpoint starts the Actor and immediately returns a Run object without waiting for completion. For results stored in the default dataset, pass the response's defaultDatasetId to Get dataset items; to wait and receive output directly, use the synchronous endpoint for dataset items or a key-value store record.

Source: Apify Run Actor API. This fix on its own page

Why are rows and hidden fields missing from my Apify dataset export?

The clean parameter enables both skipEmpty and skipHidden, removing empty items and fields whose names begin with #. This can produce fewer items than the requested limit; to retain those rows and fields, disable clean and ensure skipEmpty and skipHidden are also disabled.

Source: Apify Get dataset items API. This fix on its own page

Sources