/search/code
Search code
Find file contents via various criteria. (This method returns up to 100 results per page.)
Considerations for code search
Due to the complexity of searching code, there are a few restrictions on how searches are performed:
- Only the default branch is considered. In most cases, this will be the master branch.
- Only files smaller than 384 KB are searchable.
- You must always include at least one search term when searching source code. For example, searching for language:go is not valid, while amazing language:go is.
The q search term can also contain any combination of the supported code search qualifiers as described by the in-browser code search documentation and search syntax documentation:
inQualifies which fields are searched. With this qualifier you can restrict the search to the file contents (file), the file path (path), or both.languageSearches code based on the language it’s written in.forkSpecifies that code from forked repositories should be searched (true). Repository forks will not be searchable unless the fork has more stars than the parent repository.sizeFinds files that match a certain size (in bytes).pathSpecifies the path prefix that the resulting file must be under.filenameMatches files by a substring of the filename.extensionMatches files with a certain extension after a dot.userorrepoLimits searches to a specific user or repository.
GET
Request