Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-10-12. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

事件

事件 API 是 GitHub 事件的只读 API。

这些事件推动站点上的各种活动流。

事件 API 可以返回 GitHub Enterprise Server 上的活动触发的不同类型事件。 有关可从事件 API 接收的特定事件的详细信息,请参阅“GitHub 事件类型”。 存储库问题的事件 API 也可用。 有关详细信息,请参阅“议题事件 API”。

事件针对使用 "ETag" � �头的轮询进行了优化。 如果未触发任何新事件,您将会看到一个 "304 Not Modified" 响应,并且您的当前速率限制不受影响。 还有一个 "X-Poll-Interval" � �头,用于指定允许您轮询的间隔时间(以秒为单位)。 在服务器负载较高时,该时间可能会增� 。 请遵循� �头指示。

$ curl -I http(s)://HOSTNAME/api/v3/users/tater/events
> HTTP/2 200
> X-Poll-Interval: 60
> ETag: "a18c3bded88eb5dbb5c849a489412bf3"

# The quotes around the ETag value are important
$ curl -I http(s)://HOSTNAME/api/v3/users/tater/events \
$    -H 'If-None-Match: "a18c3bded88eb5dbb5c849a489412bf3"'
> HTTP/2 304
> X-Poll-Interval: 60

时间表中只包含过去 90 天内创建的事件。 超过 90 天的活动将不包括在内(即使时间表中的活动总数不到 300 个)。

List public events

We delay the public events feed by five minutes, which means the most recent event returned by the public events API actually occurred at least five minutes ago.

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

304

Not modified

403

Forbidden

503

Service unavailable

代� �示例

get/events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/events

Response

Status: 200
[ { "id": "22249084947", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-07T07:50:26Z" } ]

List public events for a network of repositories

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

301

Moved permanently

304

Not modified

403

Forbidden

404

Resource not found

代� �示例

get/networks/{owner}/{repo}/events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/networks/OWNER/REPO/events

Response

Status: 200
[ { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22237752260", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/rrubenich", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-08T23:29:25Z" } ]

List public organization events

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/orgs/{org}/events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/orgs/ORG/events

Response

Status: 200
[ { "id": "22237752260", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octo-org/octo-repo", "url": "https://api.github.com/repos/octo-org/octo-repo" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-08T23:29:25Z" }, { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octo-org/octo-repo", "url": "https://api.github.com/repos/octo-org/oct-repo" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octo-org/oct-repo/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-09T12:47:28Z" } ]

List repository events

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/repos/{owner}/{repo}/events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/events

Response

Status: 200
[ { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22237752260", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-08T23:29:25Z" } ]

List events for the authenticated user

If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events.

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/users/{username}/events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/events

Response

Status: 200
[ { "id": "22249084947", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": false, "created_at": "2022-06-07T07:50:26Z" } ]

List organization events for the authenticated user

This is the user's organization dashboard. You must be authenticated as the user to view this.

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/users/{username}/events/orgs/{org}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/events/orgs/ORG

Response

Status: 200
[ { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": false, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22196946742", "type": "CreateEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "ref": null, "ref_type": "repository", "master_branch": "master", "description": null, "pusher_type": "user" }, "public": false, "created_at": "2022-06-07T07:50:26Z", "org": { "id": 9919, "login": "github", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "avatar_url": "https://avatars.githubusercontent.com/u/9919?" } } ]

List public events for a user

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/users/{username}/events/public
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/events/public

Response

Status: 200
[ { "id": "22249084947", "type": "WatchEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "action": "started" }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-08T23:29:25Z" } ]

List events received by the authenticated user

These are events that you've received by watching repos and following users. If you are authenticated as the given user, you will see private events. Otherwise, you'll only see public events.

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/users/{username}/received_events
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/received_events

Response

Status: 200
[ { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22196946742", "type": "CreateEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "ref": null, "ref_type": "repository", "master_branch": "master", "description": null, "pusher_type": "user" }, "public": false, "created_at": "2022-06-07T07:50:26Z", "org": { "id": 9919, "login": "github", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "avatar_url": "https://avatars.githubusercontent.com/u/9919?" } } ]

List public events received by a user

参数

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
usernamestringRequired

The handle for the GitHub user account.

Query parameters
Name, Type, Description
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP 响应状态代� �

状态代� �说明
200

OK

代� �示例

get/users/{username}/received_events/public
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/users/USERNAME/received_events/public

Response

Status: 200
[ { "id": "22249084964", "type": "PushEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "push_id": 10115855396, "size": 1, "distinct_size": 1, "ref": "refs/heads/master", "head": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "before": "883efe034920928c47fe18598c01249d1a9fdabd", "commits": [ { "sha": "7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300", "author": { "email": "octocat@github.com", "name": "Monalisa Octocat" }, "message": "commit", "distinct": true, "url": "https://api.github.com/repos/octocat/Hello-World/commits/7a8f3ac80e2ad2f6842cb86f576d4bfe2c03e300" } ] }, "public": true, "created_at": "2022-06-09T12:47:28Z" }, { "id": "22196946742", "type": "CreateEvent", "actor": { "id": 583231, "login": "octocat", "display_login": "octocat", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "avatar_url": "https://avatars.githubusercontent.com/u/583231?v=4" }, "repo": { "id": 1296269, "name": "octocat/Hello-World", "url": "https://api.github.com/repos/octocat/Hello-World" }, "payload": { "ref": null, "ref_type": "repository", "master_branch": "master", "description": null, "pusher_type": "user" }, "public": false, "created_at": "2022-06-07T07:50:26Z", "org": { "id": 9919, "login": "github", "gravatar_id": "", "url": "https://api.github.com/orgs/github", "avatar_url": "https://avatars.githubusercontent.com/u/9919?" } } ]