Skip to main content

trendsfast

The TrendsFast SDK for Python: source-backed market evidence for AI agents. Ask what a brand's customers are stuck on, what is trending in its niche, what competitors post, which videos work and what people search for and AI assistants answer, with every item's source link, observed time and measured signal.

Standard library only. Python 3.9 or newer. MIT.

pip install trendsfast

Quickstart

from trendsfast import TrendsFast

tf = TrendsFast()  # TRENDSFAST_API_KEY, or the key `trendsfast login` stored
print(tf.context()["context"])            # free: the brand products run on
print(tf.quote("niche", "customers"))      # free: 10 credits
result = tf.customers(lookback_hours=168, limit=10)
for item in result["data"]["items"]:
    print(item["current_observation"]["title"], item["entity"]["original_url"])
print(result["result_id"], result["usage"]["credits_charged"])

result["usage"]["credits_charged"] is what the request was charged when it ran, the same on every reread; result["usage"]["this_request_credits"] is what this call charged, 0 when a saved request is replayed, and is also sent as the X-Credits-Charged header. There is no credits_used field.

Get a key by signing in with the CLI (npx -y trendsfast-cli@latest login) or at https://trendsfast.com/dashboard/api-keys. A verified account gets 100 free credits once.

Methods

context(), wallet(), quote(operation, product=None) and history(cursor=None) are free, as are result(id, cursor=None) and recover(request_id). The paid calls are customers() (10 credits), trending() (25), competitors() (30), formats() (20), search() (35), global_trends() (1), niche(description) (3), ask(question) (5), discover(question=None) (5) and outlier(url, handle=None) (5, charged only when the video is found: one TikTok, Instagram or YouTube video against its creator's recent posts; Instagram and YouTube links need handle).

Options are keyword arguments named as the API names them: lookback_hours, observed_from, observed_to, platforms, content_types, limit and the other filters, plus context_id, max_credits and request_id. An unknown option raises TypeError. Products read the brand's context_id for free when you do not pass one; ask and discover take brand=True to answer against it.

Paid calls, safely

  • Every paid call carries a request_id (made for you unless you pass one) and max_credits (the tariff unless you pass one). TrendsFast never charges more than the cap, and never twice for one request ID.
  • Network errors, 5xx and 429 are retried up to three times with the same request ID, honouring Retry-After; other 4xx never are. A still-lost answer is read back once for free; if the outcome is unknown, OutcomeUnconfirmedError is raised and recover(error.request_id) reads it later. It never resends a paid call under a new ID.
  • Errors are typed (AuthRequiredError, InsufficientScopeError, InsufficientCreditsError, CreditQuoteExceedsLimitError, IdempotencyConflictError, ContextNotCurrentError, ProductRequiresContextError, ResultUnavailableError, RateLimitedError, OutcomeUnconfirmedError), all subclasses of TrendsFastError with code, status, request_id, retry_after_seconds and exit_code.

As an agent tool

Wrap one method as a tool. The docstring is what the model reads; the return value is small on purpose. Register it with LangChain's @tool, CrewAI's @tool or your framework's equivalent; nothing here depends on them.

from trendsfast import TrendsFast, TrendsFastError

tf = TrendsFast()


def customer_problems(limit: int = 10) -> str:
    """What are my customers stuck on right now? Returns sourced conversations from Reddit,
    X, Hacker News and GitHub, one per line with its link. Costs 10 credits per call."""
    try:
        result = tf.customers(limit=limit, max_credits=10)
    except TrendsFastError as error:
        return "TrendsFast refused (%s): %s" % (error.code, error)
    lines = []
    for item in result["data"]["items"]:
        observation = item["current_observation"]
        problem = (observation.get("conversation") or {}).get("problem", {}).get("value")
        lines.append("- %s (%s) %s" % (problem or observation["title"], item["entity"]["platform"], item["entity"]["original_url"]))
    return "\n".join(lines) or "No conversations matched; an empty result costs 0 credits."

Configuration

TrendsFast(
    api_key=None,                       # default: TRENDSFAST_API_KEY, then the CLI's stored key
    base_url="https://trendsfast.com",  # https only (http for 127.0.0.1/localhost)
    max_retries=3,
    timeout=30.0,                       # free reads, seconds
    paid_timeout=150.0,                 # paid calls, seconds
)

The key is sent only to the configured origin, never logged or shown in repr, and redirects are not followed. The User-Agent is trendsfast-python/<version>; nothing else is collected.

REST contract: https://trendsfast.com/v3/openapi.json. Docs: https://trendsfast.com/docs.

Metadata

Release files for trendsfast 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trendsfast 0.1.3
File Size Uploaded Provenance Actions
trendsfast-0.1.3.tar.gz 24.4 kB Without provenance Details for trendsfast-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for trendsfast 0.1.3
File Interpreter ABI Platform Actions
trendsfast-0.1.3-py3-none-any.whl Python 3 none any Details for trendsfast-0.1.3-py3-none-any.whl

Total release size: 45.2 kB

Release files / trendsfast-0.1.3.tar.gz

Download URL trendsfast-0.1.3.tar.gz
Size 24.4 kB
Tags Source
SHA-256 checksum
How to use checksums
26afea6c2f1a4de0705cb1df08b0670fbf0cd4fe0439a034125ec975ddc25388
BLAKE2b-256 checksum
How to use checksums
ad8b94566e954d7502dff6c78a642b5a02f73c94b6b307a92fe7325d1ab30e70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / trendsfast-0.1.3-py3-none-any.whl

Download URL trendsfast-0.1.3-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fb2fd0c012da854a0ad0b065648e5aa303eeb0ba6e528a7aed6ce429f4789ae
BLAKE2b-256 checksum
How to use checksums
cf31733d4381e36d99a8dcf00e2f77885d7b84469bf811cfd8f565641b383b8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for trendsfast 0.1.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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