Reputation: 2383
I can get a list of public events for an organization via GitHub API:
GET /orgs/:org/events
How to get an event payload (like PushEvent) knowing its ID?
Upvotes: 1
Views: 482
Reputation: 28717
The GitHub API provides no way to retrieve a particular event by its ID.
Each event has a payload
inside of it. For example
{
"actor": {
"avatar_url": "https://avatars.githubusercontent.com/u/240830?",
"display_login": "sigmavirus24",
"gravatar_id": "",
"id": 240830,
"login": "sigmavirus24",
"url": "https://api.github.com/users/sigmavirus24"
},
"created_at": "2017-01-27T23:50:12Z",
"id": "5227100855",
"org": {
"avatar_url": "https://avatars.githubusercontent.com/u/1782156?",
"gravatar_id": "",
"id": 1782156,
"login": "github3py",
"url": "https://api.github.com/orgs/github3py"
},
"payload": {
"before": "7d52c200d80d86f70fbda3e9ebf48060867f9f65",
"commits": [
{
"author": {
"email": "[email protected]",
"name": "Ian Cordasco"
},
"distinct": true,
"message": "Create test.txt",
"sha": "a623ca5974523ec35fd83909dd99b220e498ef58",
"url": "https://api.github.com/repos/github3py/delete_contents/commits/a623ca5974523ec35fd83909dd99b220e498ef58"
}
],
"distinct_size": 1,
"head": "a623ca5974523ec35fd83909dd99b220e498ef58",
"push_id": 1525269783,
"ref": "refs/heads/master",
"size": 1
},
"public": true,
"repo": {
"id": 50486230,
"name": "github3py/delete_contents",
"url": "https://api.github.com/repos/github3py/delete_contents"
},
"type": "PushEvent"
}
Is an event from a list after doing GET /orgs/github3py/events
. If you look closely you'll see
"payload": {
"before": "7d52c200d80d86f70fbda3e9ebf48060867f9f65",
"commits": [
{
"author": {
"email": "[email protected]",
"name": "Ian Cordasco"
},
"distinct": true,
"message": "Create test.txt",
"sha": "a623ca5974523ec35fd83909dd99b220e498ef58",
"url": "https://api.github.com/repos/github3py/delete_contents/commits/a623ca5974523ec35fd83909dd99b220e498ef58"
}
],
"distinct_size": 1,
"head": "a623ca5974523ec35fd83909dd99b220e498ef58",
"push_id": 1525269783,
"ref": "refs/heads/master",
"size": 1
},
Which is the payload from the event. That's the only way to get that payload (from listing events).
Upvotes: 1