---
title: "Get file blame"
method: GET
path: "/api/blame"
tags: ["Git"]
---

# Get file blame

`GET /api/blame`

Returns blame information for a file at a given repository path and optional git ref.

The response is split into two parts:
- `ranges`: contiguous, non-overlapping line ranges, each attributed to a single commit. Ordered by `startLine`.
- `commits`: commit metadata (hash, date, message, author, optional `previous` pointer for walking back through history) keyed by hash, deduplicated across ranges.

Whole-file renames are followed automatically. Cross-file line moves and copies are not.

## Query parameters

- `path` string, required — The file path to blame, relative to the repository root.
- `repo` string, required — The fully-qualified repository name.
- `ref` string — The git ref (branch, tag, or commit SHA) to blame at. Defaults to the repository's default branch.

## Response `200`

Blame ranges and deduplicated commit metadata.

- PublicFileBlameResponse
  - `ranges` object[], required — Contiguous, non-overlapping line ranges ordered by startLine. Each range is attributed to a single commit.
    - `hash` string, required — The hash of the commit that last modified the lines in this range.
    - `path` string, required — The file path as it existed at the attributing commit. May differ from the current path due to renames.
    - `startLine` integer, required — The 1-based line number where the range begins (inclusive).
    - `lineCount` integer, required — The number of contiguous lines in this range.
  - `commits` object, required — Commit metadata keyed by hash, deduplicated across ranges.

## Other responses

- `400` — Invalid query parameters or git ref.
- `404` — Repository or file not found.
- `500` — Unexpected blame retrieval failure.

---

[API](https://skmtc.dev/sourcebot/apis/sourcebot-public-api.md) · [All operations](https://skmtc.dev/sourcebot/apis/sourcebot-public-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/sourcebot/sourcebot-public-api/revisions/b0ed96fb7103/schema)
