Skip to main content

The official Python client for the TrendsAGI API.

Project description

TrendsAGI Official Python Client

PyPI Version License: MIT Python Versions

About

Connect your paid social and search workflows to live market signals.

trendsagi is a BYOC-first SDK: TrendsAGI provides intelligence (/api/trends, /api/trends/{id}/ai-insights), and you execute Google/Meta/TikTok/LinkedIn updates from your own infrastructure with runtime credentials.

Plan Notes (API Access)

  • Developer plan includes:
    • 1 API integration connection
    • 100 API calls/day included
    • Overage billing above included daily usage
  • Advantage/Scale unlock higher daily API limits, more keys, and expanded team workflows.

Resources

JavaScript / TypeScript SDK

This repository now also contains the JavaScript/TypeScript SDK package source in:

It ships as the npm package trendsagi, with Python parity method names, BYOC ad executors, and a matching trendsagi scaffold CLI.

Installation

pip install trendsagi

Quick Start (BYOC Execution)

import os
from trendsagi import TrendsAGIClient
from trendsagi.integrations import GoogleAdsExecutor

client = TrendsAGIClient(api_key=os.getenv("TRENDSAGI_API_KEY"))

# 1) Read intelligence
insight = client.get_ai_insights(trend_id=123)
if not insight:
    raise RuntimeError("AI insight not ready yet")

# 2) Execute in your own runtime (credentials stay with you)
google = GoogleAdsExecutor(
    {
        "access_token": os.environ["GOOGLE_ADS_ACCESS_TOKEN"],
        "developer_token": os.environ["GOOGLE_ADS_DEVELOPER_TOKEN"],
    }
)

# 3) Strict mode: fail fast on weak payloads / missing required IDs
google.apply_targeting(
    insight,
    customer_id="1234567890",
    campaign_id="9876543210",
    strict_mode=True,
)

Supported Integrations

  • GoogleAdsExecutor
  • MetaAdsExecutor
  • TikTokAdsExecutor
  • LinkedInAdsExecutor

All integrations support:

  • runtime-supplied credentials
  • deterministic idempotency keys
  • dry-run previews (dry_run=True)
  • strict validation (strict_mode=True)

Core Endpoints Used by Integrations

  • GET /api/trends
  • GET /api/trends/{trend_id}/ai-insights
  • POST /api/trends/{trend_id}/ai-insights/generate
  • GET /api/trends/ai-insights/status/{task_id}

For full request/response contracts and all other endpoints, use the API docs link above.

CLI Scaffolder

# Docker template
trendsagi scaffold --type docker --output ./runner

# Terraform template
trendsagi scaffold --type terraform --output ./infra

Error Handling

from trendsagi import exceptions

try:
    client.get_trends(limit=5)
except exceptions.RateLimitError:
    print("Rate limited; retry with backoff")
except exceptions.AuthenticationError:
    print("Invalid API key")

Project details


Download files

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

Source Distribution

trendsagi-0.8.1.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

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

trendsagi-0.8.1-py3-none-any.whl (30.8 kB view details)

Uploaded Python 3

File details

Details for the file trendsagi-0.8.1.tar.gz.

File metadata

  • Download URL: trendsagi-0.8.1.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for trendsagi-0.8.1.tar.gz
Algorithm Hash digest
SHA256 0df1c55651badb5bf3cd67de28663a88a34aa62e3064f7ee3e8624ac766f1930
MD5 1deaff06370f4511a505e219a86d276f
BLAKE2b-256 bd002d27402584e4cfcc870d42dd4831293b3488dcd26c1707e01bce62f4c494

See more details on using hashes here.

File details

Details for the file trendsagi-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: trendsagi-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 30.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for trendsagi-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8958b29ed0f1ee3d0c9fa2ee3101588eb6207683bf27ddb72be15dc6b4698e29
MD5 f6e52e8753d1e2e06905124f122fe950
BLAKE2b-256 27d4010eb68065d1f5ad53fe362a13f72e1ea1dde831f40897247494d416f166

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page