Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MatthewSabia1/SubPirate-Pro/llms.txt
Use this file to discover all available pages before exploring further.
GET /api/analyze/:subreddit
Analyze a subreddit for marketing potential using AI-powered insights. This endpoint performs a comprehensive analysis including rules, moderator activity, content strategy, and generates actionable recommendations.Authentication
Requires active subscription and valid JWT token.Path Parameters
The subreddit name (3-21 characters, alphanumeric and underscores only). Do not include “r/” prefix.
Query Parameters
Admin-only. Force re-analysis even if cached data exists (within 30 days).
Caching Behavior
Analyses are cached for 30 days. If a valid cached analysis exists, it will be returned immediately without consuming quota. Admins can bypass cache with?force=true.
Quota Management
This endpoint uses the analysis quota system:- Cached results don’t count against quota
- Fresh analyses increment the usage counter
- If quota is exceeded, returns 403 with upgrade prompt
- Admin users have unlimited quota
Locking Mechanism
To prevent duplicate analyses, an advisory lock is acquired before fetching:- If lock is available: proceeds with analysis
- If lock is held: waits 5 seconds, polls cache, then retries
- If lock still unavailable: returns 409 “analysis in progress”
Response
Subreddit metadata
Top 25 posts from the past month (title, score, num_comments, created_utc)
AI-generated analysis
Example Request
cURL
Example Response
Error Responses
Invalid subreddit name
Subscription required or quota exceeded
Subreddit not found
Analysis already in progress
Server error or OpenRouter API key not configured
OpenRouter API error or invalid response
Implementation Details
The analysis workflow (fromapi/analyze/[subreddit].js):
- Cache check: Returns cached data if fresh (< 30 days old)
- Quota check: Verifies user hasn’t exceeded monthly limit
- Lock acquisition: Prevents duplicate analyses
- Phase 1 - Reddit data fetch (parallel):
- Subreddit about info
- Rules
- Top posts (all-time for title analysis, monthly for UI)
- Moderator list
- Phase 2 - Moderator enrichment: Fetches activity data for up to 8 mods
- LLM analysis: Sends enriched data to OpenRouter (google/gemini-3-flash-preview)
- Database cache: Stores result in
subredditstable - Quota increment: Increments usage counter (except for admins)
- Lock release: Frees advisory lock
Moderator Activity Tiers
- very_active: Last activity within 7 days
- active: Last activity within 30 days
- dormant: No activity in 30+ days
Content Type Normalization
The endpoint normalizes AI-suggested content types to one of three core types:- text: Self posts, discussions, stories
- link: External URLs, videos
- image: Photos, screenshots, memes
Next Steps
OpenRouter Integration
Learn about the AI model configuration
Subreddit Analysis Feature
User guide for the analysis dashboard