--- title: The events API keywords: fastai sidebar: home_sidebar summary: "Helpers for getting GitHub API events" description: "Helpers for getting GitHub API events" nb_path: "04_event.ipynb" ---
api = GhApi()
list_events
and list_events_parallel
support the following:
Events from | Example |
---|---|
Organization | api.list_events_parallel(org='fastai') |
User | api.list_events_parallel(username='jph00') |
Repository network | api.list_events_parallel(owner='fastai', repo='fastcore') |
All public | api.list_events_parallel() |
print([snake2camel(o)+'Event' for o in Event])
5000 sample events (taken from a single recent period) are available, and are downloaded and cached by load_sample_events
. full_type
provides the combination of type
and payload.action
(where available) for each event. Here's the frequency of all full_types
in the sample:
evts = load_sample_events()
x,y = zip(*Counter([o.full_type for o in evts]).most_common())
plt.figure(figsize=(8, 6))
plt.barh(x,y);
You can use the description
, text
, and emoji
properties to display events, e.g:
exs = [first(evts, risinstance(o)) for o in described_evts]
def _fmt_evt(o):
res = f'{o.emoji} **{o.actor.login}** ' + truncstr(f'{o.description} *{o.repo.name}',60) + '*'
if o.text: res += f': "{truncstr(o.text, 50)}"'
return res.replace('\n',' ')
Markdown('|Type|Description|\n|:--|:--|\n' +
'\n'.join(f'|{camel2words(o.type.replace("PullRequest","PR ")[:-5])}|{_fmt_evt(o)}|' for o in exs))