The official Python client for the TrendsAGI API.
Project description
TrendsAGI Official Python Client
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.
Resources
- API Docs: https://trendsagi.com/api-docs
- Endpoint Reference: https://trendsagi.com/api-docs#endpoints
- BYOC Integrations Guide (repo):
INTEGRATIONS_BYOC.md
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
GoogleAdsExecutorMetaAdsExecutorTikTokAdsExecutorLinkedInAdsExecutor
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/trendsGET /api/trends/{trend_id}/ai-insightsPOST /api/trends/{trend_id}/ai-insights/generateGET /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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trendsagi-0.7.0.tar.gz.
File metadata
- Download URL: trendsagi-0.7.0.tar.gz
- Upload date:
- Size: 32.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a4974412234e3ac63dfe0452cc5cbab8875a7af3e763753d56ff7721a876bb0
|
|
| MD5 |
184fb9c3d91f46422413982933c806df
|
|
| BLAKE2b-256 |
0ba18a41e290fb4379ab6b9680075061c11bec8303370751c82710fa7dbb92d7
|
File details
Details for the file trendsagi-0.7.0-py3-none-any.whl.
File metadata
- Download URL: trendsagi-0.7.0-py3-none-any.whl
- Upload date:
- Size: 34.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ed79c6909599da08257cc43aa0b3f789719ee81c5962c5e9638307bcb4a666e
|
|
| MD5 |
4d6f9b9ad3d8faa42e3da61dcbdd98c0
|
|
| BLAKE2b-256 |
2ff87fb1d301fcd212f7bddf93fd69a091988bdd2891bb6d90c7a995cd55f710
|