CNB Events
About 1635 wordsAbout 5 min
CNB Events documents the API that records repository events on CNB.
When to use: when you need to trace what happened in a repository over time — for example auditing who pushed code and when, syncing PR and issue changes to your own system, or measuring repository activity.
Overview
Repository events record various types of repository events triggered on CNB. Each event contains common properties and a payload object determined by its event type.
Repository events are recorded in hourly shards. Currently supported event types include:
- CreateEvent
- DeleteEvent
- ForkEvent
- IssueCommentEvent
- IssueEvent
- MemberEvent
- PublicEvent
- PullRequestEvent
- PullRequestReviewEvent
- PullRequestReviewCommentEvent
- PushEvent
- ReleaseEvent
- WatchEvent
API Interface
Get Repository Events Within Specified Time Range
- Endpoint:
/events/{repo_path}/-/{date} - Method:
GET - Input Parameters:
repo_path: Complete repository path, e.g.,cnb/testdate: Time range, queryable by hour or day. Note: Daily queries have a one-day data lag; only the previous day's aggregated data can be queried on the current day.- Hourly query:
yy-mm-dd-h, e.g.,2025-09-11-7, representing 2025-09-11 07:00:00 to 07:59:59 - Daily query:
yy-mm-dd, e.g.,2025-09-11, representing 2025-09-11 00:00:00 to 23:59:59
- Hourly query:
- Response: Repository event list. Structures vary by event type, but all share common properties.
eventObject: Event structure, composed of common event properties + payload.
Request and Response Example
Query repository cnb/test for events during 07:00-07:59 on 2025-09-11:
curl -X "GET" \
-H "accept: application/json" \
-H "Authorization: Bearer 1Z00000000000000000000000vA" \
"https://api.cnb.build/events/cnb/test/-/2025-09-11-7"The response is a list of repository events within the time range. The payload structure varies by event type, but every event contains the Common Event Properties described above. The following shows a PushEvent as an example:
[
{
"id": 2100000000000000001,
"type": "PushEvent",
"actor": {
"id": 1816756487609032700,
"username": "cnb",
"nickname": "CNB"
},
"repo": {
"id": 1816756487609032701,
"path": "cnb/test"
},
"created_at": "2025-09-11T07:30:00Z",
"push_id": "2100000000000000002",
"distinct_size": 1,
"ref": "refs/heads/main",
"head": "9f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a",
"before": "0d8e7f6a5b4c3d2e1f0a9b8c7d6e5f4a3b2c1d0e",
"commits": [
{
"sha": "9f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a",
"message": "feat: add badge",
"author": {
"name": "cnb",
"email": "cnb@example.com"
},
"distinct": true
}
]
}
]Common Event Properties
- id: int, event ID, globally unique.
- type: string, event type, see the "Overview" section above.
- actor: object, event trigger user.
- id: int, user id.
- username: string, username.
- nickname: string, user nickname.
- url: string, OPENAPI address for querying user details.
- avatar_url: string, user avatar URL.
- repo: object, repository details for the event.
- id: int, repository id.
- path: string, full repository path.
- url: string, OPENAPI address for querying repository details.
- created_at: string, event trigger time, ISO 8601 format.
Payload
CreateEvent
Records repository, branch, and tag creation events.
- ref: string, git ref resource. When ref_type is repository, ref is an empty string.
- ref_type: string, git ref object type, includes branch, tag, repository.
- master_branch: string, repository main branch.
- description: string, repository description.
- pusher_type: string, pusher type, fixed value "user".
DeleteEvent
Records branch and tag deletion events.
- ref: string, git ref resource.
- ref_type: string, git ref object type, includes branch, tag.
ForkEvent
Records repository fork events.
- forkee: repo object, forked repository resource.
- id: int, repository id.
- name: string, repository name.
- full_name: string, full repository path.
- owner: user object, repository creator details.
- id: int, creator id.
- username: string, username.
- url: string, OPENAPI address for querying user details.
- avatar_url: string, user avatar URL.
- html_url: string, user homepage URL.
- followers_url: string, user followers list URL.
- following_url: string, user following list URL.
- starred_url: string, user starred list URL.
- organizations_url: string, user organizations list URL.
- repos_url: string, user repositories list URL.
- type: string, user type, includes "wechat_user" (WeChat user), "robot_user" (robot).
- private: bool, whether it's a private repository.
- html_url: string, repository CNB URL.
- description: string, repository description.
- fork: bool, whether created by fork.
- url: string, repository details query OPENAPI address.
- branches_url: string, OPENAPI address for repository branch list query.
- collaborators_url: string, OPENAPI address for repository members list query.
- compare_url: string, OPENAPI address for branch comparison.
- contents_url: string, OPENAPI address for repository file query.
- contributors_url: string, OPENAPI address for repository contributors list query.
- forks_url: string, OPENAPI address for repository fork list query.
- git_commits_url: string, OPENAPI address for specific commit details query.
- git_tags_url: string, OPENAPI address for specific tag details query.
- issue_comment_url: string, OPENAPI address for issue comment list query.
- issues_url: string, OPENAPI address for issue list query.
- labels_url: string, OPENAPI address for issue label list query.
- pulls_url: string, OPENAPI address for PR list query.
- releases_url: string, OPENAPI address for release list query.
- stargazers_url: string, OPENAPI address for users who starred the repository query.
- tags_url: string, OPENAPI address for tag list query.
- clone_url: string, repository clone URL.
- homepage: string, repository homepage.
- language: string, repository primary language.
- forks_count: int, number of times repository was forked.
- stargazers_count: int, number of times repository was starred.
- size: int, repository storage size.
- default_branch: string, repository default branch.
- open_issues_count: int, number of open issues in repository.
- topics: string list, repository topic list.
- has_issues: bool, whether repository has issues.
- archived: bool, whether repository is archived.
- disabled: bool, whether repository is disabled.
- visibility: string, repository visibility.
- pushed_at: string, last push time to repository.
- created_at: string, repository creation time.
- updated_at: string, repository update time.
- license: string, repository license.
IssueCommentEvent
Records issue comment events.
- action: string, comment action, includes created, edited, deleted.
- issue: issue object, issue details for the comment.
- id: int, issue id.
- url: string, OPENAPI address for specific issue details query.
- repository_url: string, OPENAPI address for issue repository details query.
- labels_url: string, OPENAPI address for issue label list query.
- comments_url: string, OPENAPI address for issue comments query.
- html_url: string, issue CNB URL.
- number: int, issue repository sequence number.
- state: string, issue state.
- title: string, issue title.
- labels: label object list, issue label list.
- name: string, label name.
- description: string, label description.
- color: string, label color.
- assignees: user object list, issue assignees, object structure same as ForkEvent user object.
- comments: int, issue comment count.
- closed_at: string, issue close time.
- created_at: string, issue creation time.
- updated_at: string, issue update time.
- comment: comment object, comment details.
- id: int, comment id
- url: string, OPENAPI address for comment details query.
- html_url: string, comment CNB URL.
- body: string, comment content.
- user: user object, commenter, object structure same as ForkEvent user object.
- created_at: string, comment creation time.
- updated_at: string, comment update time.
- issue_url: string, OPENAPI address for comment's issue details query.
IssueEvent
Records issue events.
- action: string, issue action, includes opened, edited, closed, reopened, assigned, unassigned, labeled, unlabeled.
- issue: issue object, issue details, object structure same as IssueCommentEvent issue object.
- assignees: user object, assignee, object structure same as ForkEvent user object.
- labels: label object, issue label, object structure same as IssueCommentEvent label object.
MemberEvent
Records repository member addition events.
- action: string, member action, includes added.
- member: user object, new member, object structure same as ForkEvent user object.
PublicEvent
Records private repository to public repository conversion events.
PullRequestEvent
Records PR events.
- action: string, PR action, includes opened, closed, reopened, edited.
- number: int, PR repository sequence number.
- pull_request: pull_request object, PR details.
- id: int, PR id.
- url: string, OPENAPI address for PR details query.
- html_url: string, PR CNB URL.
- diff_url: string, PR diff CNB URL.
- commits_url: string, PR CNB commit details URL.
- number: int, PR repository sequence number.
- state: string, PR state.
- title: string, PR title.
- user: user object, PR creator, object structure same as ForkEvent user object.
- body: string, PR details.
- labels: label object list, PR label list, object structure same as IssueCommentEvent label object.
- created_at: string, PR creation time.
- updated_at: string, PR update time.
- closed_at: string, PR close time.
- merged_at: string, PR merge time.
- assignees: user object list, assignee list, object structure same as ForkEvent user object.
- requested_reviewers: user object list, reviewer list, object structure same as ForkEvent user object.
- head: branch object, source branch.
- ref: string, branch name.
- repo: repo object, branch repository, object structure same as ForkEvent repo object.
- base: branch object, target branch, same structure as above.
- mergeable_state: string, PR merge state.
- comments: int, PR comment count.
PullRequestReviewEvent
Records PR review events.
- action: string, PR review action, includes created.
- pull_request: pull_request object, PR details, object structure same as PullRequestEvent pull_request object.
PullRequestReviewCommentEvent
Records PR review comments.
- action: string, PR review action, includes opened, edited, deleted.
- pull_request: pull_request object, PR details, object structure same as PullRequestEvent pull_request object.
- comment: comment object, comment details, object structure same as IssueCommentEvent comment object.
PushEvent
Records repository push events.
- push_id: string, push id.
- distinct_size: int, deduplicated push size.
- ref: string, push ref name.
- head: string, latest commit sha after push.
- before: string, latest commit sha before push.
- commits: commit object list, commit details list.
- sha: string, commit sha.
- message: string, commit message.
- url: string, OPENAPI address for specific commit details query.
- author: author object, committer.
- name: string, committer name.
- email: string, committer email.
- distinct: bool, whether it's a new commit.
ReleaseEvent
Records repository release events.
- action: string, release action, includes published, edited, deleted.
- release: release object, release details.
- id: int, release id.
- url: string, OPENAPI address for specific release details query.
- html_url: string, release CNB URL.
- assets_url: string, OPENAPI address for release assets query.
- tag_name: string, tag name.
- target_commitish: string, release target commit sha.
- name: string, release name.
- body: string, release details.
- draft: bool, whether it's a draft.
- prerelease: bool, whether it's the latest release.
- created_at: string, release creation time.
- published_at: string, release publish time.
- author: user object, creator, object structure same as ForkEvent user object.
- assets: release_asset object list, release assets.
- id: int, asset id.
- name: string, asset name.
- url: string, OPENAPI address for specific asset details query.
- label: string, asset label.
- state: string, asset state.
- content_type: string, asset content type.
- size: int, asset size.
- digest: string, asset digest hash.
- download_count: int, asset download count.
- created_at: string, asset creation time.
- updated_at: string, asset update time.
WatchEvent
Records repository star events.
- action: string, star action, includes started.