Modernity API

Real-time streaming access to 18+ live data sources. Connect via SSE for continuous streaming, or query the knowledge base for structured responses.

Endpoints

Streaming: https://modernity-production.up.railway.app/v1/live
API: https://api.modernity.live/v1

Get Your API Key

Generate an API key instantly — no signup required.

Generate API Key

Enter your email to get an API key.

Quick Start

Make your first API call:

Shell
curl -X POST https://api.modernity.live/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"topic": "AI news", "limit": 5}'

Live Stream (SSE)

Connect to the real-time firehose via Server-Sent Events. All 18+ sources stream continuously.

Endpoint
GET https://api.modernity.live/v1/live?api_key=YOUR_API_KEY

JavaScript Example

JavaScript
const eventSource = new EventSource(
    'https://api.modernity.live/v1/live?api_key=YOUR_API_KEY'
);

eventSource.addEventListener('item', (e) => {
    const data = JSON.parse(e.data);
    console.log(data.source, data.message);
});

eventSource.addEventListener('connected', (e) => {
    console.log('Connected to stream');
});

Python SSE Example

Python
import requests

url = "https://api.modernity.live/v1/live?api_key=YOUR_API_KEY"
with requests.get(url, stream=True) as r:
    for line in r.iter_lines():
        if line:
            print(line.decode())

SSE Event Types

Event Description
connected Initial connection confirmation with tier info
item Level I (WorldStream) — raw data item from any source
level_ii Level II (SectorStream) — AI-generated sector summary. Pro tier and above.
level_iii Level III (KnowledgeStream) — AI cross-sector synthesis. Growth tier and above.
tier_info Tier details, limits, and monthly usage stats
ping Keepalive ping (every 15s)

Three-Level Data Architecture

The live stream delivers data across three processing levels:

Level Name Description Min Tier
I WorldStream Raw firehose from 18+ sources — every event as it happens Developer (Free)
II SectorStream AI-generated sector summaries — concise, real-time updates per category (finance, crypto, social, etc.) Pro ($99/mo)
III KnowledgeStream AI cross-sector synthesis — connects patterns across all sectors into intelligence briefings Growth ($299+/mo)

Item Payload

JSON
{
  "source": "bluesky",
  "message": "Post content here...",
  "timestamp": 1738678425,
  "metadata": { ... }
}

Recent Messages

Fetch recent messages from a 20,000-item ring buffer with pagination, filtering, and time-range queries. Results are returned newest-first.

HTTP
GET /v1/recent?api_key=YOUR_KEY&limit=100&offset=0
Parameter Type Description
api_key string Required. Your API key
limit integer Messages per page (1–500, default 100)
offset integer Skip first N items for pagination (default 0)
source string Filter by source (e.g. bluesky, level_ii, coingecko)
category string Filter by category (e.g. crypto, news, weather)
since integer Unix timestamp — only messages at or after this time
before integer Unix timestamp — only messages before this time

Pagination Example

Python
import requests

# Page 1: newest 100 messages
r1 = requests.get("https://api.modernity.live/v1/recent", params={
    "api_key": API_KEY, "limit": 100, "offset": 0
}).json()

# Page 2: next 100
r2 = requests.get("https://api.modernity.live/v1/recent", params={
    "api_key": API_KEY, "limit": 100, "offset": 100
}).json()

print(f"Page 1: {r1['count']} msgs, has_more: {r1['has_more']}")
print(f"Page 2: {r2['count']} msgs, total in buffer: {r2['total']}")

Time-Range + Source Filter

Shell
# Get all crypto news from the last 5 minutes
FIVE_MIN_AGO=$(date -v-5M +%s)  # macOS
curl "https://api.modernity.live/v1/recent?api_key=YOUR_KEY&category=crypto&since=$FIVE_MIN_AGO&limit=200"

Response Format

JSON
{
  "count": 100,
  "total": 12847,
  "offset": 0,
  "limit": 100,
  "has_more": true,
  "messages": [
    {
      "source": "bluesky",
      "schema": "social",
      "doc_id": "bsky_abc123",
      "title": "Post title...",
      "message": "Post content...",
      "timestamp": 1738678425,
      "category": "social"
    }
  ]
}

Level II and Level III have dedicated server-side buffers (100 and 50 items respectively), so they are always available via source=level_ii regardless of raw firehose volume.

Buffer Snapshot

Get a metadata overview of the entire buffer without downloading message bodies. Returns per-source and per-category counts, time range, and throughput stats. Use this to understand what's available before making targeted /v1/recent calls.

HTTP
GET /v1/snapshot?api_key=YOUR_KEY

Response

JSON
{
  "buffer_capacity": 20000,
  "buffer_used": 14832,
  "oldest_timestamp": 1738670000,
  "newest_timestamp": 1738678425,
  "time_span_seconds": 8425,
  "sources": [
    { "source": "bluesky", "count": 4200, "latest_timestamp": 1738678420 },
    { "source": "coingecko", "count": 980, "latest_timestamp": 1738678415 }
  ],
  "categories": [
    { "category": "social", "count": 5100 },
    { "category": "crypto", "count": 2400 }
  ],
  "messages_per_second": 18.4,
  "uptime_seconds": 86400
}

Message Counts

Get aggregated message counts grouped by source, category, or both. Supports optional time-range filtering. Ideal for dashboards and analytics without transferring message bodies.

HTTP
GET /v1/counts?api_key=YOUR_KEY&group_by=source
Parameter Type Description
api_key string Required. Your API key
group_by string source (default), category, or both
since integer Unix timestamp — only count messages at or after this time
before integer Unix timestamp — only count messages before this time

Response (group_by=both)

JSON
{
  "group_by": "both",
  "total": 14832,
  "counts": {
    "bluesky": { "social": 4200 },
    "coingecko": { "crypto": 980 },
    "currents": { "news": 1420, "tech": 630 }
  }
}

Live Source Activity

Get real-time health and activity stats for every connected data source. Shows which sources are actively streaming, their message counts, and throughput rates.

HTTP
GET /v1/sources/live?api_key=YOUR_KEY

Response

JSON
{
  "sources": [
    { "source": "bluesky", "count": 4200, "latest_timestamp": 1738678420 }
  ],
  "health": {
    "bluesky": { "total": 128400, "recent_60s": 42, "rate_per_sec": 0.7 }
  }
}

Query Endpoint

Query the knowledge base with natural language.

Python Example

Python
import requests

response = requests.post(
    "https://api.modernity.live/v1/query",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "topic": "AI developments",
        "limit": 10
    }
)

data = response.json()
print(f"Latency: {data['latency_ms']}ms")

Query Endpoint

HTTP
POST https://api.modernity.live/v1/query

Parameters

Parameter Type Required Description
topic string Yes Natural language query
timeframe string No 60s, 5m, 1h, 24h. Default: 60s
sources array No Filter by specific sources
limit integer No Max results (1-100). Default: 10

Response Format

JSON
{
  "id": "qry_10e4030bbc7f2490",
  "latency_ms": 319,
  "freshness_seconds": 42,
  "sources_queried": 3,
  "results": [
    {
      "title": "AI News Wrap-Up...",
      "source": "bluesky",
      "age_seconds": 42,
      "relevance": 0.9189,
      "summary": "..."
    }
  ]
}

Error Handling

Code Description
400 Invalid request parameters
401 Invalid or missing API key
429 Rate limit exceeded
500 Internal server error

MCP — Connect to Cursor & Claude

MCP (Model Context Protocol) lets AI assistants like Cursor and Claude call Modernity tools directly. Ask questions about the world and get real-time answers from 99+ sources — or ask it to help you build apps with the Modernity API. No SDK to install, no docs to read. Just connect and ask.

Prerequisites

Node.js 18+ is required. Check with node -v. Install from nodejs.org if needed.

Cursor (Recommended: Settings UI)

  1. Open Cursor Settings — press Cmd+Shift+J (Mac) or Ctrl+Shift+J (Windows/Linux)
  2. Scroll to the MCP section, click + Add new MCP server
  3. Fill in:
    • Name: Modernity
    • Type: command
    • Command: npx -y modernity-mcp
  4. Under Environment Variables, add: MODERNITY_API_KEY = your API key
  5. Save. A green dot appears when connected.

Cursor (Alternative: JSON file)

Create or edit .cursor/mcp.json in any project root:

.cursor/mcp.json
{
  "mcpServers": {
    "modernity": {
      "command": "npx",
      "args": ["-y", "modernity-mcp"],
      "env": {
        "MODERNITY_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

Claude Desktop

  1. Open your Claude config file:
    • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    Create the file if it doesn't exist.
  2. Paste the following (or add the "modernity" block to your existing mcpServers):
claude_desktop_config.json
{
  "mcpServers": {
    "modernity": {
      "command": "npx",
      "args": ["-y", "modernity-mcp"],
      "env": {
        "MODERNITY_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}
  1. Restart Claude Desktop. A hammer icon appears in the chat input — click it to confirm "modernity" is connected.

Verify Your Setup

Run this in your terminal to test connectivity before configuring your editor:

Terminal
npx -y modernity-mcp --key=YOUR_API_KEY --test

Expected output:

Output
Success! API is online and your key is valid.

Troubleshooting

Error Fix
command not found: npx Install Node.js 18+
MODERNITY_API_KEY... is required Pass your key via --key= or set the environment variable
Your API key is invalid Regenerate at modernity.live/dashboard
Rate limit exceeded Wait before retrying; check your tier limits in the dashboard
Green dot not appearing in Cursor Toggle the server off and on again, or fully restart Cursor
Hammer icon missing in Claude Ensure the JSON is valid (no trailing commas) and restart Claude Desktop

Available MCP Tools

Once connected, your AI assistant has access to two categories of tools:

Live Data Tools

Ask questions and get real-time answers from 99+ sources.

Tool Description
query_topic Semantic search across all sources. Ask about any topic and get ranked, relevant results.
get_recent_data Fetch the latest messages from the live stream buffer. Filter by source or category.
multi_schema_query Query across multiple data types (documents, financial tickers, news articles, geo alerts) simultaneously.
analyze_topic AI-powered topic analysis — get recommended data types, sources, and search terms.
get_sources List all 99+ available data sources with categories and update frequencies.
get_stream_stats Live stream health: status, connected clients, per-source throughput.
get_key_info Check your API key tier, usage, rate limits, and remaining quota.
check_health Verify the Modernity API is online and healthy.
get_pricing Get all pricing tiers and features.

Developer / Builder Tools

Build apps with the Modernity API — generate code, get docs, and start new projects.

Tool Description
get_api_docs Complete API endpoint documentation with request/response schemas, parameters, and error codes. Ask for a specific endpoint or the full reference.
generate_integration Generate ready-to-use code in Python, JavaScript, TypeScript, or curl — with authentication, error handling, and rate-limit retry logic built in.
get_quickstart Step-by-step framework integration guides for Next.js, Flask, FastAPI, Django, Express, React, Cloudflare Workers, and more.

Things to Ask

Just ask naturally — your AI assistant will call the right Modernity tools automatically.

Ask anything
# Get a pulse on the world
"What's going on with the world?"
"What are people talking about online right now?"
"Give me a snapshot of what's happening today"

# Dive into specific topics
"Any earthquakes in the last hour?"
"What's happening in AI right now?"
"Get the latest crypto prices"
"What are the top Hacker News stories?"
"Are there any severe weather alerts in the US?"

# Research and analysis
"Analyze the topic 'semiconductor supply chain'"
"What's the latest research on LLMs from arXiv?"
"Search for SEC filings related to AI companies"

# Build with Modernity
"Help me integrate Modernity into my Next.js app"
"Generate Python code to monitor crypto prices"
"Show me the API docs for the /v1/query endpoint"
"What error codes does the Modernity API return?"

Python SDK

Shell
pip install modernity
Python
from modernity import Modernity

client = Modernity(api_key="your-api-key")
response = client.query(topic="bitcoin price")

Node.js SDK

Shell
npm install @modernity/sdk
TypeScript
import { Modernity } from '@modernity/sdk';

const client = new Modernity({ apiKey: process.env.MODERNITY_API_KEY });
const response = await client.query({ topic: 'NVDA earnings' });

cURL Examples

Shell
# Recent messages (paginated, newest-first)
curl "https://api.modernity.live/v1/recent?api_key=YOUR_KEY&limit=100&offset=0"

# Filter by source + time range (last 10 min)
curl "https://api.modernity.live/v1/recent?api_key=YOUR_KEY&source=bluesky&since=$(date -v-10M +%s)"

# Buffer snapshot (no message bodies)
curl "https://api.modernity.live/v1/snapshot?api_key=YOUR_KEY"

# Message counts grouped by source
curl "https://api.modernity.live/v1/counts?api_key=YOUR_KEY&group_by=source"

# Live source health
curl "https://api.modernity.live/v1/sources/live?api_key=YOUR_KEY"

# Query (semantic search)
curl -X POST https://api.modernity.live/v1/query \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"topic": "bitcoin price", "limit": 5}'

# Generate API Key
curl -X POST https://api.modernity.live/v1/keys \
  -H "Content-Type: application/json" \
  -d '{"email": "[email protected]"}'

Available Sources

18+ data sources streaming live data continuously.

Live Streaming

Source Category Description
bluesky Social Bluesky Jetstream firehose
mastodon Social Mastodon federated public stream
wikimedia News Wikipedia recent changes
mempool Crypto Bitcoin mempool blocks
level_ii AI SectorStream — AI sector summaries (Pro+)
level_iii AI KnowledgeStream — AI cross-sector synthesis (Growth+)

Frequent Polling (10-60s)

Source Category Description
opensky Aviation Live aircraft positions
coingecko Crypto Top cryptocurrency prices
kalshi Finance Prediction market prices
github Tech Public GitHub events
hackernews Tech Hacker News stories
drand Crypto Randomness beacon
iss Space ISS location tracking
wttr Geo Global city weather (80+ cities)

Moderate Polling (1-15 min)

Source Category Description
gdelt News Global news in 65 languages
usgs Geo Earthquake alerts (M2.5+)
cisa Security CISA security advisories
urlhaus Security Malware URL database

Rate Limits & Tier Access

Monthly Call Limits & Age of Information

Free: 200 calls/mo — 5 req/min — Full access to all 99+ sources — REST API
Starter ($49/mo): 15k calls/mo — 30 req/min — Full access to all 99+ sources — REST API
Pro ($99/mo): 100k calls/mo — 250 req/min — Full access to all 99+ sources — REST API
Growth ($299/mo): 1M calls/mo — 10k req/min — Full access to all 99+ sources — REST + SSE streaming
Contact us for enterprise features (multi-connection SSE, higher rate limits, custom data sources).

Feature Access by Tier

Feature Free Starter Pro Growth
Monthly calls 200 15,000 100,000 1,000,000
Rate limit 5/min 30/min 250/min 10,000/min
Data sources All 99+ All 99+ All 99+ All 99+
REST API
SSE Streaming
How limits are enforced

Monthly limits are enforced server-side. When you hit your limit, REST calls return HTTP 429 and SSE streams send an error event. All calls count toward your monthly allowance. Limits reset on the 1st of each month (UTC).

All tiers get full access to all 99+ data sources. Only rate limits and SSE access differ. SSE streaming (/v1/live) requires Growth tier or higher. Contact us for enterprise features (multi-connection SSE, higher rate limits, custom data sources).