Skip to main content

anyapi-haystack

Haystack components and tools for AnyAPI: one key, hundreds of data and scraping APIs (Reddit, Instagram, TikTok, YouTube, Google search, web scraping, and more), billed per request in USD with no subscription.

This package is a thin adapter over the official getanyapi SDK. HTTP, auth, retries, pricing, and schema handling belong to that SDK and to the gateway behind it.

Install

pip install anyapi-haystack

Set your key once. Get one at getanyapi.com.

export ANYAPI_API_KEY="..."

Five components, not 363

AnyAPI has hundreds of SKUs. One component per SKU would blow out any agent's context window, so this package exposes the same five that the AnyAPI MCP server does, which together are its proven discovery-then-run loop.

Component Tool name Charges?
AnyAPISearchAPIs anyapi_search_apis no
AnyAPIListAPIs anyapi_list_apis no
AnyAPIGetAPI anyapi_get_api no
AnyAPIRunAPI anyapi_run_api YES
AnyAPIGetBalance anyapi_get_balance no

The loop: search or list to find a SKU, AnyAPIGetAPI to read its strict input schema, then AnyAPIRunAPI. Every input schema is strict, so an unknown field is rejected rather than ignored, and an input built from a description instead of a schema usually fails.

In a pipeline

from haystack import Pipeline
from haystack.components.converters import OutputAdapter
from haystack_integrations.components.connectors.anyapi import AnyAPIRunAPI

pipe = Pipeline()
pipe.add_component("anyapi", AnyAPIRunAPI())
pipe.add_component("titles", OutputAdapter("{{ data.posts | map(attribute='title') | list }}", list))
pipe.connect("anyapi.data", "titles.data")

result = pipe.run({"anyapi": {"slug": "reddit.trending_posts", "input": {"limit": 2}}})
print(result["anyapi"]["cost_usd"], result["titles"]["output"])

AnyAPIRunAPI publishes its billed envelope as separate sockets so a pipeline can wire each part where it belongs: data, found, cost_usd, items, provider, result_id, and error. AnyAPIGetAPI publishes api, plus input_schema (the input to the next step of the loop) and pricing (what you read to bound spend).

Every component also implements run_async on the SDK's async client, and to_dict / from_dict, so a pipeline containing them serializes to YAML with the key kept as a Secret reference rather than a value.

In an agent

from haystack.components.agents import Agent
from haystack.components.generators.chat import OpenAIChatGenerator
from haystack_integrations.tools.anyapi import ANYAPI_INSTRUCTIONS, anyapi_tools

agent = Agent(
    chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"),
    tools=anyapi_tools(),
    system_prompt=ANYAPI_INSTRUCTIONS,
)

anyapi_tools() returns the five as ComponentTools carrying the AnyAPI MCP server's own descriptions. Each is also importable on its own: AnyAPISearchAPIsTool, AnyAPIListAPIsTool, AnyAPIGetAPITool, AnyAPIRunAPITool, AnyAPIGetBalanceTool.

Money

Prices are USD and are never scaled here. The gateway publishes both maxUsd (what one request is billed) and maxPer1kUsd (the same maximum per 1,000 requests); this package reads both off the wire and multiplies nothing. When you show a catalog price to a person, quote maxPer1kUsd and label it /1k req. A per-call charge is reported as cost_usd for that one request.

provider is always AnyAPI. A lane may name a dataset brand or an anonymous source, and that is the only other source identity you will see.

Two deliberate departures from the MCP server

  • There is no quote tool. The MCP server has quote_api, but the published getanyapi SDK exposes no quote method, and adding one would mean hand-rolling an authenticated HTTP call beside the SDK. AnyAPIGetAPI already publishes pricing.from.maxUsd (the most a first-choice run is billed) and pricing.failoverMaxUsd (the ceiling for any run), so spend is still bounded before the call.
  • Search results carry no heavy marker. The gateway's ranked search does not publish one. AnyAPIListAPIs and AnyAPIGetAPI do.

Errors

Every AnyAPI failure is caught at the component boundary and returned on the error socket as {"error": ..., "status": ..., "code": ..., "requestId": ...}, so a failed call gives the agent something recoverable instead of aborting the run. On that path the unknowable sockets are None rather than a fabricated zero. Anything that is not an AnyAPI error propagates.

License

MIT. See the LICENSE file at the root of this repository.

Support

support@getanyapi.com

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anyapi_haystack-0.2.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyapi_haystack-0.2.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file anyapi_haystack-0.2.0.tar.gz.

File metadata

  • Download URL: anyapi_haystack-0.2.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for anyapi_haystack-0.2.0.tar.gz
Algorithm Hash digest
SHA256 031652931175a47b3d3169e86dfb37f8afd1bf7dd822d81e0b0b29875c7bbfba
MD5 06eb8b21b43a74c18f5b98af9f8c8da5
BLAKE2b-256 a97073f075a8d3081e160d4fd36f7f60d688888033cc5f785a6112074f3f2c38

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyapi_haystack-0.2.0.tar.gz:

Publisher: release-anyapi-haystack.yml on getanyapi-com/integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anyapi_haystack-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anyapi_haystack-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 963f705742a0dc2059a0e592b0e4b97ec33da75b6c9119a1bb657ec2bdd61a8a
MD5 0c373257e189e045c65148e3a2f65c8e
BLAKE2b-256 aae4e6d7770191233fb47a5e0e09ec931e69961fd2b75e862eef6f2f2bf70f67

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyapi_haystack-0.2.0-py3-none-any.whl:

Publisher: release-anyapi-haystack.yml on getanyapi-com/integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page