I am trying to get the top 10 repositories based on the star, So here is the API I am using.
However, The result I get is incorrect and it seems like it changes the order of the top 3 repositories. For example: The first time I call the below API, here is the top 3 repository based on the star.
- freeCodeCamp/freeCodeCamp 342K
- EbookFoundation/free-programming-books 225K
- vuejs/vue 194K
After 1 minute, i call the api one more time and got totally different result:
- freeCodeCamp/freeCodeCamp 342K
- 996icu/996.ICU 261K
- jwasham/coding-interview-university 212K
So basically, the result is not correct. Is there anything wrong with my API endpoint?
https://api.github.com/search/repositories?q=stars:>0&sort=stars&per_page=3
CodePudding user response:
I modified the api little bit ,
https://api.github.com/search/repositories?q=stars:>=10000&sort=stars&order=desc
and I am getting consistent results like this;
1.freeCodeCamp/freeCodeCamp
2. 996icu/996.ICU
3. free-programming-books
CodePudding user response:
The GitHub website lists the top repositories under https://github.com/search?q=stars:>1&s=stars&type=Repositories as:
- freeCodeCamp/freeCodeCamp
- 996icu/996.ICU
- EbookFoundation/free-programming-books
First of all, this should be the right endpoint, see https://docs.github.com/en/rest/reference/search#search-repositories, the page says:
The results are sorted by stars in descending order, so that the most popular repositories appear first in the search results.
I get the same result when I use the parameters and run the following query in the browser, using the same parameters as on the website above:
https://api.github.com/search/repositories?q=stars:>1&s=stars
Note: I am not sure about the s parameter. Either s is short for sort or it is not used as the result is already sorted.