...written in Python!
Data you can retrieve from this API.
β― 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"
},
...
]
},
...
]
β― 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!
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 | βοΈ | βοΈ |
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