Search on Github repositories inside source files using API

Viewed 453

I am trying to use the search code from Github as presented in the following link:

Search code

They gave an example to search a "String" inside Github without the API as the following:

search "amazing" in language:go

Is there a way to apply the last query to get results from the Rest API they are presenting?

1 Answers

The help page mentions:

The REST API supports the same qualifiers as GitHub.com.
To learn more about the format of the query, see Constructing a search query.
See "Searching code" for a detailed list of qualifiers.

In your case:

curl -G https://api.github.com/search/code          \
--data-urlencode 'q=amazing language:go org:github' \
--data-urlencode 'sort=indexed'                   \
--data-urlencode 'order=desc'                     \
-H 'Accept: application/vnd.github.preview' 

But: since 2013, for an API search (not Web search), a user, organization, or repository qualifier is now required, as confirmed here.

This thread mentions:

Related