Earlier this year, GitHub introduced the Code Search feature that let you search for code within repositories that you had access to. The team has built on that foundation and have now made available the same functionality via an API. This will open up interesting integration possibilities within IDEs and Automation Software that could sift through your GitHub repositories.
The Code Search API is currently available in Preview and allows you to search Github data via various parameters like specific users/repositories, language, number of stars and much more. An example provided at their Developer Blog is that of “Searching for Popular Tetris repositories written in Assembly”. The query for that will look something like this:
Note that the popularity is based denoted by stars while the language has been specified as assembly. You can combine these parameters in a more complicated fashion as required.
The API also provides methods for searching for code issues, users as well as highlighting search results/issues. The API is REST based and returns back JSON data. The number of API Results are limited to 1000 results per search. It is currently Rate limited to 20 requests/minute for authenticated requests via OAuth, Basic Auth and Client ID/Secret and 5 requests/minute for unauthenticated requests.
For more information, check out the announcement on the Github Developer Blog.