# GET /repo/search: $0.005 per call

Search inside one public GitHub repository: every line where a word or code snippet appears, with file, line number and a link. Reads up to 120 likely source files per call (skips vendored, built and lock files) and says how many it covered; may lag GitHub by up to 12 hours; narrow big repos with path=src/ or ext=ts. Pass ?owner=honojs&repo=hono&q=getCookie. Then read a file with /repo/file.

- **Price:** $0.005 in USDC, the same on Base, Solana, Polygon, Arbitrum. Failed calls are never charged.
- **Free trial:** yes, 20 free calls a day from Claude, Cursor or any MCP client ([set-up](/mcp/setup)).
- **Answers cached for:** 30 min
- **Data sources:** jsDelivr (mirror of public GitHub repositories, free)
- **Lane:** GitHub repositories ([OpenAPI](/openapi/repos.json))
- **Live health:** [status page](/status)

## Free sample

See an answer for the demo input first, free (no payment, 10 a minute): [https://aayatai.com/sample/repo-search](/sample/repo-search). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

```bash
curl "https://aayatai.com/sample/repo-search"
```

## 1. See the price (free)

Call it without paying: you get `402 Payment Required` and a `PAYMENT-REQUIRED` header with the exact price and where to pay.

```bash
curl -i "https://aayatai.com/repo/search?owner=honojs&repo=hono&q=getCookie&path=src%2Fhelper%2Fcookie%2F&limit=3"
```

## 2. Pay and call (TypeScript)

```bash
npm install @x402/fetch @x402/evm viem
```

```ts
import { wrapFetchWithPaymentFromConfig } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm";
import { privateKeyToAccount } from "viem/accounts";

// A wallet used only by your agent, holding a little USDC on Base.
const account = privateKeyToAccount(process.env.WALLET_PRIVATE_KEY as `0x${string}`);
const pay = wrapFetchWithPaymentFromConfig(fetch, {
  schemes: [{ network: "eip155:8453", client: new ExactEvmScheme(account) }],
});

const res = await pay("https://aayatai.com/repo/search?owner=honojs&repo=hono&q=getCookie&path=src%2Fhelper%2Fcookie%2F&limit=3");
console.log(await res.json());
```

## 3. Or as an MCP tool

```ts
// MCP server: https://aayatai.com/mcp (Streamable HTTP). With the x402 MCP client (see /start):
const result = await client.callTool("repo-search", {"owner":"honojs","repo":"hono","q":"getCookie","path":"src/helper/cookie/","limit":3});
```

## Inputs

- `owner` **(required)** (string): GitHub user or organisation, e.g. honojs.
- `repo` **(required)** (string): Repository name, e.g. hono.
- `q` **(required)** (string): Text to find (exact text, not a pattern), e.g. getCookie.
- `ref` (string; default `main`): Branch, tag or commit (default main; master is tried if main doesn't exist).
- `path` (string): Only files under this folder, e.g. src/.
- `ext` (string): Only these file extensions, comma-separated, e.g. ts,tsx.
- `case_sensitive` (boolean; default `false`): Match upper/lower case exactly.
- `limit` (integer; default `30`): Most matching lines to return.
- `detail` (string; one of `full`, `brief`; default `full`): brief = key fields only (same price)

Bad inputs are rejected with HTTP 400 before any payment is asked for.

## Example answer

Example only: the shape of an answer, with placeholder addresses and made-up figures. It is not data about any real token or wallet; call the service (or its free sample) for real results.

```json
{
  "repo": "honojs/hono",
  "ref": "main",
  "query": "getCookie",
  "matches": [
    {
      "path": "src/helper/cookie/index.ts",
      "line": 10,
      "text": "interface GetCookie {",
      "url": "https://github.com/honojs/hono/blob/main/src/helper/cookie/index.ts#L10"
    },
    {
      "path": "src/helper/cookie/index.ts",
      "line": 27,
      "text": "export const getCookie: GetCookie = (c, key?, prefix?: CookiePrefixOptions) => {",
      "url": "https://github.com/honojs/hono/blob/main/src/helper/cookie/index.ts#L27"
    }
  ],
  "files": [
    {
      "path": "src/helper/cookie/index.test.ts",
      "count": 8
    },
    {
      "path": "src/helper/cookie/index.ts",
      "count": 3
    }
  ],
  "totalMatches": 11,
  "filesSearched": 2,
  "candidateFiles": 2,
  "complete": true,
  "source": "Files from jsDelivr (mirrors public GitHub repositories); each file keeps its repository's licence."
}
```

## Related

- [GET /repo/tree](/services/repo-tree) ($0.002): Every file in a public GitHub repository at a branch or tag, with sizes: the map an agent needs before reading code.
- [GET /repo/file](/services/repo-file) ($0.002): Read one file from a public GitHub repository at any branch, tag or commit, as text trimmed to a budget you set, with optional line numbers and a start line for

New here? [Getting started in 60 seconds](/start). All services: [Aayat AI](/).