Skip to content

πŸ“ˆ This API provides Data about Trending Repositories and Developers on Github.

License

Notifications You must be signed in to change notification settings

NiklasTiede/Github-Trending-API

Repository files navigation

...written in Python!

Codecov

Examples

Data you can retrieve from this API.

Trending Repositories

❯ curl -X GET "https://gh-trending-api.herokuapp.com/repositories" -H  "accept: application/json"
[
  {
    "rank": 1,
    "username": "sherlock-project",
    "repositoryName": "sherlock",
    "url": "https://github.com/sherlock-project/sherlock",
    "description": "Hunt down social media accounts by username across social networks",
    "language": "Python",
    "languageColor": "#3572A5",
    "totalStars": 21977,
    "forks": 2214,
    "StarsSince": 462,
    "since": "daily",
    "builtBy": [
      {
        "username": "hoadlck",
        "url": "https://github.com/hoadlck",
        "avatar": "https://avatars.githubusercontent.com/u/1666888?s=40&v=4"
      },
      ...
    ]
  },
...
]

Trending Developers

❯ curl -X GET "https://gh-trending-api.herokuapp.com/developers" -H  "accept: application/json"
[
  {
    "rank": 1,
    "username": "felangel",
    "name": "Felix Angelov",
    "url": "https://github.com/felangel",
    "avatar": "https://avatars.githubusercontent.com/u/8855632?s=96&v=4",
    "since": "daily",
    "popularRepository": {
      "repositoryName": "bloc",
      "description": "A predictable state management library that helps implement the BLoC design pattern",
      "url": "https://github.com/felangel/bloc"
    }
  },
...
]

The motivation behind this API for me was to learn web scraping and how to create an API. It is based on the idea of the github-trending-api except that this one is written in python and it is available πŸ˜‰!

This project runs on Python 3.9 and uses...

  • beautifulsoup4 | scraping
  • aiohttp | async GET requests
  • fastAPI | web framework
  • uvicorn | ASGI server

Since Heroku removed their free plan I can no longer offer you discovering this API's functionality with a deployed instance!

How to Use

FastAPI has a fantastic built-in documentation, so feel free to visit and explore the API by yourself. Data about trending repositories/developers are provided via the /repositories and /developers routes. The endpoints are similar to the routes on github.

  • a path parameter for the programming language can be used to limit the scope of the search to this language
  • a query parameter for the date range (since) let you select the trending projects within the specified period of time (daily, weekly or monthly)
  • moreover, repositories can be limited to a spoken language (spoken_lang)

Here are some examples. Repositories can be queried for 3 parameters...

example pogramming lang date range spoken lang
/repositories ❌ ❌ ❌
/repositories?since=weekly ❌ βœ”οΈ ❌
/repositories/python βœ”οΈ ❌ ❌
/repositories/python?since=monthly βœ”οΈ βœ”οΈ ❌
/repositories/python?since=weekly&spoken_lang=zh βœ”οΈ βœ”οΈ βœ”οΈ

...whereas developers can only be queried for 2 parameters.

example pogramming lang date range
/developers ❌ ❌
/developers?since=weekly ❌ βœ”οΈ
/developers/c++ βœ”οΈ ❌
/developers/c++?since=weekly βœ”οΈ βœ”οΈ

Running from Source

You can easily clone the project and run it locally:

❯ git clone
❯ cd Github-Trending-API

Recreate the dependencies from the requirements-prod.txt file with a dependency manager of your choice.

❯ uvicorn app.main:app --host 0.0.0.0 --port 5000 --reload

Or pull the docker image and run it:

❯ docker pull niklastiede/github-trending-api:latest
❯ docker run -p 5000:5000 niklastiede/github-trending-api:latest