1
votes

How to search for some piece of code through the github api, knowing only the keyword contained in the piece of code ?

Using the search term 'preg_replace', type 'code' and language 'PHP'. In any repo.

Just like the following link, but with the dedicated API.

https://github.com/search?q=preg_replace&repo=&langOverride=&start_value=1&type=Code&language=PHP

(Checked this, but can't see how to search code. http://developer.github.com/v3/search/#search-issues https://github.com/search )

2

2 Answers

3
votes

As of July 2013, code search is available via an API:

https://github.com/blog/1564-code-search-api

0
votes

Answer from the GitHub support team (from Wynn - Thanks for the answer)

Hi, Cedric. Sorry, code search isn't currently available in the API. We're constantly improving the API so keep an eye on the docs and @GitHubAPI on Twitter for updates as we add new features.

Cheers,

I guess I will have to parse some HTML instead (from https://github.com/search results).