Searchcode Code Search API

The Code Search API from Searchcode — 1 operation(s) for code search.

GitHub OpenAPI

Operations 1

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/searchcode-com:searchcode-com-code-search-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

searchcode-com-code-search-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository. This REST API mirrors the MCP tool endpoints for non-MCP clients.
  title: searchcode REST Code Search API
  version: 1.0.0
servers:
- description: Production
  url: https://api.searchcode.com
tags:
- name: Code Search
paths:
  /api/v1/code_search:
    post:
      operationId: code_search
      parameters:
      - $ref: '#/components/parameters/client'
      requestBody:
        content:
          application/json:
            schema:
              properties:
                case_sensitive:
                  default: false
                  description: Whether to match case-sensitively.
                  type: boolean
                code_filter:
                  description: Structural filter to narrow matches to specific code regions. only-declarations and only-usages use heuristic patterns and support 30+ languages (Go, Python, JS/TS, Rust, Java, C/C++, C#, Ruby, PHP, Kotlin, Swift, and more). For unsupported languages, all matches are classified as usages.
                  enum:
                  - only-code
                  - only-strings
                  - only-comments
                  - only-declarations
                  - only-usages
                  type: string
                context_lines:
                  default: 2
                  description: Lines of context before and after each match.
                  maximum: 20
                  type: integer
                include_all_dirs:
                  default: false
                  description: Include dependency/build/cache directories that are excluded by default (vendor, node_modules, third_party, target, build, dist, Pods, generated, etc.). Set to true if you need to search generated/vendored code.
                  type: boolean
                max_matches_per_file:
                  default: 5
                  description: 'Maximum matches to show per file (cap: 50). Keeps responses compact for files with many hits. The response includes matches_in_file (total) so you know if more exist.'
                  maximum: 50
                  minimum: 1
                  type: integer
                max_results:
                  default: 20
                  description: Maximum number of file results to return. Integer between 1 and 100 — values above 100 are rejected, not clamped. Paginate with offset for more.
                  maximum: 100
                  minimum: 1
                  type: integer
                offset:
                  default: 0
                  description: Skip this many results before returning. Use for paging.
                  type: integer
                query:
                  description: 'Search query. Keywords are ANDed — use OR for exploratory multi-term searches (e.g. auth OR login OR session). Prefer single precise terms over multi-keyword phrases. Supports OR, NOT, "phrases", regex (/pattern/), fuzzy (term~1), file:, path:, lang:, ext: filters. Also supports tech:NAME, which restricts results to files that import a detected technology (e.g. "tech:boto3 retry" finds retry logic only in files using boto3). Several tech: terms intersect. tech: needs at least one ordinary search term alongside it — to list every file using a technology, call code_find_usages instead. COVERAGE LIMIT for tech: technology detection reads only the first 150 lines of each file, so files importing further down are excluded from the filter; a file missing from a tech:-filtered search is not proof it does not use the technology.'
                  type: string
                repository:
                  description: 'Full git URL of ONE public remote repository, e.g. "https://github.com/redis/redis". Required. There is no cross-repository or global search: this API analyses one repository per call, cloning it on demand. Wildcards and placeholders ("*", "all", "global", a bare host like "github.com") are rejected — if you do not have a specific repository URL, ask for one rather than guessing.'
                  type: string
                snippet_mode:
                  description: auto (ranked relevance), grep (every matching line), or summary (1 best match per file, no context — very compact). Use auto when exploring or discovering where something is used across a codebase (e.g. "how is authentication handled?"). Use grep when you know the exact identifier or string you want every occurrence of (e.g. "find all calls to parseConfig"). Use summary for broad queries where you want a compact overview of which files match.
                  enum:
                  - auto
                  - grep
                  - summary
                  type: string
              required:
              - repository
              - query
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                type: object
          description: Successful response
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Bad request (invalid params or missing client)
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Repository or file not found
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Rate limited
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Internal server error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Bad gateway (upstream clone failure)
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIError'
          description: Service unavailable (clone queue full)
      summary: Fast code search across any public git repo.
      tags:
      - Code Search
components:
  schemas:
    APIError:
      properties:
        error:
          properties:
            code:
              description: Machine-readable error code
              type: string
            message:
              description: Human-readable error message
              type: string
            retry_after_seconds:
              description: Seconds to wait before retrying (for rate-limited requests)
              type: integer
            suggestion:
              description: Suggested action to resolve the error
              type: string
          required:
          - code
          - message
          type: object
      type: object
  parameters:
    client:
      description: Client identifier for your application (e.g. 'my-app-v1'). Required for all REST API requests.
      in: query
      name: client
      required: true
      schema:
        type: string