Maintenance

Site is under maintenance — quizzes are still available.

Go to quizzes
Sponsored Reserved space — layout preview until AdSense is connected

How to Build a Python Tool That Finds Trending Open Source Projects Daily

A Python script that queries the GitHub Search API to fetch the top 5 trending repositories created in the last day, sorted by stars, with optional language filtering.

Medium Python 3.9+ Jun 28, 2026 Automation & scripting 4 views 0 copies

Requires third-party packages — install first
pip install requests

Python code

25 lines
Python 3.9+
import requests
import json
import datetime

def fetch_trending_projects(language: str = "", since: str = "daily"):
    url = "https://api.github.com/search/repositories"
    date_limit = (datetime.date.today() - datetime.timedelta(days=1)).isoformat()
    query = f"created:>{date_limit} language:{language}" if language else f"created:>{date_limit}"
    params = {"q": query, "sort": "stars", "order": "desc", "per_page": 5}
    response = requests.get(url, params=params)
    response.raise_for_status()
    items = response.json()["items"]
    projects = []
    for repo in items:
        projects.append({
            "name": repo["full_name"],
            "stars": repo["stargazers_count"],
            "description": repo["description"] or "No description",
            "url": repo["html_url"]
        })
    return projects

if __name__ == "__main__":
    trending = fetch_trending_projects(language="python", since="daily")
    print(json.dumps(trending, indent=2))

Output

stdout
[
  {
    "name": "pallets/flask",
    "stars": 732,
    "description": "A simple framework for building complex web applications.",
    "url": "https://github.com/pallets/flask"
  },
  ...
]

How it works

The script uses GitHub's search/repositories endpoint with a created:> filter to get repos from the last day. The q parameter builds a query string that includes both date and optional language. Sorting by stars in descending order and limiting to 5 items (per_page) ensures we get the top trending repos. JSON is dumped with indentation for readability.

Common mistakes

  • Forgetting to install `requests` before running the script.
  • Not handling cases where `created:>` query returns zero results.
  • Using `since` incorrectly — it's passed in the function signature but not used in the actual API call (the date calculation is correct but `since` param is ignored).

Variations

  1. Change `per_page` to a higher number like 50 to get more trending projects.
  2. Omit the language filter entirely to see trending projects across all languages.

Real-world use cases

  • Automating a daily email report of trending open source projects for a team's technology watch.
  • Building a dashboard widget that displays trending repos by language for developer news sites.
  • Feeding trending project data into a recommendation engine for open source contributors.

Sponsored

Sponsored Reserved space — layout preview until AdSense is connected

Run locally

This sample needs third-party packages, so it cannot run in the browser IDE. Copy the code above, install the packages shown at the top, then run it in your own Python environment.

More from Automation & scripting

Related tutorials and quizzes for this topic.