Drupal Contrib Code Search

This is a search engine for the 11898 contributed themes and modules compatible with Drupal 10 and above.


Details

Which modules are indexed?
Modules and theme which support Drupal 10 and later only.
Which branches are indexed?
Branches with code compatible with 10 and above.
How old is the data?
The code is updated every 48h and release data is updated weekly.

Search code:

hook_form_alter
find all implementations of hook_form_alter
sym:_form_alter
find symbol definitions containing _form_alter
hook_form_alter r:webform
search within the webform module only
hook_form_alter lang:php
restrict to PHP files
"extends PluginBase"
exact phrase search
EntityInterface or ContentEntityBase
match either term
FormBuilder -test
find FormBuilder, exclude test files
Drupal\\views case:yes
case-sensitive namespace search
f:\.info\.yml$
find all module info files

Filter by file & branch:

hook f:\.module$
search only in .module files
render f:src/Plugin
search in Plugin directories
schema -f:test -f:vendor
exclude test and vendor paths
migrate b:HEAD
search only in the default branch

Find modules:

r:views
list modules whose name contains "views"
r:commerce -r:stripe
commerce modules, excluding stripe
r:field_
all field-related modules

Regex patterns:

function .*_schema\(\)
find all schema hook implementations
@Form\(
find Form annotations
@Block\( lang:php
find Block plugin annotations
\bdeprecated\b lang:php
find deprecation notices

Full syntax reference →

JSON API for scripting

The API is hosted at https://api.tresbien.tech (not on this domain). Two GET endpoints, both return JSON. Important: query terms are regex: escape . ( ) \ with a backslash (e.g. .once(\.once\().

Step 1: Search code

curl 'https://api.tresbien.tech/v1/search/code?q=\.once\(&num=200'

Returns Result.Files[], each with .Repository (module name) and .ChunkMatches[] (base64 content + match positions). Use num to control max file results.

Step 2: Get repository metadata

curl 'https://api.tresbien.tech/v1/search/repo'

Returns List.Repos[] (all repositories). Each entry has .Repository.Name and .Repository.RawConfig with:

Example: find 5 most installed modules using .once(

  1. Search: curl 'https://api.tresbien.tech/v1/search/code?q=\.once\(&num=500'
  2. Collect unique Repository names from Result.Files[]
  3. Fetch: curl 'https://api.tresbien.tech/v1/search/repo' (full list, no parameters)
  4. For each repo from step 2, look up its RawConfig.priority in the repo list
  5. Sort by priority descending, take top 5

Full API reference with response examples →