Home · Recipes · Python

Stack Overflow reputation to a CSV, one row a day

Each run adds one dated row with a Stack Overflow user's name and reputation to reputation.csv. Schedule it once a day and the file becomes a reputation history.

tested Run for real on 19 November 2026 against https://api.foxapis.com (Python 3.14 with requests 2.34, Node 20). The code below is the file that ran; the output is what it printed.

What you need

The code

Save as so_rep_log.py

"""Log a Stack Overflow user's reputation to a CSV, one row per run. Run it once a day with cron or Task Scheduler. 1 credit per run (as reported by the API on 19 Nov 2026)."""
import csv, datetime, os, requests

KEY = os.environ["FOXAPIS_KEY"]            # your FoxAPIs key; never paste it into the file
USER_ID = os.environ.get("SO_USER_ID", "22656")
r = requests.post("https://api.foxapis.com/v1/developer/stackoverflow/user", headers={"Authorization": f"Bearer {KEY}"}, json={"user_id": USER_ID}, timeout=60)
r.raise_for_status()
d = r.json()
if d.get("errors"):
    raise SystemExit(f"FoxAPIs said: {d['errors'][0]}")
new = not os.path.exists("reputation.csv")
with open("reputation.csv", "a", newline="", encoding="utf-8") as f:
    w = csv.writer(f)
    if new:
        w.writerow(["date", "user", "reputation", "credits"])
    w.writerow([datetime.date.today().isoformat(), d["display_name"], d["reputation"], d.get("credits_used")])
print("logged", d["display_name"], d["reputation"])

Run it

  1. Put your key in an environment variable: export FOXAPIS_KEY=your-key (PowerShell: $env:FOXAPIS_KEY = "your-key").
  2. Set the user: export SO_USER_ID=22656 (or leave it for the example user).
  3. Run python so_rep_log.py once, then schedule it daily.

Input used in the test

SO_USER_ID=22656

What it printed and wrote (19 November 2026)

logged Jon Skeet 1530553

reputation.csv:
date,user,reputation,credits
2026-11-19,Jon Skeet,1530553,1

What a run costs

1 credit per run. fact: credits the API reported

That is about $0.01 per run on the Builder plan. Calculated by us: plan price divided by its credits.Formula Plans and credits: pricing.

Official docs, read 19 November 2026

Common questions

How much does a year of daily rows cost?

365 runs of 1 credit is 365 credits, which fits inside the smallest paid plan's monthly credits many times over: see the price line above.

Can I track many users?

Yes: loop over a list of numbers; each user is one call and one credit.

Start free: get a key   More code samples · All recipes

How we calculate

Data: the FoxAPIs catalog and plans, read 19 November 2026. Every other figure on this page is copied from the record, not calculated by us.

Run this free, then pay per call

Free to start: 100 credits, no card. Then from $10. Credits you buy never expire. Use them at your own pace. Get my free key

One call costs 1 credit. That is $7.96 per 1,000 calls on the Production plan and $9.80 on Builder (plan price divided by its monthly credits). The Free plan gives 100 credits a month with no card.

Run this freeBuy credits

Building an AI agent?

See the MCP server