GitHub Code Search API avatar

GitHub Code Search API

Pricing

$1.00 / 1,000 code hit produceds

Go to Apify Store
GitHub Code Search API

GitHub Code Search API

Search public GitHub code by query, language, repository, file name or path: file link, repository, path, matched text and repository stars and forks for each hit. Export to CSV, JSON or Excel, schedule runs or use the API.

Pricing

$1.00 / 1,000 code hit produceds

Rating

0.0

(0)

Developer

Automly

Automly

Maintained by Community

Actor stats

0

Bookmarked

26

Total users

10

Monthly active users

9 days ago

Last modified

Share

What is GitHub Code Search API?

GitHub Code Search API is a tool that lets you scrape code search results from GitHub: the files that match your search, with file name and path, a link to the file, the matching lines, the language, and the repository's name, description, stars, forks and owner. Type a search such as requests language:Python, click Start, and download the code hits as Excel, CSV or JSON.

  • 🔎 GitHub search syntax: keywords plus filters for language, repository, file name and path
  • 📁 Repository context: every code hit comes with the repository's stars, forks, description and owner type
  • 🔓 One repository, no key: search inside any one public repository without a GitHub key; searching all of GitHub needs your own free GitHub key
  • 💸 Free to try: the $5 of free usage every Apify account gets each month covers about 5,000 code hits

What can GitHub Code Search API do?

  • Search public GitHub code by keyword
  • Find which repositories use a library, package or API
  • Search GitHub code by programming language
  • Search code inside one GitHub repository
  • Find files by name across GitHub, such as package.json or requirements.txt
  • Search GitHub code in a folder path such as src/ or docs/
  • Get the matching lines of code for each file when GitHub shows them
  • Export GitHub code search results to Excel, CSV, JSON, HTML or XML
📄 File name📂 File path🔗 Link to the file
🧾 Matching lines💻 Language🎯 Match score
📦 Repository name and URL📝 Repository description⭐ Stars and 🍴 forks
👤 Owner login🏢 Owner type (user or organization)🔎 Your search query

How to scrape GitHub code search results

  1. Create a free Apify account (no credit card needed).
  2. Open GitHub Code Search API.
  3. Type a Search query. To search all of GitHub, paste your own GitHub personal access key in the last field of the form; to search one repository, fill in Repository filter instead.
  4. Add a Language filter, Filename filter or Path filter if you want, set Maximum results, and click Start.
  5. When the run finishes, download your code hits as Excel, CSV, JSON, HTML or XML.

How to get a free GitHub key for searching all of GitHub

GitHub only lets signed-in users search code across all of GitHub, so this one setting needs your own key. It is free and takes a minute:

  1. Sign in to GitHub and open github.com/settings/tokens.
  2. Create a new personal access key. It needs no permissions, because the actor only reads public code.
  3. Paste it into the last field of the input form. Apify stores it as a secret.

You don't need a key to search inside one public repository: put repo:owner/name in the query or fill in Repository filter.

How much does it cost to scrape GitHub code search results?

You pay $1.00 per 1,000 code hits. Apify platform usage is included in this price, so there is nothing else to pay for the run.

For example, 1,000 code hits cost $1.00 on the Free plan, and a run that returns 100 code hits costs $0.10.

Every Apify account gets $5 of free usage each month. See the Pricing tab for details.

⬇️ Input

SettingWhat it does
Search queryKeywords plus optional GitHub filters, such as language:Python, repo:owner/name, filename:requirements.txt or path:src/ (required)
Maximum resultsHow many code hits to return (default 50, up to 100)
Language filterOnly code in this programming language
Repository filterOnly code in this repository, as owner/name, e.g. psf/requests
Filename filterOnly files with this name, e.g. package.json or README.md
Path filterOnly files under this path, e.g. src/ or docs/
Your GitHub keyNeeded only to search all of GitHub (see above)

Example: Python code that uses requests (needs your GitHub key).

{
"query": "requests language:Python",
"maxResults": 20
}

Example: search one repository, no key needed.

{
"query": "HTTPAdapter repo:psf/requests",
"maxResults": 20
}

Example: search the README of one repository.

{
"query": "api key",
"repo": "psf/requests",
"filename": "README.md",
"maxResults": 10
}

⬆️ Output

You get one row per matching file. You can view the rows as a table in Apify Console or download them as Excel, CSV, JSON, HTML or XML. matchedText holds the matching lines when GitHub shows them.

{
"recordType": "code-hit",
"query": "requests language:Python",
"repositoryFullName": "psf/requests",
"repositoryUrl": "https://github.com/psf/requests",
"repositoryDescription": "Python HTTP for Humans.",
"repositoryStars": 53500,
"repositoryForks": 9700,
"repositoryOwnerLogin": "psf",
"repositoryOwnerType": "Organization",
"fileName": "__init__.py",
"filePath": "requests/__init__.py",
"htmlUrl": "https://github.com/psf/requests/blob/main/requests/__init__.py",
"gitUrl": "https://api.github.com/repos/psf/requests/git/blobs/...",
"apiUrl": "https://api.github.com/repos/psf/requests/contents/requests/__init__.py",
"score": 1,
"language": "Python",
"matchedText": "..."
}

How can I use GitHub code search data?

  • Library and API adoption: find real examples of how a library, SDK or API is used, and which projects use it
  • Developer prospecting: list the repositories and organizations whose code mentions your product or a competitor's
  • Code research: compare patterns and implementation styles across public projects
  • Package and dependency discovery: find package.json, requirements.txt or other files that name a package
  • Mention monitoring: run the same search on a schedule to see new code mentions of your package
  • Examples for AI prompts: collect real code examples to add to your own prompts and docs

Scrape more GitHub and developer data

ActorWhat it gets
GitHub Repository Scraper - Repos, Issues & Pull RequestsRepository details, open issues, pull requests and contributor profiles
GitHub Issues Scraper - Issues & Pull Requests MonitorNew, updated, closed and merged issues and pull requests, on a schedule
GitHub Users Scraper - Developers by Location & CompanyGitHub users and organizations by keyword, location, company and follower count
npm Scraper - Package Metadata, Versions & Maintainersnpm package details, versions and maintainers
PyPI Scraper - Python Package Versions & DownloadsPython package metadata, versions and project links
Stack Overflow Scraper - Questions, Tags & ScoresStack Overflow and Stack Exchange questions with tags, scores and answer counts

🤖 Use with AI agents (MCP)

This actor works as a tool for AI agents. Connect any MCP-compatible AI assistant or agent to the Apify MCP server at mcp.apify.com (sign in with your Apify account), and it can find this actor, fill in the input and read the results by itself. Ask in plain words, for example "Find the files in psf/requests that use HTTPAdapter", and the agent runs automly/github-code-search-api with an input like {"query": "HTTPAdapter repo:psf/requests", "maxResults": 20}. Every input and output field has a plain description, so the agent knows what to type and what each column means. Agent runs cost the same as runs you start yourself.

❓FAQ

How much does GitHub Code Search API cost?

$1.00 per 1,000 code hits, platform usage included. See the cost section above and the Pricing tab.

Do I need a GitHub account or key?

To search all of GitHub, yes: GitHub only allows that for signed-in users. Create a free personal access key at github.com/settings/tokens; it needs no permissions, because the actor reads public code only. To search inside one public repository you need nothing: put repo:owner/name in the query or fill in Repository filter. Results then include every file that contains all your words, best matches first, and score counts how often the words appear.

Can I search a single repository?

Yes. Use repo:owner/name in the query or the Repository filter field.

How many code hits can I get per run?

Up to 100 per run. For more, split your search into narrower ones, for example by language, path or repository, and run each one.

Can I search private code?

No. It returns public code search results only.

Why are some matchedText values empty?

GitHub does not show the matching lines for every result. When it doesn't, the row still has the file, its link and the repository details.

What if my run charge limit is reached?

The actor stops after the last result your limit covers and keeps every code hit it already produced.

Can I connect GitHub Code Search API to other tools or AI agents?

Yes. Start runs and download results with the Apify API or the Python and JavaScript clients, send results to Make, Zapier, n8n, Google Sheets or Slack with Apify integrations and webhooks. AI assistants and agents can run it through the Apify MCP server, see the Use with AI agents (MCP) section above.

This actor only returns public code that anyone can find with GitHub search. Code and repository details can still contain personal data, such as names or email addresses in files, which may be protected by laws such as GDPR, and code is covered by its license. Only use it for a legitimate reason and ask a lawyer if you are unsure. You can read more in Is web scraping legal?

GitHub Code Search API is an independent tool. It is not affiliated with, endorsed by or sponsored by GitHub.

Something isn't working?

Open the Issues tab and tell us your search query and what you expected.

⭐ Your feedback

Have an idea or found a problem? Tell us on the Issues tab. If GitHub Code Search API saved you time, a short review on the Reviews tab helps other people find it.