Simple one-time search when users test their brand - no monitoring needed
✅ User enters brand name in your tool
✅ Tool searches Reddit RIGHT NOW
✅ Shows recent posts/mentions
✅ Done - no ongoing monitoring
FREE - No API key needed!
$50/mo - 5,000 searches
✅ Start with this - it's FREE and works great for most use cases!
// /app/api/reddit-search/route.ts
import { NextRequest, NextResponse } from 'next/server';
export async function POST(request: NextRequest) {
try {
const { brandName } = await request.json();
if (!brandName) {
return NextResponse.json({ error: 'Brand name required' }, { status: 400 });
}
// Search Reddit using public JSON API
const response = await fetch(
`https://www.reddit.com/search.json?q=${encodeURIComponent(brandName)}&limit=25&sort=new`,
{
headers: {
'User-Agent': 'AI-Brand-Defense/1.0'
}
}
);
if (!response.ok) {
throw new Error('Reddit search failed');
}
const data = await response.json();
const posts = data.data.children;
// Format results
const mentions = posts.map((post: any) => {
const p = post.data;
return {
title: p.title,
subreddit: p.subreddit,
author: p.author,
score: p.score,
numComments: p.num_comments,
url: `https://reddit.com${p.permalink}`,
createdAt: new Date(p.created_utc * 1000).toISOString(),
preview: p.selftext?.substring(0, 200) || '',
sentiment: analyzeSentiment(p.title + ' ' + (p.selftext || '')),
riskLevel: assessRisk(p.title, p.selftext || '', p.score)
};
});
return NextResponse.json({
success: true,
brandName,
totalFound: mentions.length,
mentions: mentions,
summary: {
highRisk: mentions.filter((m: any) => m.riskLevel === 'HIGH').length,
negative: mentions.filter((m: any) => m.sentiment === 'NEGATIVE').length,
avgScore: mentions.reduce((sum: number, m: any) => sum + m.score, 0) / mentions.length || 0
}
});
} catch (error: any) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}
function analyzeSentiment(text: string): 'POSITIVE' | 'NEGATIVE' | 'NEUTRAL' {
const lower = text.toLowerCase();
const negative = ['scam', 'fake', 'fraud', 'terrible', 'worst', 'avoid', 'bad'];
const positive = ['great', 'excellent', 'amazing', 'best', 'love', 'recommend'];
const negCount = negative.filter(w => lower.includes(w)).length;
const posCount = positive.filter(w => lower.includes(w)).length;
if (negCount > posCount) return 'NEGATIVE';
if (posCount > negCount) return 'POSITIVE';
return 'NEUTRAL';
}
function assessRisk(title: string, text: string, score: number): 'HIGH' | 'MEDIUM' | 'LOW' {
const combined = (title + ' ' + text).toLowerCase();
const highRisk = ['investigation', 'lawsuit', 'scam', 'fraud', 'exposed'];
const hasRiskKeyword = highRisk.some(k => combined.includes(k));
if (hasRiskKeyword && score > 100) return 'HIGH';
if (hasRiskKeyword || score > 100) return 'MEDIUM';
return 'LOW';
}
Reddit allows ~60 requests per minute. Fine for most tools. If you hit limits, add a simple proxy or upgrade to SerpAPI.
Use if: Reddit public JSON hits rate limits or you want more reliability
SERPAPI_KEY=your_key// /app/api/reddit-search/route.ts (SerpAPI version)
import { NextRequest, NextResponse } from 'next/server';
export async function POST(request: NextRequest) {
try {
const { brandName } = await request.json();
// Search Reddit via Google using SerpAPI
const response = await fetch(
`https://serpapi.com/search?` +
`engine=google&` +
`q=site:reddit.com+${encodeURIComponent(brandName)}&` +
`num=20&` +
`api_key=${process.env.SERPAPI_KEY}`
);
const data = await response.json();
const results = data.organic_results || [];
const mentions = results.map((result: any) => ({
title: result.title,
url: result.link,
snippet: result.snippet,
date: result.date || 'Recent',
source: extractSubreddit(result.link)
}));
return NextResponse.json({
success: true,
brandName,
mentions
});
} catch (error: any) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}
function extractSubreddit(url: string): string {
const match = url.match(/reddit\.com\/r\/([^\/]+)/);
return match ? match[1] : 'reddit';
}
| Feature | Reddit JSON | SerpAPI |
|---|---|---|
| 💰 Cost | FREE | $50/mo |
| 🔑 API Key | Not needed | Required |
| ⏱️ Setup | 30 seconds | 2 minutes |
| 📊 Results | 25 per search | 20 per search |
| ⚡ Speed | Fast | Fast |
| 🚦 Rate Limit | 60/min | High |
| ✅ Best For | Most users | High volume |
Create: /app/api/reddit-search/route.ts
Use "Reddit Public JSON" code above (it's free!)
Add button: "Search Reddit" → calls /api/reddit-search
Deploy to Vercel → Test with brand name → Done!
✅ Start with Reddit Public JSON (FREE)
Works great for 99% of use cases. Only upgrade to SerpAPI if you hit rate limits.