Get the diff of a commit¶
GET /api/v5/repos/{owner}/{repo}/commit/{sha}/diff
This endpoint returns the diff of a specific commit in the specified repository. Pass the namespace address that owns the repository, the repository path, and the commit SHA to query the diff data for that commit and view the code changes.
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 organization or user) |
repo |
path | string | Yes | Repository path (path) |
sha |
path | string | Yes | Commit SHA |
Response parameters¶
The response body is a JSON object containing the commit's diff data. The reference documentation does not specify the exact field structure; the actual fields are those returned by the backend.
Error response¶
This endpoint has no business failure response.
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
304 |
Not modified |
401 |
Authentication required |
403 |
Forbidden |
Request example¶
Note: This endpoint allows anonymous access, so the example does not include an access token. You can also include an access token (access_token) if needed.
Parameter description¶
Replace
<owner>with the address path of the namespace that owns the repository (address path of the organization or user); Replace<repo>with the repository path (path); Replace<sha>with the SHA of the commit.
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commit/<sha>/diff' \
-H 'Accept: application/json'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commit/<sha>/diff", {
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>/commit/<sha>/diff",
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
400 |
Parameter error or the request cannot be parsed |
404 |
The requested path does not exist |
405 |
Request method not supported |
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