Skip to content

feat: add Apify platform core tools#456

Closed
daveomri wants to merge 27 commits into
strands-agents:mainfrom
apify:feat/strands-core-apify-tools
Closed

feat: add Apify platform core tools#456
daveomri wants to merge 27 commits into
strands-agents:mainfrom
apify:feat/strands-core-apify-tools

Conversation

@daveomri
Copy link
Copy Markdown

@daveomri daveomri commented Apr 20, 2026

This PR adds Apify platform integration as a new tool for Strands Agents (src/strands_tools/apify.py), enabling agents to interact with the Apify Actor and task ecosystem for web scraping and automation tasks.

Six new tools are introduced:

Actor Execution:

  • apify_run_actor: Run any Apify Actor by ID with arbitrary input and return run metadata (run ID, status, dataset ID, timestamps).
  • apify_run_actor_and_get_dataset: Convenience tool that runs an Actor and fetches its default dataset results in a single call.

Task Execution:

  • apify_run_task: Run a saved Apify task by ID with optional input overrides and return run metadata. Tasks are pre-configured Actor setups that can be rerun without redefining inputs.
  • apify_run_task_and_get_dataset: Convenience tool that runs a task and fetches its default dataset results in a single call.

Data Retrieval:

  • apify_get_dataset_items: Fetch items from an existing Apify dataset by ID, with pagination support.
  • apify_scrape_url: Scrape a single URL using the Website Content Crawler Actor and return the page content as markdown.

All tools share a common ApifyToolClient helper class, consistent error handling (with user-friendly messages for 401/404/429 API errors), URL validation, dependency checking, and Rich console output.

All tools require APIFY_API_TOKEN to be set in the environment. The apify-client SDK is added as an optional dependency (pip install strands-agents-tools[apify]).

Files Changed

File Change
src/strands_tools/apify.py New tool module with 6 @tool-decorated functions and ApifyToolClient helper
tests/test_apify.py Comprehensive unit tests (30+ test cases)
docs/apify_tool.md Tool documentation page
pyproject.toml apify optional dependency group (apify-client>=2.5.0,<3.0.0), added to static-analysis and test env features
README.md Tool table entries, usage examples, and environment variable documentation

Related Issues

#457
#458

Documentation PR

strands-agents/docs#769

Type of Change

New Tool

Testing

  • Added comprehensive unit tests in tests/test_apify.py covering all six tools, including:

    • Success paths for Actor runs, task runs, dataset retrieval, and URL scraping
    • Error handling (failed runs, timed-out runs, API exceptions)
    • ApifyApiError mapping (401 auth, 404 not found, 429 rate limit)
    • Missing token validation for every tool entry point
    • Missing dependency (apify-client not installed) fallback for every tool
    • Pagination parameter forwarding
    • URL validation (invalid scheme, missing scheme)
    • Task-specific edge cases (None response from TaskClient.call(), input omission when not provided)
  • Ran hatch run prepare locally to verify no warnings or lint issues.

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • [x ] I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

daveomri and others added 27 commits March 18, 2026 15:20
fix: improve Apify tools docstrings with Apify context
@daveomri
Copy link
Copy Markdown
Author

cc @drobnikj

@afarntrog
Copy link
Copy Markdown

Hi @daveomri, thanks for creating this! We are encouraging the Strands community to vend a tool as package instead of placing it here. Please see the following user guides:

Thanks!

@daveomri daveomri closed this Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants