socialcrawl/
← All recipes

Rank a subreddit by engagement rate

The computed block is pre-calculated on every post, so ranking is a sort — not a maths exercise.

Python
import os, requests

H = {"x-api-key": os.environ["SOCIALCRAWL_API_KEY"]}
r = requests.get("http://datatrend.nl/v1/reddit/subreddit", params={"name": "programming"}, headers=H)

posts = r.json()["data"]["items"]
posts.sort(key=lambda p: p["post"]["engagement"]["likes"] or 0, reverse=True)

for p in posts[:10]:
    e = p["post"]["engagement"]
    print(f'{e["likes"]:>6} ▲  {e["comments"]:>4} 💬  {p["post"]["content"]["text"][:70]}')
You'll need a key. It takes ten seconds and starts with 100 credits. Get a key