Skip to content

A commit in a repository

GET /api/v5/repos/{owner}/{repo}/commits/{sha}

This endpoint returns details about a specific commit in the specified repository, including the commit information, author and committer, change statistics, and the list of changed files. Use the show_diff parameter to control whether the file change details are returned.

Access token support

  • AtomGit user access tokens

Anonymous access

This endpoint allows anonymous access.

Request parameters

Parameter Location Type Required Description
owner path string Yes Address path of the namespace that owns the repository (address path of the enterprise, organization, or user)
repo path string Yes Repository path (path)
sha path string Yes SHA of the commit or a branch name
show_diff query boolean No Defaults to false; when true, returns the files field containing up to 100 changed file names from the commit

Response parameters

Field Type Always returned Nullable Description
url string Yes No API URL of the commit
sha string Yes No SHA of the commit
html_url string Yes No Web page URL of the commit
comments_url string Yes No API URL of the commit comments
commit object Yes No Commit information
stats object Yes No Commit statistics
files object[] No Yes List of changed files; returned when show_diff=true, up to 100
parents object[] Yes No List of parent commits
co_authors object[] Yes Yes List of co-authors

commit object

Field Type Always returned Nullable Description
commit.author object Yes No Commit author information
commit.committer object Yes No Committer information
commit.message string Yes No Commit information

commit.author object

Field Type Always returned Nullable Description
commit.author.name string Yes No Author name
commit.author.date string Yes No Commit date (ISO 8601 format)
commit.author.email string Yes No Author email

commit.committer object

Field Type Always returned Nullable Description
commit.committer.name string Yes No Committer name
commit.committer.date string Yes No Commit date (ISO 8601 format)
commit.committer.email string Yes No Committer email

stats object

Field Type Always returned Nullable Description
stats.additions integer Yes No Lines added
stats.deletions integer Yes No Lines deleted
stats.total integer Yes No Total lines changed

files object

Field Type Always returned Nullable Description
files[].sha string No Yes SHA of the file within the commit
files[].filename string No Yes Changed file name
files[].status string No Yes File status
files[].additions integer No Yes Lines added
files[].deletions integer No Yes Lines deleted
files[].changes integer No Yes Lines changed
files[].raw_url string No Yes Raw file URL
files[].content_url string No Yes File content URL

parents object

Field Type Always returned Nullable Description
parents[].sha string Yes No SHA of the parent commit
parents[].url string Yes No API URL of the parent commit

co_authors object

Field Type Always returned Nullable Description
co_authors[].id string Yes No Co-author ID
co_authors[].login string Yes No Co-author login name
co_authors[].name string Yes No Co-author name
co_authors[].avatar_url string Yes No Co-author avatar URL
co_authors[].html_url string Yes No Co-author profile URL
co_authors[].email string Yes No Co-author email

Error response

This endpoint returns an error response when parameter validation fails, the commit does not exist, or authentication fails. The actual error field names are those returned by the backend.

400 Parameter error

{
  "error": "invalid_request",
  "message": "Parameter validation failed"
}

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

404 Commit not found

{
  "error": "not_found",
  "message": "Repository or commit not found"
}

HTTP response status codes

Status code Description
200 Success (OK)
304 Not modified
401 Authentication required
404 Repository or commit not found

Request example

Parameter description

This endpoint allows anonymous access, so the request does not need to include an access token. To access private repository resources, you can also include an AtomGit user access token.

Replace <owner> with the address path of the namespace that owns the repository (address path of the enterprise, organization, or user); Replace <repo> with the repository path (path); Replace <sha> with the SHA of the commit or a branch name.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>?show_diff=true' -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>?show_diff=true", {
  headers: {
    "Accept": "application/json",
  },
});

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const data = await response.json();
console.log(data);

Python

import requests

resp = requests.get(
    "https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits/<sha>?show_diff=true",
    headers={"Accept": "application/json"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "url": "https://api.atomgit.com/api/v5/repos/daming_1/zhu_di/commits/7ffc0a0deb709143f6be12a55e218fab9233ca37",
  "sha": "7ffc0a0deb709143f6be12a55e218fab9233ca37",
  "html_url": "https://api.atomgit.com/daming_1/zhu_di/commit/7ffc0a0deb709143f6be12a55e218fab9233ca37",
  "comments_url": "https://api.atomgit.com/api/v5/repos/daming_1/zhu_di/commits/7ffc0a0deb709143f6be12a55e218fab9233ca37/comments",
  "commit": {
    "author": {
      "name": "Zhan Fen",
      "date": "2024-04-14T07:25:11+00:00",
      "email": "7543745+centking@user.noreply.atomgit.com"
    },
    "committer": {
      "name": "AtomGit",
      "date": "2024-04-14T07:25:11+00:00",
      "email": "noreply@atomgit.com"
    },
    "message": "Commit message test"
  },
  "stats": {
    "additions": 1,
    "deletions": 1,
    "total": 2
  },
  "files": [
    {
      "sha": "b0e267d8bbed9b568623528c216f8f8489689a61",
      "filename": "pom.xml",
      "status": "modified",
      "additions": 1,
      "deletions": 1,
      "changes": 2,
      "raw_url": "https://raw.atomgit.com/test-owner/test-repo/raw/b0e267d8bbed9b568623528c216f8f8489689a61/pom.xml",
      "content_url": "https://api.atomgit.com/test-owner/test-repo/blob/b0e267d8bbed9b568623528c216f8f8489689a61/pom.xml"
    }
  ],
  "parents": [
    {
      "sha": "6c7a2c0a5c5b2a3c4d5e6f7a8b9c0d1e2f3a4b5c",
      "url": "https://api.atomgit.com/api/v5/repos/daming_1/zhu_di/commits/6c7a2c0a5c5b2a3c4d5e6f7a8b9c0d1e2f3a4b5c"
    }
  ],
  "co_authors": [
    {
      "id": "12345",
      "login": "octocat",
      "name": "Octo Cat",
      "avatar_url": "https://api.atomgit.com/avatar/octocat.png",
      "html_url": "https://api.atomgit.com/octocat",
      "email": "octocat@atomgit.com"
    }
  ]
}

Error codes

Error code Description
400 Parameter error or the request cannot be parsed
401 Unauthenticated or invalid credentials
404 Repository or commit not found
429 Too many requests; rate limit triggered
500 Internal system error

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc