Get all repository commits¶
GET /api/v5/repos/{owner}/{repo}/commits
This endpoint retrieves all commits in the specified repository. You can filter results by commit SHA, file path, author, and time range, and browse the commit history with pagination.
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 |
query | string | No | Starting commit SHA |
path |
query | string | No | Commits that include this file |
author |
query | string | No | Email address or personal namespace address of the commit author (username/login) |
since |
query | string | No | Start time of the commits; time format (2024-11-08T16:25:44Z) |
until |
query | string | No | End time of the commits; time format (2024-11-08T16:25:44Z) |
page |
query | string | No | Current page number |
per_page |
query | string | No | Number of items per page; maximum 100, default 20 |
Response parameters¶
The response body is an array; each element represents one commit and has the following fields:
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
url |
string | Yes | No | URL of the commit details |
sha |
string | Yes | No | SHA of the commit |
html_url |
string | Yes | No | HTML page URL of the commit |
comments_url |
string | Yes | No | URL of the commit comments endpoint |
commit |
object | Yes | No | Commit content (author, committer, tree, commit message) |
author |
object | Yes | No | Commit author information |
committer |
object | Yes | No | Committer information |
parents |
object[] | Yes | No | List of parent commits |
co_authors |
object[] | Yes | No | List of co-authors |
commit object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
commit.author |
object | Yes | No | Author information in the commit |
commit.committer |
object | Yes | No | Committer information in the commit |
commit.tree |
object | Yes | No | File tree for the commit |
commit.message |
string | Yes | No | Commit message |
commit.author object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
commit.author.name |
string | Yes | No | Author name |
commit.author.date |
string | Yes | No | Commit time |
commit.author.email |
string | Yes | No | Author email |
commit.author.login |
string | Yes | No | Author login name |
commit.committer object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
commit.committer.name |
string | Yes | No | Committer name |
commit.committer.date |
string | Yes | No | Commit time |
commit.committer.email |
string | Yes | No | Committer email |
commit.committer.login |
string | Yes | No | Committer login name |
commit.tree object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
commit.tree.sha |
string | Yes | No | SHA of the file tree |
commit.tree.url |
string | Yes | No | File tree URL |
author object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
author.name |
string | Yes | No | Author name |
author.email |
string | Yes | No | Author email |
author.id |
integer | Yes | No | Author user ID |
author.login |
string | Yes | No | Author login name |
author.type |
string | Yes | No | Author type (for example, User) |
author.object_id |
string | Yes | No | Author object ID |
committer object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
committer.name |
string | Yes | No | Committer name |
committer.date |
string | Yes | No | Commit time |
committer.email |
string | Yes | No | Committer email |
committer.id |
integer | Yes | No | Committer user ID |
committer.login |
string | Yes | No | Committer login name |
committer.type |
string | Yes | No | Committer type (for example, User) |
committer.object_id |
string | Yes | No | Committer object ID |
parents array element object¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
parents[].sha |
string | Yes | No | SHA of the parent commit |
parents[].url |
string | Yes | No | Parent commit URL |
co_authors array element 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¶
Besides the success response, callers also need to understand the shape of a failure response in order to write error handling.
400 Parameter error
401 Unauthenticated
404 Not found
The actual error field names are those returned by the backend.
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Authentication required |
403 |
Forbidden |
404 |
Resource not found |
Request example¶
Parameter description¶
This endpoint allows anonymous access, so the example does not include a token by default. To access a private repository, append access_token=<token> to the query parameters.
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).
cURL¶
curl -X GET 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/commits' \
-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", {
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",
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/mactribe/test02/commits/66a12f572722ebe2cad44f44d48e253a0f027e09",
"sha": "66a12f572722ebe2cad44f44d48e253a0f027e09",
"html_url": "https://api.atomgit.com/mactribe/test02/commits/detail/66a12f572722ebe2cad44f44d48e253a0f027e09",
"comments_url": "https://api.atomgit.com/api/v5/repos/mactribe/test02/commits/66a12f572722ebe2cad44f44d48e253a0f027e09/comments",
"commit": {
"author": {
"name": "dengmengmian",
"date": "2024-09-25T08:14:59+08:00",
"email": "my@dengmengmian.com",
"login": "dengmengmian"
},
"committer": {
"name": "dengmengmian",
"date": "2024-09-25T08:14:59+08:00",
"email": "my@dengmengmian.com",
"login": "dengmengmian"
},
"tree": {
"sha": "6214a5921eda7f5148f249587b74201d5946a6d4",
"url": "https://api.atomgit.com/api/v5/repos/mactribe/test02/git/trees/6214a5921eda7f5148f249587b74201d5946a6d4"
},
"message": "feat: change all issue numbers to string type"
},
"author": {
"name": "dengmengmian",
"email": "my@dengmengmian.com",
"id": 10086,
"login": "dengmengmian",
"type": "User",
"object_id": "1"
},
"committer": {
"name": "dengmengmian",
"date": "2024-09-25T08:14:59+08:00",
"email": "my@dengmengmian.com",
"id": 10086,
"login": "dengmengmian",
"type": "User",
"object_id": "1"
},
"parents": [
{
"sha": "0c41318014c472534a2abc2e0aa498fd49d046f1",
"url": "https://api.atomgit.com/api/v5/repos/mactribe/test02/commits/0c41318014c472534a2abc2e0aa498fd49d046f1"
}
],
"co_authors": [
{
"id": "1",
"login": "dengmengmian",
"name": "dengmengmian",
"avatar_url": "https://api.atomgit.com/avatar.png",
"html_url": "https://api.atomgit.com/dengmengmian",
"email": "my@dengmengmian.com"
}
]
}
]
Error codes¶
| Error code | Description |
|---|---|
400 |
Parameter error or the request cannot be parsed |
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
404 |
The requested resource 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