---
title: "Search repository source"
method: GET
path: "/api/repos/{owner}/{repo}/search"
tags: ["Repositories"]
---

# Search repository source

`GET /api/repos/{owner}/{repo}/search`

## Request

- Base URL: `https://git.cafe`
- URL: `https://git.cafe/api/repos/{owner}/{repo}/search`
- Auth: one of:
  - none
  - API key in cookie `gc-session`
  - HTTP bearer
  - HTTP basic
  - HTTP token
  - OAuth 2
    - Authorization code: `/api/oauth/authorize`
    - Token URL: `/api/oauth/token` scopes: `repo:contents:read`

Searches files at HEAD, a public branch or tag, or an exact commit OID and returns at most 1,000 matches with up to 10 context lines. Public repositories allow anonymous reads; supplied credentials are validated and may expand access to private resources.

## Path parameters

- `owner` string, required
- `repo` string, required

## Query parameters

- `ref` string
- `oid` string
- `path` string
- `pattern` string, required
- `ignoreCase` union
  - boolean
  - string
- `isRegex` union
  - boolean
  - string
- `maxMatches` integer
- `contextLines` integer

## Response `200`

Response for status 200

- object
  - `ref` string, required
  - `commit` string, required
  - `matches` object[], required
    - `lineNumber` integer, required
    - `line` string, required
    - `path` string, required
    - `contextBefore` object[], required
      - `lineNumber` integer, required
      - `line` string, required
    - `contextAfter` object[], required
      - `lineNumber` integer, required
      - `line` string, required
  - `truncated` boolean, required

## Other responses

- `400`: Response for status 400
- `401`: Authentication is required, or the supplied credential is invalid.
- `403`: The credential does not permit this operation. A `code`, when present, names the refusal.
- `404`: Response for status 404
- `409`: The request conflicts with the current state. A `code`, when present, names the refusal; `retryable` says whether the same request can succeed later, and `operationId` names the operation in the way.
- `413`: Response for status 413
- `429`: A rate limit is exhausted. Wait Retry-After seconds; the value is a hint, so back off on a repeat 429.
- `501`: Response for status 501
- `503`: Response for status 503

---

[API](https://skmtc.dev/gitcafe/apis/git-cafe-api.md) - [All operations](https://skmtc.dev/gitcafe/apis/git-cafe-api/llms.txt) - [OpenAPI document](https://skmtc.dev/gitcafe/apis/git-cafe-api/revisions/9fa233d2986d?raw)
