# 리포지토리 통계에 대한 REST API 엔드포인트

REST API를 사용하여 GitHub에서 다양한 유형의 리포지토리 활동을 시각화하는 데 사용하는 데이터를 가져옵니다.

## 리포지토리 통계 정보

REST API를 사용하여 GitHub에서 다양한 유형의 리포지토리 활동을 시각화하는 데 사용하는 데이터를 가져올 수 있습니다.

### 캐싱에 대한 모범 사례

리포지토리 통계 컴퓨팅은 비용이 많이 드는 작업이므로 가능하면 캐시된 데이터를 반환하려고 합니다. 리포지토리의 통계를 쿼리할 때 데이터가 캐시되지 않은 경우 `202` 응답을 받게 됩니다. 해당 통계를 컴파일하기 위한 백그라운드 작업도 발생합니다. 작업을 짧은 시간 동안 완료하도록 허용한 다음 요청을 다시 제출해야 합니다. 작업이 완료되면 해당 요청은 응답 본문에 통계가 포함된 `200` 응답을 받게 됩니다.

리포지토리 통계는 리포지토리의 기본 분기의 SHA에 의해 캐시됩니다. 기본 분기로 푸시하면 통계 캐시가 다시 설정됩니다.

### 통계는 일부 유형의 커밋을 제외합니다.

API에서 노출하는 통계는 [다른 리포지토리 그래프](/ko/enterprise-server@3.22/repositories/viewing-activity-and-data-for-your-repository/about-repository-graphs)에 표시된 통계와 일치합니다.

이를 요약하려면 다음을 수행합니다.

* 모든 통계는 병합 커밋을 제외합니다.
* 기여자 통계는 빈 커밋도 제외합니다.

> \[!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## Get the weekly commit activity

```
GET /repos/{owner}/{repo}/stats/code_frequency
```

Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

### HTTP response status codes

* **200** - Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

* **202** - Accepted

* **204** - A header with no content is returned.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/code_frequency
```

**Response schema (Status: 200):**

Array of array

## Get the last year of commit activity

```
GET /repos/{owner}/{repo}/stats/commit_activity
```

Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

### HTTP response status codes

* **200** - OK

* **202** - Accepted

* **204** - A header with no content is returned.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/commit_activity
```

**Response schema (Status: 200):**

Array of `Commit Activity`:

* `days`: required, array of integer
* `total`: required, integer
* `week`: required, integer

## Get all contributor commit activity

```
GET /repos/{owner}/{repo}/stats/contributors
```

Returns the total number of commits authored by the contributor. In addition, the response includes a Weekly Hash (weeks array) with the following information:

w - Start of the week, given as a Unix timestamp.
a - Number of additions
d - Number of deletions
c - Number of commits

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

### HTTP response status codes

* **200** - OK

* **202** - Accepted

* **204** - A header with no content is returned.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/contributors
```

**Response schema (Status: 200):**

Array of `Contributor Activity`:

* `author`: required, any of:
  * **null**
  * **Simple User**
    * `name`: string or null
    * `email`: string or null
    * `login`: required, string
    * `id`: required, integer, format: int64
    * `node_id`: required, string
    * `avatar_url`: required, string, format: uri
    * `gravatar_id`: required, string or null
    * `url`: required, string, format: uri
    * `html_url`: required, string, format: uri
    * `followers_url`: required, string, format: uri
    * `following_url`: required, string
    * `gists_url`: required, string
    * `starred_url`: required, string
    * `subscriptions_url`: required, string, format: uri
    * `organizations_url`: required, string, format: uri
    * `repos_url`: required, string, format: uri
    * `events_url`: required, string
    * `received_events_url`: required, string, format: uri
    * `type`: required, string
    * `site_admin`: required, boolean
    * `starred_at`: string
    * `user_view_type`: string
* `total`: required, integer
* `weeks`: required, array of objects:
  * `w`: integer
  * `a`: integer
  * `d`: integer
  * `c`: integer

## Get the weekly commit count

```
GET /repos/{owner}/{repo}/stats/participation
```

Returns the total commit counts for the owner and total commit counts in all. all is everyone combined, including the owner in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract owner from all.
The array order is oldest week (index 0) to most recent week.
The most recent week is seven days ago at UTC midnight to today at UTC midnight.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

### HTTP response status codes

* **200** - The array order is oldest week (index 0) to most recent week.

* **404** - Resource not found

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/participation
```

**Response schema (Status: 200):**

* `all`: required, array of integer
* `owner`: required, array of integer

## Get the hourly commit count for each day

```
GET /repos/{owner}/{repo}/stats/punch_card
```

Each array contains the day number, hour number, and number of commits:

0-6: Sunday - Saturday
0-23: Hour of day
Number of commits

For example, \[2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.

### Parameters

#### Headers

* **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

* **`owner`** (string) (required)
  The account owner of the repository. The name is not case sensitive.

* **`repo`** (string) (required)
  The name of the repository without the .git extension. The name is not case sensitive.

### HTTP response status codes

* **200** - For example, \[2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.

* **204** - A header with no content is returned.

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/punch_card
```

**Response schema (Status: 200):**

Same response schema as [Get the weekly commit activity](#get-the-weekly-commit-activity).