Skip to main content
Streams the full diff for a commit to help you review file-level changes.
GET /api/v1/repos/diff?sha=COMMIT_SHA&baseSha=BASE_COMMIT_SHA&path=src/main.go&path=README.md
Authorization: Bearer YOUR_JWT_TOKEN

Parameters

ParameterTypeDescription
shaRequiredThe full commit SHA to get the diff for
baseShaOptionalBase commit SHA to compare against. If not specified, compares against the commit’s parent(s)
pathOptionalFile path(s) to filter the diff. Can be specified multiple times to include multiple files. When provided, only returns diffs for the specified files and bypasses size/type filtering

JWT Requirements

  • The JWT must include the repository in the repo claim
  • Requires git:read scope

Response

{
  "sha": "b003fc78805954584e1ee364a4ad39d7c79e819a",
  "stats": {
    "files": 3,
    "additions": 50,
    "deletions": 10,
    "changes": 60
  },
  "files": [
    {
      "path": "src/main.go",
      "state": "M",
      "old_path": "",
      "bytes": 2048,
      "is_eof": true,
      "raw": "diff --git a/src/main.go b/src/main.go\nindex abc123..def456 100644\n--- a/src/main.go\n+++ b/src/main.go\n@@ -10,6 +10,8 @@\n+func newFunction() {\n+    // New implementation\n+}\n"
    },
    {
      "path": "README.md",
      "state": "A",
      "old_path": "",
      "bytes": 512,
      "is_eof": true,
      "raw": "diff --git a/README.md b/README.md\nnew file mode 100644\nindex 0000000..abc123\n--- /dev/null\n+++ b/README.md\n@@ -0,0 +1,5 @@\n+# Project Title\n+\n+Description of the project\n"
    }
  ],
  "filtered_files": [
    {
      "path": "package-lock.json",
      "state": "M",
      "old_path": "",
      "bytes": 50000,
      "is_eof": true
    }
  ]
}

Notes

  • The diff includes both file-level changes and line-by-line diffs
  • When baseSha is not provided, the diff shows changes from the commit’s parent(s)
  • When baseSha is provided, the diff shows changes between the base commit and the target commit (useful for comparing specific commits)
  • Large files (>500KB) or files with too many changes (>2000 lines) are included in filtered_files without diff content
  • Binary files and lock files are automatically filtered
  • When path is specified, size and type filtering is bypassed—requested files are always returned with full diff content
  • The is_eof field indicates whether the file ends with a newline
  • Git status codes: A (added), M (modified), D (deleted), R (renamed), C (copied), T (type changed)

Error Responses

StatusDescription
404 Not FoundCommit doesn’t exist
401 UnauthorizedInvalid JWT or missing git:read scope
400 Bad RequestMissing or invalid SHA parameter