# GET /repo/file: $0.002 per call

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 long files. Pass ?owner=honojs&repo=hono&path=src/hono.ts&max_chars=20000. List files first with /repo/tree. Binary files are refused (not charged).

- **Price:** $0.002 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:** raw.githubusercontent.com (free)
- **Lane:** AI coding agents ([OpenAPI](/openapi/coding.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-file](/sample/repo-file). It is a stored real answer when we have one, otherwise an example marked `"kind": "illustrative"`.

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

## 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/file?owner=honojs&repo=hono&path=package.json&max_chars=600"
```

## 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/file?owner=honojs&repo=hono&path=package.json&max_chars=600");
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-file", {"owner":"honojs","repo":"hono","path":"package.json","max_chars":600});
```

## Inputs

- `owner` **(required)** (string): GitHub user or organisation, e.g. honojs.
- `repo` **(required)** (string): Repository name, e.g. hono.
- `path` **(required)** (string): File path from the repository root, e.g. src/hono.ts.
- `ref` (string; default `main`): Branch, tag or commit (default main; master is tried if main doesn't exist).
- `from_line` (integer): Start at this line (for reading long files in parts).
- `max_chars` (integer; default `20000`): Most characters to return (trimmed at a line end).
- `line_numbers` (boolean; default `false`): Prefix each line with its number.

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
{
  "owner": "honojs",
  "repo": "hono",
  "ref": "main",
  "path": "package.json",
  "url": "https://github.com/honojs/hono/blob/main/package.json",
  "bytes": 23679,
  "content": "{\n  \"name\": \"hono\",\n  \"version\": \"4.13.11\",\n  \"description\": \"Web framework built on Web Standards\",\n  \"main\": \"dist/cjs/index.js\",\n  \"type\": \"module\",\n  \"module\": \"dist/index.js\",\n  \"types\": \"dist/types/index.d.ts\",\n  \"files\": [\n    \"dist\",\n    \"!dist/**/*.tsbuildinfo\"\n  ],\n  \"scripts\": {\n    \"test\": \"tsc -p tsconfig.spec.json && vp test --run\",\n    \"test:watch\": \"vp test --watch\",",
  "lines": 706,
  "fromLine": 1,
  "toLine": 15,
  "truncated": true,
  "note": "Trimmed to max_chars; ask again with from_line to read on. The file keeps its repository's licence."
}
```

## Related

- [GET /docs/find](/services/docs-find) ($0.003): Find the AI-ready docs for any library or API: checks the project's docs site (from its npm, PyPI, crates or Go metadata) or any company domain (docs., develope
- [GET /docs/lib](/services/docs-lib) ($0.005): Up-to-date docs for any npm, PyPI, crates or Go library, trimmed for a coding agent's context: finds the project's own llms.txt and docs pages (or the latest re
- [POST /docs/answer](/services/docs-answer) ($0.02): Ask a coding question about any npm, PyPI, crates or Go library and get an answer written only from its current docs (project llms.txt, docs pages or latest REA
- [GET /openapi](/services/openapi) ($0.005): Understand any public API fast: give its OpenAPI/Swagger spec URL, its docs or base URL, or a name from the APIs.guru directory (?api=stripe.com); we find the s
- [GET /library/research](/services/library-research) ($0.10): Premium research report on a library or API for coding agents: reads its current docs for your goal, checks version, safety and repository health, gathers what 
- [GET /package/check](/services/package-check) ($0.005): Should a coding agent install this package?
- [GET /dependency/verdict](/services/dependency-verdict) ($0.03): "Should I use this dependency?" in one call for npm, PyPI, crates or Go: full package safety check (vulnerabilities, malware, typosquats, deprecation, licence, 
- [GET /dependency/report](/services/dependency-report) ($0.08): Premium "should I use this dependency?" report: package safety (vulnerabilities, malware, typosquats, deprecation), GitHub repository health, licence compatibil

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