Need an API to search all private GIT Hub repositories for a specific word

We are looking for some help on best way to search a private GIT Hub repositories for a specific word. The result should be list of files matching the search word. We are looking for an API where we don’t need to download each repository.

Is there any API available? If so, please help us how to use it.

1 Like

Hello @kvskjava, welcome to the community :grinning:

You can search all repositories that you have access to for a specific word by using GitHub search or the GitHub Search API if you want to do it programmatically. But you can’t search all private GitHub repositories.

For example, you can use the following GitHub CLI command to search for the word octocat inside files and display the URL to those files:

gh api "search/code?q=octocat+in:file" | jq ".items[].html_url"

But even the Search API has limits. It will only show you the first 1,000 results for any search.

Let us know if you have more questions.

1 Like