---

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"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: 04_event.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">api</span> <span class="o">=</span> <span class="n">GhApi</span><span class="p">()</span>
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="GhApi.list_events" class="doc_header"><code>GhApi.list_events</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L43" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>GhApi.list_events</code>(<strong><code>per_page</code></strong>=<em><code>30</code></em>, <strong><code>page</code></strong>=<em><code>1</code></em>, <strong><code>username</code></strong>=<em><code>None</code></em>, <strong><code>org</code></strong>=<em><code>None</code></em>, <strong><code>owner</code></strong>=<em><code>None</code></em>, <strong><code>repo</code></strong>=<em><code>None</code></em>)</p>
</blockquote>
<p>Fetch public events for repo network, org, user, or all</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="GhApi.list_events_parallel" class="doc_header"><code>GhApi.list_events_parallel</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L51" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>GhApi.list_events_parallel</code>(<strong><code>per_page</code></strong>=<em><code>30</code></em>, <strong><code>n_pages</code></strong>=<em><code>8</code></em>, <strong><code>username</code></strong>=<em><code>None</code></em>, <strong><code>org</code></strong>=<em><code>None</code></em>, <strong><code>owner</code></strong>=<em><code>None</code></em>, <strong><code>repo</code></strong>=<em><code>None</code></em>)</p>
</blockquote>
<p>Fetch as many events from <code>list_events</code> in parallel as available</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p><code>list_events</code> and <code>list_events_parallel</code> support the following:</p>
<table>
<thead><tr>
<th style="text-align:left">Events from</th>
<th style="text-align:left">Example</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Organization</td>
<td style="text-align:left"><code>api.list_events_parallel(org='fastai')</code></td>
</tr>
<tr>
<td style="text-align:left">User</td>
<td style="text-align:left"><code>api.list_events_parallel(username='jph00')</code></td>
</tr>
<tr>
<td style="text-align:left">Repository network</td>
<td style="text-align:left"><code>api.list_events_parallel(owner='fastai', repo='fastcore')</code></td>
</tr>
<tr>
<td style="text-align:left">All public</td>
<td style="text-align:left"><code>api.list_events_parallel()</code></td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="GhEvent" class="doc_header"><code>class</code> <code>GhEvent</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L66" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>GhEvent</code>() :: <code>AttrDict</code></p>
</blockquote>
<p>Class for events returned from `fetch_events</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">print</span><span class="p">([</span><span class="n">snake2camel</span><span class="p">(</span><span class="n">o</span><span class="p">)</span><span class="o">+</span><span class="s1">&#39;Event&#39;</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">Event</span><span class="p">])</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre>[&#39;PageBuildEvent&#39;, &#39;ContentReferenceEvent&#39;, &#39;RepositoryImportEvent&#39;, &#39;CreateEvent&#39;, &#39;WorkflowRunEvent&#39;, &#39;DeleteEvent&#39;, &#39;OrganizationEvent&#39;, &#39;SponsorshipEvent&#39;, &#39;ProjectColumnEvent&#39;, &#39;PushEvent&#39;, &#39;ContextEvent&#39;, &#39;MilestoneEvent&#39;, &#39;ProjectCardEvent&#39;, &#39;ProjectEvent&#39;, &#39;PackageEvent&#39;, &#39;PullRequestEvent&#39;, &#39;RepositoryDispatchEvent&#39;, &#39;TeamAddEvent&#39;, &#39;WorkflowDispatchEvent&#39;, &#39;MemberEvent&#39;, &#39;MetaEvent&#39;, &#39;CodeScanningAlertEvent&#39;, &#39;PublicEvent&#39;, &#39;NeedsEvent&#39;, &#39;CheckRunEvent&#39;, &#39;SecurityAdvisoryEvent&#39;, &#39;PullRequestReviewCommentEvent&#39;, &#39;OrgBlockEvent&#39;, &#39;CommitCommentEvent&#39;, &#39;WatchEvent&#39;, &#39;MarketplacePurchaseEvent&#39;, &#39;StarEvent&#39;, &#39;InstallationRepositoriesEvent&#39;, &#39;CheckSuiteEvent&#39;, &#39;GithubAppAuthorizationEvent&#39;, &#39;TeamEvent&#39;, &#39;StatusEvent&#39;, &#39;RepositoryVulnerabilityAlertEvent&#39;, &#39;PullRequestReviewEvent&#39;, &#39;LabelEvent&#39;, &#39;InstallationEvent&#39;, &#39;ReleaseEvent&#39;, &#39;IssuesEvent&#39;, &#39;RepositoryEvent&#39;, &#39;GollumEvent&#39;, &#39;MembershipEvent&#39;, &#39;DeploymentEvent&#39;, &#39;DeployKeyEvent&#39;, &#39;IssueCommentEvent&#39;, &#39;PingEvent&#39;, &#39;DeploymentStatusEvent&#39;, &#39;ForkEvent&#39;, &#39;ScheduleEvent&#39;]
</pre>
</div>
</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="GhApi.fetch_events" class="doc_header"><code>GhApi.fetch_events</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L87" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>GhApi.fetch_events</code>(<strong><code>n_pages</code></strong>=<em><code>3</code></em>, <strong><code>pause</code></strong>=<em><code>0.4</code></em>, <strong><code>per_page</code></strong>=<em><code>30</code></em>, <strong><code>types</code></strong>=<em><code>None</code></em>, <strong><code>incl_bot</code></strong>=<em><code>False</code></em>, <strong><code>username</code></strong>=<em><code>None</code></em>, <strong><code>org</code></strong>=<em><code>None</code></em>, <strong><code>owner</code></strong>=<em><code>None</code></em>, <strong><code>repo</code></strong>=<em><code>None</code></em>)</p>
</blockquote>
<p>Generate an infinite stream of events, optionally filtered to <code>types, with</code>pause` seconds between requests</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="load_sample_events" class="doc_header"><code>load_sample_events</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L102" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>load_sample_events</code>()</p>
</blockquote>
<p>Load sample events, downloading if needed</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="save_sample_events" class="doc_header"><code>save_sample_events</code><a href="https://github.com/fastai/ghapi/tree/master/ghapi/event.py#L113" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>save_sample_events</code>(<strong><code>n</code></strong>=<em><code>5000</code></em>)</p>
</blockquote>
<p>Save the most recent <code>n</code> events as compressed JSON</p>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>5000 sample events (taken from a single recent period) are available, and are downloaded and cached by <a href="/event.html#load_sample_events"><code>load_sample_events</code></a>. <a href="/event.html#full_type"><code>full_type</code></a> provides the combination of <code>type</code> and <code>payload.action</code> (where available) for each event. Here's the frequency of all <code>full_types</code> in the sample:</p>

</div>
</div>
</div>
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">evts</span> <span class="o">=</span> <span class="n">load_sample_events</span><span class="p">()</span>
<span class="n">x</span><span class="p">,</span><span class="n">y</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="n">Counter</span><span class="p">([</span><span class="n">o</span><span class="o">.</span><span class="n">full_type</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">evts</span><span class="p">])</span><span class="o">.</span><span class="n">most_common</span><span class="p">())</span>
<span class="n">plt</span><span class="o">.</span><span class="n">figure</span><span class="p">(</span><span class="n">figsize</span><span class="o">=</span><span class="p">(</span><span class="mi">8</span><span class="p">,</span> <span class="mi">6</span><span class="p">))</span>
<span class="n">plt</span><span class="o">.</span><span class="n">barh</span><span class="p">(</span><span class="n">x</span><span class="p">,</span><span class="n">y</span><span class="p">);</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 30784 characters]
"
>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>You can use the <a href="/event.html#description"><code>description</code></a>, <a href="/event.html#text"><code>text</code></a>, and <a href="/event.html#emoji"><code>emoji</code></a> properties to display events, e.g:</p>

</div>
</div>
</div>
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="n">exs</span> <span class="o">=</span> <span class="p">[</span><span class="n">first</span><span class="p">(</span><span class="n">evts</span><span class="p">,</span> <span class="n">risinstance</span><span class="p">(</span><span class="n">o</span><span class="p">))</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">described_evts</span><span class="p">]</span>

<span class="k">def</span> <span class="nf">_fmt_evt</span><span class="p">(</span><span class="n">o</span><span class="p">):</span>
    <span class="n">res</span> <span class="o">=</span> <span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">o</span><span class="o">.</span><span class="n">emoji</span><span class="si">}</span><span class="s1"> **</span><span class="si">{</span><span class="n">o</span><span class="o">.</span><span class="n">actor</span><span class="o">.</span><span class="n">login</span><span class="si">}</span><span class="s1">** &#39;</span> <span class="o">+</span> <span class="n">truncstr</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;</span><span class="si">{</span><span class="n">o</span><span class="o">.</span><span class="n">description</span><span class="si">}</span><span class="s1"> *</span><span class="si">{</span><span class="n">o</span><span class="o">.</span><span class="n">repo</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s1">&#39;</span><span class="p">,</span><span class="mi">60</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;*&#39;</span>
    <span class="k">if</span> <span class="n">o</span><span class="o">.</span><span class="n">text</span><span class="p">:</span> <span class="n">res</span> <span class="o">+=</span> <span class="sa">f</span><span class="s1">&#39;: &quot;</span><span class="si">{</span><span class="n">truncstr</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">text</span><span class="p">,</span> <span class="mi">50</span><span class="p">)</span><span class="si">}</span><span class="s1">&quot;&#39;</span>
    <span class="k">return</span> <span class="n">res</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">,</span><span class="s1">&#39; &#39;</span><span class="p">)</span>

<span class="n">Markdown</span><span class="p">(</span><span class="s1">&#39;|Type|Description|</span><span class="se">\n</span><span class="s1">|:--|:--|</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span>
         <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="sa">f</span><span class="s1">&#39;|</span><span class="si">{</span><span class="n">camel2words</span><span class="p">(</span><span class="n">o</span><span class="o">.</span><span class="n">type</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;PullRequest&quot;</span><span class="p">,</span><span class="s2">&quot;PR &quot;</span><span class="p">)[:</span><span class="o">-</span><span class="mi">5</span><span class="p">])</span><span class="si">}</span><span class="s1">|</span><span class="si">{</span><span class="n">_fmt_evt</span><span class="p">(</span><span class="n">o</span><span class="p">)</span><span class="si">}</span><span class="s1">|&#39;</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">exs</span><span class="p">))</span>
</pre></div>

    </div>
</div>
</div>

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea output_execute_result">
<table>
<thead><tr>
<th style="text-align:left">Type</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">Push</td>
<td style="text-align:left">⭐ <strong>fedya</strong> pushed 1 commits to "rolling" in <em>OpenMandrivaAssociation/g…</em></td>
</tr>
<tr>
<td style="text-align:left">Delete</td>
<td style="text-align:left">✂ <strong>dependabot[bot]</strong> deleted branch "packit-0.5.0" in <em>paketo-buildpacks/occam</em></td>
</tr>
<tr>
<td style="text-align:left">Create</td>
<td style="text-align:left">🏭 <strong>github-classroom[bot]</strong> created repository in <em>Introduction-to-Programming-OSOWSKI/…</em>: "1-5-add-two-numbers-noraahlman23 created by GitHu…"</td>
</tr>
<tr>
<td style="text-align:left">PR</td>
<td style="text-align:left">📬 <strong>JerryMacedoCastro</strong> opened PR #1 on <em>JerryMacedoCastro/tb-arquitetura-js</em>: "Input component created"</td>
</tr>
<tr>
<td style="text-align:left">Member</td>
<td style="text-align:left">💃 <strong>github-classroom[bot]</strong> added member noraahlman23 in <em>Introduction-to-Programming-O…</em></td>
</tr>
<tr>
<td style="text-align:left">Public</td>
<td style="text-align:left">♥ <strong>navikt</strong> made public repo  <em>navikt/syfoinntektsmelding</em></td>
</tr>
<tr>
<td style="text-align:left">PR  Review Comment</td>
<td style="text-align:left">🗨 <strong>fruttasecca</strong> created review comment on PR #97 in <em>orchest/orchest</em>: "Does this make it so that users coming from an ol…"</td>
</tr>
<tr>
<td style="text-align:left">Fork</td>
<td style="text-align:left">🍽 <strong>amin-lotf</strong> forked <em>vinaygaba/Learn-Jetpack-Compose-By-Example</em>: "🚀 This project contains various examples that sho…"</td>
</tr>
<tr>
<td style="text-align:left">Commit Comment</td>
<td style="text-align:left">🎉 <strong>vercel[bot]</strong> created commint comment in <em>Samaraferreira/test-frontend</em>: "Successfully deployed to the following URLs:  * […"</td>
</tr>
<tr>
<td style="text-align:left">Watch</td>
<td style="text-align:left">👀 <strong>ikarius</strong> started watching <em>jorgebucaran/awsm.fish</em></td>
</tr>
<tr>
<td style="text-align:left">PR  Review</td>
<td style="text-align:left">💌 <strong>fruttasecca</strong> created PR review in <em>orchest/orchest</em></td>
</tr>
<tr>
<td style="text-align:left">Release</td>
<td style="text-align:left">🚀 <strong>github-actions[bot]</strong> published release v1.1.3 in <em>vouv/srun</em></td>
</tr>
<tr>
<td style="text-align:left">Issues</td>
<td style="text-align:left">🐛 <strong>efritz</strong> opened issue #16915 on <em>sourcegraph/sourcegraph</em>: "auto-indexing: Add docker/src-cli command wall cl…"</td>
</tr>
<tr>
<td style="text-align:left">Gollum</td>
<td style="text-align:left">📚 <strong>TradingToolCrypto</strong> created wiki page in <em>TradingToolCrypto/TradingTool-Wiki</em></td>
</tr>
<tr>
<td style="text-align:left">Issue Comment</td>
<td style="text-align:left">💬 <strong>jerhard</strong> created comment on issue #2570 in <em>ls1intum/Artemis</em>: "Do you think that spaces (or even white space cha…"</td>
</tr>
</tbody>
</table>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

