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.

Three 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.
  • Search requires a query. AnyAPISearchAPIs has no browse-everything mode; use AnyAPIListAPIs for that.

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.1.0.tar.gz (21.0 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.1.0-py3-none-any.whl (16.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: anyapi_haystack-0.1.0.tar.gz
  • Upload date:
  • Size: 21.0 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.1.0.tar.gz
Algorithm Hash digest
SHA256 2dbf786f03a4c492e1c5851c4f79a072a2358c025067490ef2d0cdd6a4f82e19
MD5 5ffa878c8c192e475f20dba8e8d80415
BLAKE2b-256 a05ecda05789927e3f3dea53d25cedc1c3597efef987773882b4149690239c72

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyapi_haystack-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for anyapi_haystack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba76213a40ae2228330cc49e3c88ebac363c9ecfcfd47ea6953d3ad3c9f3ba5e
MD5 f70dc852dea908cd4abc683d84c16aa4
BLAKE2b-256 f62a693756140efc617352563a5f446c52c1ff6c0040176510b8145697947411

See more details on using hashes here.

Provenance

The following attestation bundles were made for anyapi_haystack-0.1.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

0.2.0

2 files

This release

0.1.0 This release

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