Home · Recipes · Python

GitHub repository stats to a CSV file

Give it a list of GitHub repository links and get a spreadsheet-ready CSV with each repository's name, description, stars, last change and creation date.

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 github_repos_to_csv.py

"""GitHub repos to a CSV with FoxAPIs. Reads repo links from repos.txt (one per line), writes repos.csv. 1 credit per repo (as reported by the API on 19 Nov 2026)."""
import csv, os, sys, requests

KEY = os.environ["FOXAPIS_KEY"]          # your FoxAPIs key; never paste it into the file
URL = "https://api.foxapis.com/v1/developer/github/repo"

repos = [l.strip() for l in open("repos.txt", encoding="utf-8") if l.strip()]
rows = []
for link in repos:
    r = requests.post(URL, headers={"Authorization": f"Bearer {KEY}"}, json={"url": link}, timeout=60)
    if r.status_code != 200:
        print(f"{link}: HTTP {r.status_code}", file=sys.stderr)
        continue
    d = r.json()
    if d.get("errors"):
        print(f"{link}: {d['errors'][0]}", file=sys.stderr)
        continue
    rows.append({"repo": d.get("title"), "description": d.get("description"), "stars": d.get("likes"),
                 "last_changed": d.get("modified_at"), "created": d.get("published_at"), "url": d.get("url"),
                 "credits": d.get("credits_used")})

with open("repos.csv", "w", newline="", encoding="utf-8") as f:
    w = csv.DictWriter(f, fieldnames=["repo", "description", "stars", "last_changed", "created", "url", "credits"])
    w.writeheader()
    w.writerows(rows)
print(f"wrote repos.csv with {len(rows)} rows, {sum(r['credits'] or 0 for r in rows)} credits")

Run it

  1. Put your key in an environment variable: on macOS or Linux export FOXAPIS_KEY=your-key, in Windows PowerShell $env:FOXAPIS_KEY = "your-key".
  2. Run python github_repos_to_csv.py.

Input used in the test

repos.txt:
https://github.com/torvalds/linux
https://github.com/astral-sh/uv
https://github.com/hono-js/hono

What it printed and wrote (19 November 2026)

hono-js/hono: HTTP 404          (printed to the error stream: that link is not a repository, the script carries on)
wrote repos.csv with 2 rows, 2 credits

repos.csv:
repo,description,stars,last_changed,created,url,credits
torvalds/linux,Linux kernel source tree,256159,2026-11-18T22:07:42Z,2011-09-04T22:48:12Z,https://github.com/torvalds/linux,1
astral-sh/uv,"An extremely fast Python package and project manager, written in Rust.",92205,2026-11-18T22:01:28Z,2023-10-02T20:24:11Z,https://github.com/astral-sh/uv,1

What a run costs

1 credit per repository (a link that failed was not charged: 3 links, 2 credits). fact: credits the API reported

That is about $0.01 per repository 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

Can I run it on a schedule?

Yes: cron on macOS and Linux, Task Scheduler on Windows. Each run costs the credits above.

Where does the key go?

In an environment variable, as shown. The script reads it and never writes it anywhere.

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