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 publishedgetanyapiSDK exposes no quote method, and adding one would mean hand-rolling an authenticated HTTP call beside the SDK.AnyAPIGetAPIalready publishespricing.from.maxUsd(the most a first-choice run is billed) andpricing.failoverMaxUsd(the ceiling for any run), so spend is still bounded before the call. - Search results carry no
heavymarker. The gateway's ranked search does not publish one.AnyAPIListAPIsandAnyAPIGetAPIdo.
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
Metadata
Release files for anyapi-haystack 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| anyapi_haystack-0.2.0.tar.gz | 21.6 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anyapi_haystack-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 38.0 kB
Release files / anyapi_haystack-0.2.0.tar.gz
| Download URL | anyapi_haystack-0.2.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
031652931175a47b3d3169e86dfb37f8afd1bf7dd822d81e0b0b29875c7bbfba
|
|
BLAKE2b-256 checksum How to use checksums |
a97073f075a8d3081e160d4fd36f7f60d688888033cc5f785a6112074f3f2c38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / anyapi_haystack-0.2.0-py3-none-any.whl
| Download URL | anyapi_haystack-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
963f705742a0dc2059a0e592b0e4b97ec33da75b6c9119a1bb657ec2bdd61a8a
|
|
BLAKE2b-256 checksum How to use checksums |
aae4e6d7770191233fb47a5e0e09ec931e69961fd2b75e862eef6f2f2bf70f67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logSecurity for anyapi-haystack 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for anyapi_haystack-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.