GITHUB API

GitHub Code Search API

Search source code across public GitHub repositories, filtered by language, file extension, file name, path, owner or repository. Each result gives the file name, path, link and the repository it belongs to.

Endpoint
POST /github/search-code
Price
1 credit per request
SDK
client.github.searchCode()
MCP tool
github_search_code
Terminal
curl -X POST "https://api.bridgly.app/github/search-code" \
-H "Authorization: Bearer $BRIDGLY_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "createServer",
"language": "TypeScript",
"count": 10
}'
[ REQUEST AND RESPONSE ]

What does the GitHub Code Search API return?

GitHub code search API: search code across public GitHub repositories by keyword, language, file name, extension and path, with file path and repository. Every response has the same envelope: the result in data, plus timeMs and the creditsCost of the call.

Request body

querystring
Free-text search terms, matched against the default fields for this search type, e.g. "web framework".
ownersstring[]
Limit to these owners (users or orgs). Maps to `user:`.
reposstring[]
Limit to these "owner/name" repositories. Maps to `repo:`.
languagestring
Programming language, e.g. "Go". Maps to `language:`.
extensionstring
File extension without the dot, e.g. "ts". Maps to `extension:`.
filenamestring
Exact file name, e.g. "package.json". Maps to `filename:`.
pathstring
Path prefix within the repo, e.g. "src/app". Maps to `path:`.
forkenum · default exclude
Whether to include forks. Defaults to excluding them.
exclude | include
sortenum · default best-match
Sort field. Defaults to relevance ("best-match").
best-match | indexed
orderenum · default desc
Sort direction. Defaults to "desc".
desc | asc
countinteger · 1–10 · default 10
Number of results to return (1–10). Defaults to 10.
startinteger · 0–999
Number of results to skip (0–999). Defaults to 0. Only the first 1,000 results of a search can be paged through.

Example response

200 OK · application/json
{
"timeMs": 1840,
"creditsCost": 1,
"data": {
"query": "string",
"totalCount": 0,
"results": [
{
"name": "string",
"path": "string",
"sha": "string",
"url": "string",
"htmlUrl": "string",
"repository": {
"id": 0,
"nodeId": "string",
"name": "string",
"fullName": "string",
"ownerLogin": "string",
"url": "string",
"isPrivate": true
}
}
],
"nextStart": 0
}
}
[ USE CASES ]

What can you build with the GitHub Code Search API?

Find usage examples

See how real projects call a function or configure a tool.

Track adoption

Count which repositories import your library or SDK.

Find leaked keys

Search for your own key prefixes in public code and rotate them.

[ FAQ ]

GitHub Code Search API questions

How do I search code across all of GitHub?

Send a keyword and narrow it with language, extension, filename, path, owners or repos. Each result gives the file name, path, link and the repository it is in.

Can I find which projects use a library?

Yes. Search the package name with filename set to package.json, or an import or function name with language set. The repositories in the results are projects using it.

How do I get more than 10 results from a GitHub code search?

Each call returns up to 10 files. Send the same query with start set to the nextStart from the response for the next ones. GitHub only lets you page through the first 1,000 results of a search, so narrow the query to reach the rest.

How do I use the GitHub Code Search API?

Send a POST request to https://api.bridgly.app/github/search-code with the filters you want in the JSON body and your API key in the Authorization header. In the TypeScript SDK, call client.github.searchCode(). AI agents connected to Bridgly over MCP can call the github_search_code tool.

How much does the GitHub Code Search API cost?

Costs 1 credit per request. Credits cost $2.00 per 1,000 on pay-as-you-go and as low as $1.00 per 1,000 at volume. New accounts on a business email start with 100 free credits, and failed requests are never charged.

Try the GitHub Code Search API

100 free credits on business email, no card. Your first call takes a minute.

APIMCPSDKCLI
free credits

On business email signup. No credit card required.

Start free with 100 credits