Politics
Sports
Entertainment
Business
Pop Culture
Pipeline Run Audit Log
0
Total Runs (7d)
0
Successful
0
Failed
0
Total API Calls
API Testing Interface
Select Endpoint
Request
Response
Select an endpoint and click "Send Request"
API Documentation
Overview
The Political Trends Tracking API provides daily-tracked, graphable metrics for political entities including politicians, bills, movements, and ideas. All data is accurate and sourced from real news and social media APIs.
Base URL
https://your-domain.com
Endpoints
GET /entities
List all entities with optional filtering. Returns entity details including optimized thumbnail URLs.
active(boolean, optional) - Filter by active statuscategory(string, optional) - Filter by category (politics, sports, entertainment)
id- Entity IDname- Entity namecategory- Category (politics, sports, entertainment)entity_type- Type (politician, team, movie, etc.)thumbnail_url- URL to 80x80px optimized thumbnail image (null if not available)image_url- URL to full-size imagedescription- Entity description
GET /api/thumbnails/{entity_id}
Get optimized 80x80px thumbnail image for an entity. Thumbnails are square, center-cropped JPEGs optimized for fast loading in table views.
entity_id(integer, required) - Entity ID
JPEG image (80x80px, optimized for web)
Cache Headers:Images are cached for 24 hours (Cache-Control: public, max-age=86400)
Usage in External Apps:<img src="http://localhost:5000/api/thumbnails/5" alt="Entity" style="border-radius: 8px; width: 40px; height: 40px;">
POST /entities
Create a new political entity.
{
"name": "Entity Name",
"entity_type": "politician|bill|movement|idea",
"aliases": ["Alias 1"],
"tags": ["tag1"],
"active": true
}
GET /metrics
Get daily metrics with flexible filtering.
entity_id(integer, optional) - Filter by entity IDentity_type(string, optional) - Filter by entity typemetric(string, optional) - Filter by metric namefrom(date, optional) - Start date (YYYY-MM-DD)to(date, optional) - End date (YYYY-MM-DD)
GET /compare
Compare entities by a specific metric on a given date.
entity_type(string, required) - Entity type to comparemetric(string, required) - Metric namedate(date, required) - Date for comparison (YYYY-MM-DD)limit(integer, optional) - Number of results (default: 10)
GET /sparkline
Get time-series data for charting.
entity_id(integer, required) - Entity IDmetric(string, required) - Metric namedays(integer, optional) - Number of days (default: 30)
GET /inbox
Get auto-discovered entity candidates from the inbox queue.
- None - Returns all inbox candidates sorted by mention count
Array of candidate entities with mention counts and approval status.
POST /run-pipeline
Manually trigger the daily data ingestion pipeline.
None - No parameters required
Response:{
"status": "success",
"date": "2025-11-04",
"message": "Pipeline ran successfully for 2025-11-04"
}
Behavior:
Fetches data from NewsAPI and Reddit, normalizes metrics, auto-discovers new entities, and updates the database with today's metrics.
Metric Names
mentions_news- Number of news article mentionsmentions_social- Number of social media mentionssentiment- Sentiment score (-1 to 1)share_of_voice- Percentage of total mentionsz_score- Standardized scoredelta_prev- Change from previous daydelta_base- Change from baseline
Use with Claude & AI Agents
This API is designed to be easily consumable by AI agents. Key features:
- RESTful Design - Standard HTTP methods and JSON responses
- Consistent Formatting - All dates in YYYY-MM-DD, all numbers as floats
- No Authentication Required - Easy integration for prototyping
- Error Messages - Clear, actionable error responses
Code Snippets
Python
import requests
# Get all entities with thumbnails
response = requests.get('http://localhost:5000/entities?category=politics')
entities = response.json()
# Display entity names and thumbnails
for entity in entities[:5]:
print(f"{entity['name']}: {entity['thumbnail_url']}")
# Get metrics for specific entity
params = {
'entity_id': 1,
'metric': 'mentions_news',
'from': '2025-11-01',
'to': '2025-11-04'
}
response = requests.get('http://localhost:5000/metrics', params=params)
metrics = response.json()
# Get sparkline data
params = {
'entity_id': 1,
'metric': 'mentions_news',
'days': 30
}
response = requests.get('http://localhost:5000/sparkline', params=params)
sparkline = response.json()
JavaScript / Node.js
// Get all entities
const entities = await fetch('http://localhost:5000/entities')
.then(r => r.json());
// Get metrics for specific entity
const params = new URLSearchParams({
entity_id: 1,
metric: 'mentions_news',
from: '2025-11-01',
to: '2025-11-04'
});
const metrics = await fetch(`http://localhost:5000/metrics?${params}`)
.then(r => r.json());
// Get sparkline data
const sparklineParams = new URLSearchParams({
entity_id: 1,
metric: 'mentions_news',
days: 30
});
const sparkline = await fetch(`http://localhost:5000/sparkline?${sparklineParams}`)
.then(r => r.json());
cURL
# Get all entities curl http://localhost:5000/entities # Get metrics with filters curl "http://localhost:5000/metrics?entity_id=1&metric=mentions_news&from=2025-11-01&to=2025-11-04" # Compare entities curl "http://localhost:5000/compare?entity_type=politician&metric=mentions_news&date=2025-11-04&limit=10" # Run daily pipeline curl -X POST http://localhost:5000/run-pipeline
Claude / AI Agent Integration
// MCP Server Implementation (TypeScript)
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const API_BASE = "http://localhost:5000";
const server = new Server({
name: "political-trends",
version: "1.0.0"
}, {
capabilities: {
tools: {}
}
});
// Tool: Get entity metrics
server.setRequestHandler("tools/list", async () => ({
tools: [{
name: "get_political_trends",
description: "Get political entity metrics and trends",
inputSchema: {
type: "object",
properties: {
entity_id: { type: "number" },
metric: {
type: "string",
enum: ["mentions_news", "mentions_social", "sentiment"]
},
days: { type: "number", default: 30 }
},
required: ["entity_id", "metric"]
}
},
{
name: "compare_entities",
description: "Compare multiple entities by metric",
inputSchema: {
type: "object",
properties: {
entity_type: { type: "string" },
metric: { type: "string" },
date: { type: "string" },
limit: { type: "number", default: 10 }
},
required: ["entity_type", "metric", "date"]
}
}]
}));
server.setRequestHandler("tools/call", async (request) => {
if (request.params.name === "get_political_trends") {
const { entity_id, metric, days = 30 } = request.params.arguments;
const url = `${API_BASE}/sparkline?entity_id=${entity_id}&metric=${metric}&days=${days}`;
const response = await fetch(url);
return { content: [{ type: "text", text: JSON.stringify(await response.json()) }] };
}
if (request.params.name === "compare_entities") {
const { entity_type, metric, date, limit = 10 } = request.params.arguments;
const url = `${API_BASE}/compare?entity_type=${entity_type}&metric=${metric}&date=${date}&limit=${limit}`;
const response = await fetch(url);
return { content: [{ type: "text", text: JSON.stringify(await response.json()) }] };
}
});
// Start server
const transport = new StdioServerTransport();
await server.connect(transport);