Using GitHub Api Code Search - Sort by recently indexed

Viewed 306

I am searching for a specific code in GitHub using their API code search.

https://api.github.com/search/code?q={query}{&page,per_page,sort,order}

I have for example the following:

https://api.github.com/search/code?q={"Hello World"}

I want to sort the search result by Recently Indexed, I am not sure what to put in the sort parameter. I checked GitHub documentation but I didn't find how.

1 Answers

Have a look at the Search code section of the GitHub REST API Reference. By default, the search results of this endpoint are best match. The only option for the sort parameter is indexed and actually what you want. The following query is an example:

https://api.github.com/search/code?q=org:github+octocat&sort=indexed
Related