There's no GitHub Trending API, so we tested 3 free alternatives
While building a tool that collects GitHub data, we got curious about one thing.
Can you get the list of repositories on the GitHub Trending page through an API?
GitHub offers a lot of its features through official APIs, so we assumed there would be a Trending API too. There isn't.
If you search for it, you'll find plenty of guides that build "Trending" on top of the GitHub Search API. At first we also thought this would get us something reasonably close to the real Trending page.
So we compared them directly.
The results were very different from what we expected.
1. Three free approaches
These are the three approaches we tested:
- Repositories created recently, sorted by total stars
- Repositories with a recent push, sorted by total stars
- The OSS Insight API, which ranks repositories based on GitHub event data
The first two use GitHub's official Search API, so there's no web scraping involved. We expected the third one to be closer to Trending, because it measures popularity from events that happened during a given period.
2. How they compare to the real GitHub Trending page
The difference might only show up for certain languages or periods, so we split the comparison into three cases:
- Python / Weekly
- All languages / Weekly
- Python / Daily
That's two Search API approaches times three cases, six comparisons in total.
In every comparison, only 0 or 1 repositories overlapped with the actual GitHub Trending list.
| Case | Repos on the Trending page | Created recently, by stars | Pushed recently, by stars | OSS Insight |
|---|---|---|---|---|
| Python / Weekly | 15 | 0 | 0 | no data |
| All languages / Weekly | 15 | 0 | 0 | no data |
| Python / Daily | 23 | 0 | 1 | no data |
Tested on November 28, 2026 at 14:38 UTC. Every request returned HTTP 200. We compared the top 25 results of each Search API query with every repository on the Trending page. "Recently" means the last 7 days for the weekly cases and the last day for the daily case. The full script is at the end of this post.
At first we thought something was wrong with how we collected the data.
The Python weekly Trending list in particular gave us only 15 repositories, so we opened the actual page and checked. The page had exactly 15 at that time.
No repositories were missing from our collection. We had simply been pulling two different lists from the start.
3. GitHub Trending isn't a ranking of this week's stars either
Looking through the actual Trending page, we noticed something more interesting.
In Python weekly Trending, the repository in 5th place got 162 stars this week.
The repository in 12th place got 12,164 stars in the same period.
The one with far more stars this week was ranked lower.
According to GitHub's original post introducing Trending, it looks at stars, forks, commits, follows and pageviews, and also at how recently those events happened. The exact formula has never been published.
Filtering the Search API for recently created repositories and sorting them by stars is a completely different calculation.
The same goes for sorting recently pushed repositories by stars. You're more likely to get repositories that were already popular and also got updated recently, rather than ones that just became popular.
In the end, the Search API alone can't give you the same result as GitHub Trending.
4. What about event data?
Then why not collect when stars were added and calculate the ranking yourself?
OSS Insight is a well-known service that takes this approach.
But when we tested it, the API call itself worked, yet no Trending data came back.
The response said the data had been unavailable since March 1, 2026, and that event collection had dropped to about 0.3% of the normal level.
Looking further, this isn't just an OSS Insight problem.
According to a September 2026 post on the Google Open Source Blog, GH Archive may have been missing more than half of GitHub events since 2025, and in 2026 the capture rate for some event types may be as low as 20%.
Before you even get to the ranking algorithm, the raw data itself has become unreliable.
On top of that, OSS Insight has announced that it will shut down its live service and public API on December 4, 2026.
Before following an older "GitHub Trending API" tutorial as is, it's worth checking whether the data is actually still there.
5. So which approach should you use?
This test made us think that getting the GitHub Trending list and finding repositories that are getting attention lately are two different problems.
If you need exactly the same list as GitHub Trending
Using the Trending page itself as the data source is the most reliable way. But parsing HTML can stop working whenever the page structure changes.
If you want to find popular projects that appeared recently
Limiting the creation date in the Search API and sorting by stars is useful enough.
If you want popular projects that are still being actively developed
Filtering by recent push date and sorting by stars works well. It doesn't show how often or how much development actually happens, though.
None of these approaches is wrong. They just answer different questions.
6. Wrapping up
We started out looking for a simple API to replace GitHub Trending.
After actually comparing them, we found that defining what data you want matters more than copying Trending as is.
The test script
Python standard library only, no token needed. It prints each list and the overlap counts. The OSS Insight part will return 410 Gone after December 4, 2026.
"""Compare GitHub trending pages with Search API (created / pushed) and OSS Insight trends. Standard library only, no tokens. Usage: python run.py """ import urllib.request, urllib.error, urllib.parse, re, json, datetime UA = {"User-Agent": "trending-compare/1.0", "Accept": "*/*"} def get(url): req = urllib.request.Request(url, headers=UA) try: with urllib.request.urlopen(req, timeout=60) as r: return r.status, r.read().decode("utf-8", "replace") except urllib.error.HTTPError as e: return e.code, e.read().decode("utf-8", "replace")[:300] except Exception as e: return type(e).__name__, str(e) def stamp(): return datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%d %H:%M:%S UTC") def trending(lang, since): path = f"/trending/{lang}" if lang else "/trending" url = f"https://github.com{path}?since={since}" t = stamp() s, html = get(url) repos = [] if s == 200: for art in html.split("<article")[1:]: m = re.search(r'<h2[^>]*>.*?href="/([^"/]+/[^"/]+)"', art, re.S) if m: repos.append(m.group(1)) return url, t, s, repos def search(lang, field, days, n=25): d = (datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=days)).date().isoformat() q = f"{field}:>{d}" + (f" language:{lang}" if lang else "") url = "https://api.github.com/search/repositories?" + urllib.parse.urlencode( {"q": q, "sort": "stars", "order": "desc", "per_page": n}) t = stamp() s, body = get(url) repos = [] if s == 200: repos = [i["full_name"] for i in json.loads(body)["items"]] return url, t, s, repos def ossinsight(lang, period): qs = {"period": period, "language": lang or "All"} url = "https://api.ossinsight.io/v1/trends/repos/?" + urllib.parse.urlencode(qs) t = stamp() s, body = get(url) repos = [] if s == 200: try: rows = json.loads(body)["data"]["rows"] repos = [r["repo_name"] for r in rows] except Exception as e: return url, t, f"200 but parse error {e}", repos else: body_short = body[:200] return url, t, f"{s} {body_short}", repos return url, t, s, repos def low(xs): return {x.lower() for x in xs} scenarios = [ ("Python weekly", "python", "weekly", 7, "past_week"), ("All languages weekly", "", "weekly", 7, "past_week"), ("Python daily", "python", "daily", 1, "past_24_hours"), ] for name, lang, since, days, period in scenarios: print("=" * 70) print(name) turl, tt, ts, trend = trending(lang, since) print(f"[trending] {tt} HTTP {ts} count={len(trend)}\n {turl}\n {trend}") sources = [ ("a. Search created, stars", search(lang, "created", days)), ("b. Search pushed, stars", search(lang, "pushed", days)), ("c. OSS Insight trends", ossinsight(lang, period)), ] for label, (url, t, s, repos) in sources: ov = sorted(low(trend) & low(repos)) # also overlap when API list is cut to the same size as trending k = len(trend) ovk = sorted(low(trend) & low(repos[:k])) print(f"[{label}] {t} HTTP {s} count={len(repos)}\n {url}") print(f" overlap with trending: {len(ov)} (top-{k} only: {len(ovk)}) {ov}") print(f" top5: {repos[:5]}") Disclosure: I wrote this post in Korean and translated it into English with an AI assistant. The test script was written with AI help, and the numbers come from our own run.
The original post is on my blog: ondutylabs.hashnode.dev