Build a Social Research Agent with FetchPI: From Keyword to Brief in One Script
A complete minimal research agent: search across platforms, expand authors, summarize with an LLM — built on normalized JSON tools with per-call accounting.
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=research+topic&freshness=default"The shape of the agent
Three tools are enough for a research pass: search (find mentions), profile (expand an author), and comments (read the discussion). Because every platform shares the response shape, the agent's tool schema is three entries, not thirty.
Step 1 — gather mentions across platforms
import os, requests
KEY = os.environ["FETCHPI_API_KEY"]
def search(platform_path, q):
r = requests.get(
f"https://fetchpi.com{platform_path}",
headers={"Authorization": f"Bearer {KEY}"},
params={"q": q, "freshness": "default", "max_age": "900"},
timeout=30,
)
r.raise_for_status()
return r.json()["data"]
mentions = (
search("/v1/reddit/search/posts", "vector databases")
+ search("/v1/x/search/posts", "vector databases")
)
print(len(mentions), "mentions")Step 2 — expand the loudest authors
def profile(platform_path, username):
r = requests.get(
f"https://fetchpi.com{platform_path}/{username}",
headers={"Authorization": f"Bearer {KEY}"},
params={"freshness": "default", "max_age": "3600"},
timeout=30,
)
r.raise_for_status()
return r.json()["data"]
# reddit profiles: /v1/reddit/users/{username}
top = profile("/v1/reddit/users", "spez")Step 3 — hand the structured brief to your LLM
The records are already typed (author, text, created_at, metrics) — serialize the mentions plus the expanded profiles into your prompt and let the model write the brief. Every record carries meta.request_id lineage if a claim needs auditing later. For a runnable starting point see the monitoring demo — it is this loop, live.