Tutorial

How to Build a Reddit Demand Scanner with Recency Filtering

Build a Reddit demand scanner with 24h/7d/30d recency toggles. Filter for recent demand signals only. Python tutorial.

An r/SideProject follow-up asked how to filter Reddit demand signals by recency. Old posts about wanting a product might be outdated -- someone may have already built it. This tutorial adds recency filtering to the demand scanner: only show demand signals from the last 24 hours, 7 days, or 30 days.

Prerequisites

  • Scavio API key
  • Python 3.8+

Walkthrough

Step 1: Search Reddit with sort by new

Use the sort parameter to get recent posts first.

Python
import requests, os
from datetime import datetime, timedelta
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def search_reddit_recent(query, sort='new'):
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=H,
        json={'platform': 'reddit', 'query': query, 'sort': sort}).json()
    return data.get('results', [])

Step 2: Filter by recency window

Filter results to the desired time window.

Python
def filter_by_recency(results, window='7d'):
    windows = {'24h': 1, '7d': 7, '30d': 30}
    days = windows.get(window, 7)
    cutoff = datetime.now() - timedelta(days=days)
    recent = []
    for r in results:
        post_date = r.get('date', '')
        if post_date:
            try:
                dt = datetime.fromisoformat(post_date.replace('Z', '+00:00'))
                if dt.replace(tzinfo=None) >= cutoff:
                    recent.append(r)
            except ValueError:
                continue
    return recent

Step 3: Score demand with recency weighting

Recent posts get higher weight.

Python
def score_with_recency(results):
    scored = []
    now = datetime.now()
    for r in results:
        base_score = r.get('upvotes', 0) + r.get('comments', 0) * 2
        post_date = r.get('date', '')
        if post_date:
            try:
                dt = datetime.fromisoformat(post_date.replace('Z', '+00:00'))
                days_ago = (now - dt.replace(tzinfo=None)).days
                recency_multiplier = max(0.1, 1.0 - (days_ago / 30))
                r['demand_score'] = int(base_score * recency_multiplier)
            except ValueError:
                r['demand_score'] = base_score
        scored.append(r)
    return sorted(scored, key=lambda x: x.get('demand_score', 0), reverse=True)

Step 4: Generate recency-filtered report

Show demand signals by time window.

Python
def demand_report(idea, windows=['24h', '7d', '30d']):
    results = search_reddit_recent(idea)
    for window in windows:
        filtered = filter_by_recency(results, window)
        scored = score_with_recency(filtered)
        print(f'\n--- {window} window ({len(filtered)} posts) ---')
        for r in scored[:5]:
            print(f'  [{r.get("demand_score", 0)}] {r.get("title", "")}')
            print(f'    r/{r.get("subreddit", "")} | {r.get("upvotes", 0)} upvotes')

demand_report('invoice tool for freelancers')

Python Example

Python
import os, requests
from datetime import datetime, timedelta
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def recent_demand(idea, days=7):
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'reddit', 'query': idea, 'sort': 'new'}).json()
    cutoff = datetime.now() - timedelta(days=days)
    recent = [r for r in data.get('results', []) if r.get('date', '') > cutoff.isoformat()]
    print(f'{len(recent)} posts in last {days} days for "{idea}"')
    return recent

JavaScript Example

JavaScript
const res = await fetch('https://api.scavio.dev/api/v1/search', {
  method: 'POST',
  headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
  body: JSON.stringify({platform: 'reddit', query: idea, sort: 'new'})
});
const data = await res.json();
const cutoff = new Date(Date.now() - 7 * 86400000);
const recent = data.results?.filter(r => new Date(r.date) >= cutoff);

Expected Output

JSON
Reddit demand report with 24h/7d/30d windows. Each post has a recency-weighted demand score. Identifies fresh demand signals vs stale ones.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Scavio API key. Python 3.8+. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Build a Reddit demand scanner with 24h/7d/30d recency toggles. Filter for recent demand signals only. Python tutorial.