Skip to content

Get code contribution

GET /api/v5/{owner}/{repo}/repository/commit_statistics

This endpoint returns code contribution statistics for a branch in the specified repository, including commit records and each user's added and deleted lines and commit counts. You can filter the statistics by author and date range.

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)
branch_name query string Yes Branch name
author query string No Author username
only_self query boolean No Whether to query only your own contributions
since query string No Return only commits on or after this date
until query string No Return only commits on or before this date
access_token query string No User authorization code

Response parameters

Field Type Always returned Nullable Description
commits object[] Yes No List of commit records
statistics object[] Yes No List of code contribution statistics
total integer Yes No Number of statistics entries

commits object

Field Type Always returned Nullable Description
commits.author_name string Yes No Author username
commits.date string Yes No Commit date

statistics object

Field Type Always returned Nullable Description
statistics.project_id integer Yes No Repository ID
statistics.branch string Yes No Branch name
statistics.user_name string Yes No Username
statistics.nick_name string Yes No Nickname
statistics.add_lines integer Yes No Number of code lines added
statistics.delete_lines integer Yes No Number of code lines deleted
statistics.commit_count integer Yes No Number of commits

Error response

400 Parameter error

{
  "error": "invalid_request",
  "message": "Parameter branch_name cannot be empty"
}

401 Unauthenticated

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

HTTP response status codes

Status code Description
200 Success (OK)
400 Bad request
401 Authentication required
403 Forbidden
404 Resource not found
405 Method not allowed
429 Too many requests
500 Internal server error

Request example

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 <branch_name> with the name of the branch to collect statistics for. The optional query parameters author, only_self, since, until, and access_token can be added as needed.

cURL

curl -X GET 'https://api.atomgit.com/api/v5/<owner>/<repo>/repository/commit_statistics?branch_name=<branch_name>' \
  -H 'Accept: application/json'

JavaScript

// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/<owner>/<repo>/repository/commit_statistics?branch_name=<branch_name>", {
  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/<owner>/<repo>/repository/commit_statistics",
    params={"branch_name": "<branch_name>"},
    headers={
        "Accept": "application/json",
    },
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "commits": [
    {
      "author_name": "tester",
      "date": "2024-11-12"
    },
    {
      "author_name": "tester",
      "date": "2024-01-15"
    }
  ],
  "statistics": [
    {
      "project_id": 1359,
      "branch": "main",
      "user_name": "tester",
      "nick_name": "Test",
      "add_lines": 4370,
      "delete_lines": 351,
      "commit_count": 123
    }
  ],
  "total": 1
}

Error codes

Error code Description
400 Parameter error or the request cannot be parsed
401 Unauthenticated or invalid credentials (missing/invalid access credentials)
403 Forbidden (no permission)
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