FetchPI
Log in

Guides

Social Media Monitoring with AI Agents: Give Your Agent Structured Public Data

How to wire an LLM agent to public social data safely: normalized JSON tools, per-call billing instead of browser automation, and the request model that keeps agent loops simple.

Last reviewed

Quickstart

Every request needs one header: Authorization: Bearer $FETCHPI_API_KEY. Create a free key in the console and you can replay every snippet on this page as-is.

curl -s -H "Authorization: Bearer $FETCHPI_API_KEY"   "https://fetchpi.com/v1/reddit/search/posts?q=your-brand&freshness=default&max_age=900"

Why agents fail at social data

An agent that drives a headless browser is slow, fragile and unaccountable: layouts change mid-run, and nothing in the trace says what a step cost. An agent that calls a normalized JSON API gets typed observations, deterministic pagination and a per-call audit trail (meta.request_id, meta.billing) it can reason about and report.

The tool surface an agent needs

  • One search tool per platform — same parameters (q, cursor, freshness), same response shape.
  • Identity tools (profile, user posts) to expand a mention into context.
  • The freshness parameter as an explicit agent decision: cache for recall work, live for breaking events.
  • meta.request_id echoed into the agent's own log — every observation is reproducible.

A monitoring loop in twenty lines

import os, requests

KEY = os.environ["FETCHPI_API_KEY"]

def watch(keyword):
    r = requests.get(
        "https://fetchpi.com/v1/reddit/search/posts",
        headers={"Authorization": f"Bearer {KEY}"},
        params={"q": keyword, "freshness": "default", "max_age": "900"},
        timeout=30,
    )
    r.raise_for_status()
    for post in r.json()["data"]:
        yield {
            "platform": post["platform"],
            "author": post["author"].get("name"),
            "title": post.get("title"),
            "engagement": post.get("metrics", {}),
        }

for mention in watch("your-brand"):
    print(mention)  # feed these records to your LLM for triage/scoring

Billing that survives agent loops

Agents loop. Cache-mode reads (freshness=default + max_age) keep the recap runs cheap, meta.billing.cache_hit tells you when a loop iteration was free-ish, and failed upstream calls release their holds — an agent stuck on an outage does not burn budget.