@@ -363,6 +363,54 @@ def ratelimit_remaining():
363363 return gh .ratelimit_remaining
364364
365365
366+ def search_code (query , sort = None , order = None , per_page = None ,
367+ text_match = False , number = - 1 , etag = None ):
368+ """Find code via the code search API.
369+
370+ .. warning::
371+
372+ You will only be able to make 5 calls with this or other search
373+ functions. To raise the rate-limit on this set of endpoints, create an
374+ authenticated :class:`GitHub <github3.github.GitHub>` Session with
375+ ``login``.
376+
377+ The query can contain any combination of the following supported
378+ qualifiers:
379+
380+ - ``in`` Qualifies which fields are searched. With this qualifier you
381+ can restrict the search to just the file contents, the file path, or
382+ both.
383+ - ``language`` Searches code based on the language it’s written in.
384+ - ``fork`` Specifies that code from forked repositories should be
385+ searched. Repository forks will not be searchable unless the fork
386+ has more stars than the parent repository.
387+ - ``size`` Finds files that match a certain size (in bytes).
388+ - ``path`` Specifies the path that the resulting file must be at.
389+ - ``extension`` Matches files with a certain extension.
390+ - ``user`` or ``repo`` Limits searches to a specific user or
391+ repository.
392+
393+ For more information about these qualifiers, see: http://git.io/-DvAuA
394+
395+ :param str query: (required), a valid query as described above, e.g.,
396+ ``addClass in:file language:js repo:jquery/jquery``
397+ :param str sort: (optional), how the results should be sorted;
398+ option(s): ``indexed``; default: best match
399+ :param str order: (optional), the direction of the sorted results,
400+ options: ``asc``, ``desc``; default: ``desc``
401+ :param int per_page: (optional)
402+ :param bool text_match: (optional), if True, return matching search
403+ terms. See http://git.io/4ct1eQ for more information
404+ :param int number: (optional), number of repositories to return.
405+ Default: -1, returns all available repositories
406+ :param str etag: (optional), previous ETag header value
407+ :return: generator of :class:`CodeSearchResult
408+ <github3.search.CodeSearchResult>`
409+ """
410+ return gh .search_code (query , sort , order , per_page , text_match , number ,
411+ etag )
412+
413+
366414def search_repositories (query , sort = None , order = None , per_page = None ,
367415 text_match = False , number = - 1 , etag = None ):
368416 """Find repositories via various criteria.
0 commit comments