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
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}'import osimport requestsresponse = requests.post( "https://api.bridgly.app/github/search-code", headers={"Authorization": f"Bearer {os.environ['BRIDGLY_KEY']}"}, json={ "query": "createServer", "language": "TypeScript", "count": 10, },)data = response.json()const response = await fetch("https://api.bridgly.app/github/search-code", { method: "POST", headers: { Authorization: `Bearer ${process.env.BRIDGLY_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ "query": "createServer", "language": "TypeScript", "count": 10 }),});const data = await response.json();import { Bridgly } from "@bridgly/sdk";const client = new Bridgly({ apiKey: "bgly_YOUR_KEY" });const res = await client.github.searchCode({ query: "createServer", language: "TypeScript", count: 10});if (res.type === "success") { console.log(res.data);}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
{ "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 }}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.
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.
More GitHub endpoints
The same API key works on every endpoint. See all GitHub API endpoints.
- GitHub Topic Search API→GitHub topics API: search GitHub topics by keyword, with filters for featured, curated and repository count. Each result has its name and description.
- GitHub Repository Search API→GitHub repository search API: search public repos by keyword, language, stars, forks, topics, license and dates, with description and star and fork counts.
- GitHub Commit Search API→GitHub commit search API: search commits across public repositories by message, author, committer, date or SHA, with message, author and repository.
- GitHub Issue Search API→GitHub issues API: search issues by keyword, repo, state, labels, author, assignee, comment count and dates, with title, state, labels and timestamps.
Try the GitHub Code Search API
100 free credits on business email, no card. Your first call takes a minute.