Esta versão do GitHub Enterprise Server foi descontinuada em 2024-03-26. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, segurança aprimorada e novos recursos, atualize para a última versão do GitHub Enterprise Server. Para obter ajuda com a atualização, entre em contato com o suporte do GitHub Enterprise.
Pontos de extremidade da API REST para estatísticas do repositório
Use a API REST para buscar os dados usados pelo GitHub Enterprise Server a fim de visualizar diferentes tipos de atividades do repositório.
Sobre estatísticas do repositório
Use a API REST para buscar os dados usados pelo GitHub Enterprise Server a fim de visualizar diferentes tipos de atividades do repositório.
Melhores práticas de armazenamento em cache
Computar as estatísticas do repositório é uma operação cara. Por esse motivo, tentamos retornar dados armazenados em cache sempre que possível.  Se os dados não forem armazenados em cache nas estatísticas de um repositório, você receberá uma resposta 202. Um trabalho em segundo plano também é disparado para começar a compilar essas estatísticas. Você aguardar um tempo curto para que o trabalho seja concluído e, em seguida, enviar a solicitação novamente. Se o trabalho for concluído, essa solicitação receberá uma resposta 200 com as estatísticas no corpo da resposta.
As estatísticas do repositório são armazenadas em cache pelo SHA do branch-padrão do repositório; fazer push para o branch-padrão redefine o armazenamento em cache de estatísticas.
As estatísticas excluem alguns tipos de commits
As estatísticas expostas pela API correspondem às estatísticas mostradas por diferentes grafos de repositório.
Para resumir:
- Todas as estatísticas excluem commits de merge.
- As estatísticas do contribuidor também excluem commits vazios.
Get the weekly commit activity
Returns a weekly aggregate of the number of additions and deletions pushed to a repository.
Parâmetros para "Get the weekly commit activity"
| Nome, Tipo, Descrição | 
|---|
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| ownerstring ObrigatórioThe account owner of the repository. The name is not case sensitive. | 
| repostring ObrigatórioThe name of the repository without the  | 
Códigos de status de resposta HTTP para "Get the weekly commit activity"
| Código de status | Descrição | 
|---|---|
| 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. | 
Exemplos de código para "Get the weekly commit activity"
Exemplo de solicitação
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/code_frequencyReturns a weekly aggregate of the number of additions and deletions pushed to a repository.
Status: 200[
  [
    1302998400,
    1124,
    -435
  ]
]Get the last year of 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.
Parâmetros para "Get the last year of commit activity"
| Nome, Tipo, Descrição | 
|---|
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| ownerstring ObrigatórioThe account owner of the repository. The name is not case sensitive. | 
| repostring ObrigatórioThe name of the repository without the  | 
Códigos de status de resposta HTTP para "Get the last year of commit activity"
| Código de status | Descrição | 
|---|---|
| 200 | OK | 
| 202 | Accepted | 
| 204 | A header with no content is returned. | 
Exemplos de código para "Get the last year of commit activity"
Exemplo de solicitação
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/commit_activityResponse
Status: 200[
  {
    "days": [
      0,
      3,
      26,
      20,
      39,
      1,
      0
    ],
    "total": 89,
    "week": 1336280400
  }
]Get all contributor commit activity
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
Parâmetros para "Get all contributor commit activity"
| Nome, Tipo, Descrição | 
|---|
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| ownerstring ObrigatórioThe account owner of the repository. The name is not case sensitive. | 
| repostring ObrigatórioThe name of the repository without the  | 
Códigos de status de resposta HTTP para "Get all contributor commit activity"
| Código de status | Descrição | 
|---|---|
| 200 | OK | 
| 202 | Accepted | 
| 204 | A header with no content is returned. | 
Exemplos de código para "Get all contributor commit activity"
Exemplo de solicitação
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/contributorsResponse
Status: 200[
  {
    "author": {
      "login": "octocat",
      "id": 1,
      "node_id": "MDQ6VXNlcjE=",
      "avatar_url": "https://github.com/images/error/octocat_happy.gif",
      "gravatar_id": "",
      "url": "https://HOSTNAME/users/octocat",
      "html_url": "https://github.com/octocat",
      "followers_url": "https://HOSTNAME/users/octocat/followers",
      "following_url": "https://HOSTNAME/users/octocat/following{/other_user}",
      "gists_url": "https://HOSTNAME/users/octocat/gists{/gist_id}",
      "starred_url": "https://HOSTNAME/users/octocat/starred{/owner}{/repo}",
      "subscriptions_url": "https://HOSTNAME/users/octocat/subscriptions",
      "organizations_url": "https://HOSTNAME/users/octocat/orgs",
      "repos_url": "https://HOSTNAME/users/octocat/repos",
      "events_url": "https://HOSTNAME/users/octocat/events{/privacy}",
      "received_events_url": "https://HOSTNAME/users/octocat/received_events",
      "type": "User",
      "site_admin": false
    },
    "total": 135,
    "weeks": [
      {
        "w": 1367712000,
        "a": 6898,
        "d": 77,
        "c": 10
      }
    ]
  }
]Get the weekly commit count
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.
Parâmetros para "Get the weekly commit count"
| Nome, Tipo, Descrição | 
|---|
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| ownerstring ObrigatórioThe account owner of the repository. The name is not case sensitive. | 
| repostring ObrigatórioThe name of the repository without the  | 
Códigos de status de resposta HTTP para "Get the weekly commit count"
| Código de status | Descrição | 
|---|---|
| 200 | The array order is oldest week (index 0) to most recent week. | 
| 404 | Resource not found | 
Exemplos de código para "Get the weekly commit count"
Exemplo de solicitação
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/participationThe array order is oldest week (index 0) to most recent week.
Status: 200{
  "all": [
    11,
    21,
    15,
    2,
    8,
    1,
    8,
    23,
    17,
    21,
    11,
    10,
    33,
    91,
    38,
    34,
    22,
    23,
    32,
    3,
    43,
    87,
    71,
    18,
    13,
    5,
    13,
    16,
    66,
    27,
    12,
    45,
    110,
    117,
    13,
    8,
    18,
    9,
    19,
    26,
    39,
    12,
    20,
    31,
    46,
    91,
    45,
    10,
    24,
    9,
    29,
    7
  ],
  "owner": [
    3,
    2,
    3,
    0,
    2,
    0,
    5,
    14,
    7,
    9,
    1,
    5,
    0,
    48,
    19,
    2,
    0,
    1,
    10,
    2,
    23,
    40,
    35,
    8,
    8,
    2,
    10,
    6,
    30,
    0,
    2,
    9,
    53,
    104,
    3,
    3,
    10,
    4,
    7,
    11,
    21,
    4,
    4,
    22,
    26,
    63,
    11,
    2,
    14,
    1,
    10,
    3
  ]
}Get the hourly commit count for each day
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.
Parâmetros para "Get the hourly commit count for each day"
| Nome, Tipo, Descrição | 
|---|
| acceptstringSetting to  | 
| Nome, Tipo, Descrição | 
|---|
| ownerstring ObrigatórioThe account owner of the repository. The name is not case sensitive. | 
| repostring ObrigatórioThe name of the repository without the  | 
Códigos de status de resposta HTTP para "Get the hourly commit count for each day"
| Código de status | Descrição | 
|---|---|
| 200 | For example,  | 
| 204 | A header with no content is returned. | 
Exemplos de código para "Get the hourly commit count for each day"
Exemplo de solicitação
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/stats/punch_cardFor 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.
Status: 200[
  [
    0,
    0,
    5
  ],
  [
    0,
    1,
    43
  ],
  [
    0,
    2,
    21
  ]
]