{"id":3534,"date":"2021-05-27T08:11:58","date_gmt":"2021-05-27T11:11:58","guid":{"rendered":"https:\/\/renanmf.com\/?p=3534"},"modified":"2021-05-27T08:23:26","modified_gmt":"2021-05-27T11:23:26","slug":"using-the-github-api-in-python","status":"publish","type":"post","link":"https:\/\/renanmf.com\/using-the-github-api-in-python\/","title":{"rendered":"Using the Github API in Python"},"content":{"rendered":"<p>Github is a repository for developers to keep their projects and code versioned.<\/p>\n<p>You can create an account for free and use it as much as you want at no cost.<\/p>\n<p>Some APIs are paid and a bit troublesome to set up, that&#8217;s why we are going to use the freely available Github API.<\/p>\n<p>The GET resources are public, while PUT, DELETE, and POST are not.<\/p>\n<p>This means the retrieval part using GET will work ok if you do exactly what I do, but if you want to change a resource, you need specific authorization and you can do it easily on your own account.<\/p>\n<h2>The Github API<\/h2>\n<p>I want you to stop and go to <a href=\"https:\/\/github.com\/\">github.com<\/a> and create your account, we are going to use it later when I show how to set up your API credentials.<\/p>\n<p>If you go to <code>https:\/\/api.github.com\/<\/code> on your browser, you will see a response similar to this one, but with many more options.<\/p>\n<pre><code>{\n  &quot;current_user_url&quot;: &quot;https:\/\/api.github.com\/user&quot;,\n  &quot;current_user_authorizations_html_url&quot;: &quot;https:\/\/github.com\/settings\/connections\/applications{\/client_id}&quot;,\n  &quot;authorizations_url&quot;: &quot;https:\/\/api.github.com\/authorizations&quot;,\n  &quot;code_search_url&quot;: &quot;https:\/\/api.github.com\/search\/code?q={query}{&amp;page,per_page,sort,order}&quot;,\n  &quot;commit_search_url&quot;: &quot;https:\/\/api.github.com\/search\/commits?q={query}{&amp;page,per_page,sort,order}&quot;,\n  &quot;emails_url&quot;: &quot;https:\/\/api.github.com\/user\/emails&quot;,\n  &quot;emojis_url&quot;: &quot;https:\/\/api.github.com\/emojis&quot;,\n  &quot;events_url&quot;: &quot;https:\/\/api.github.com\/events&quot;,\n  &quot;feeds_url&quot;: &quot;https:\/\/api.github.com\/feeds&quot;,\n  &quot;followers_url&quot;: &quot;https:\/\/api.github.com\/user\/followers&quot;,\n  &quot;following_url&quot;: &quot;https:\/\/api.github.com\/user\/following{\/target}&quot;,\n  &quot;gists_url&quot;: &quot;https:\/\/api.github.com\/gists{\/gist_id}&quot;,\n  &quot;hub_url&quot;: &quot;https:\/\/api.github.com\/hub&quot;,\n  &quot;issue_search_url&quot;: &quot;https:\/\/api.github.com\/search\/issues?q={query}{&amp;page,per_page,sort,order}&quot;,\n  &quot;issues_url&quot;: &quot;https:\/\/api.github.com\/issues&quot;,\n  &quot;keys_url&quot;: &quot;https:\/\/api.github.com\/user\/keys&quot;,\n  &quot;label_search_url&quot;: &quot;https:\/\/api.github.com\/search\/labels?q={query}&amp;repository_id={repository_id}{&amp;page,per_page}&quot;,\n  &quot;notifications_url&quot;: &quot;https:\/\/api.github.com\/notifications&quot;,\n  &quot;organization_url&quot;: &quot;https:\/\/api.github.com\/orgs\/{org}&quot;,\n  &quot;organization_repositories_url&quot;: &quot;https:\/\/api.github.com\/orgs\/{org}\/repos{?type,page,per_page,sort}&quot;,\n  &quot;organization_teams_url&quot;: &quot;https:\/\/api.github.com\/orgs\/{org}\/teams&quot;,\n  &quot;public_gists_url&quot;: &quot;https:\/\/api.github.com\/gists\/public&quot;,\n  &quot;rate_limit_url&quot;: &quot;https:\/\/api.github.com\/rate_limit&quot;,\n  &quot;repository_url&quot;: &quot;https:\/\/api.github.com\/repos\/{owner}\/{repo}&quot;,\n  &quot;repository_search_url&quot;: &quot;https:\/\/api.github.com\/search\/repositories?q={query}{&amp;page,per_page,sort,order}&quot;,\n  &quot;current_user_repositories_url&quot;: &quot;https:\/\/api.github.com\/user\/repos{?type,page,per_page,sort}&quot;,\n  &quot;starred_url&quot;: &quot;https:\/\/api.github.com\/user\/starred{\/owner}{\/repo}&quot;,\n  &quot;starred_gists_url&quot;: &quot;https:\/\/api.github.com\/gists\/starred&quot;,\n  &quot;user_url&quot;: &quot;https:\/\/api.github.com\/users\/{user}&quot;,\n  &quot;user_organizations_url&quot;: &quot;https:\/\/api.github.com\/user\/orgs&quot;,\n  &quot;user_repositories_url&quot;: &quot;https:\/\/api.github.com\/users\/{user}\/repos{?type,page,per_page,sort}&quot;,\n  &quot;user_search_url&quot;: &quot;https:\/\/api.github.com\/search\/users?q={query}{&amp;page,per_page,sort,order}&quot;\n}<\/code><\/pre>\n<p>This is the JSON format, which resembles a Python dictionary with the key-value pair structure.<\/p>\n<p>This is a list of all the APIs that Github provides.<\/p>\n<p>You can see each API has a specific URL address, so you can easily check the information of a user with <code>https:\/\/api.github.com\/users\/{username}<\/code>.<\/p>\n<p>My user on github is &#8216;renanmouraf&#8217;, so if you open <code>https:\/\/api.github.com\/users\/renanmouraf<\/code> on your browser you will see a JSON similar to this (I removed some info to make it more readable ):<\/p>\n<pre><code>{\n  &quot;login&quot;: &quot;renanmouraf&quot;,\n  &quot;id&quot;: 11388726,\n  &quot;node_id&quot;: &quot;MDQ6VXNlcjExMzg4NzI2&quot;,\n  &quot;avatar_url&quot;: &quot;https:\/\/avatars.githubusercontent.com\/u\/11388726?v=4&quot;,\n  &quot;gravatar_id&quot;: &quot;&quot;,\n  &quot;url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf&quot;,\n  &quot;html_url&quot;: &quot;https:\/\/github.com\/renanmouraf&quot;,\n  &quot;followers_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/followers&quot;,\n  &quot;following_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/following{\/other_user}&quot;,\n  &quot;gists_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/gists{\/gist_id}&quot;,\n  &quot;starred_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/starred{\/owner}{\/repo}&quot;,\n  &quot;subscriptions_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/subscriptions&quot;,\n  &quot;organizations_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/orgs&quot;,\n  &quot;repos_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/repos&quot;,\n  &quot;events_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/events{\/privacy}&quot;,\n  &quot;received_events_url&quot;: &quot;https:\/\/api.github.com\/users\/renanmouraf\/received_events&quot;,\n  &quot;type&quot;: &quot;User&quot;,\n  &quot;site_admin&quot;: false,\n  &quot;name&quot;: &quot;Renan Moura&quot;,\n  &quot;company&quot;: null,\n  &quot;blog&quot;: &quot;https:\/\/renanmf.com&quot;,\n  &quot;location&quot;: null,\n  &quot;email&quot;: null,\n  &quot;hireable&quot;: null,\n  &quot;bio&quot;: null,\n  &quot;twitter_username&quot;: null,\n  &quot;public_repos&quot;: 27,\n  &quot;public_gists&quot;: 1,\n  &quot;followers&quot;: 5,\n  &quot;following&quot;: 2,\n  &quot;created_at&quot;: &quot;2015-03-09T11:15:04Z&quot;,\n  &quot;updated_at&quot;: &quot;2021-05-27T00:19:08Z&quot;\n}<\/code><\/pre>\n<p>So you can see you can have access to a list of my repos using <code>https:\/\/api.github.com\/users\/renanmouraf\/repos<\/code> as indicated by the key &quot;repos_url&quot;.<\/p>\n<h2>Python and the requests module<\/h2>\n<p>Instead of checking my repos using the browser, let&#8217;s do it in Python.<\/p>\n<p>We are going to use the <code>json<\/code> module and the <code>requests<\/code> module.<\/p>\n<p>The <code>requests<\/code> module doesn&#8217;t come built-in in Python, we have to install it:<\/p>\n<pre><code>pip install requests <\/code><\/pre>\n<p><code>requests<\/code> is the most used library to handle HTTP requests in Python and makes the use of APIs very simple.<\/p>\n<p>Create a file &quot;test_api.py&quot;, type the following and run it with <code>python3 test_api.py<\/code>.<\/p>\n<pre><code class=\"language-python\">import requests\nimport json\n\nresponse = requests.get(&#039;https:\/\/api.github.com\/users\/renanmouraf\/repos&#039;)\nprint(response.status_code)\nrepos = response.json()\nprint(json.dumps(repos, indent = 4, sort_keys=True))<\/code><\/pre>\n<p>Here we are making a GET using <code>requests.get()<\/code> passing the URL we want, which is my repos. <\/p>\n<p>Then we print the status_code, which will be 200 if everything went alright.<\/p>\n<p>Then we take the <code>json()<\/code> with the ist of repos and use <code>dumps()<\/code> to print it in a more readable way.<\/p>\n<p>You will see that I have a bunch of repos in my github account.<\/p>\n<h2>Other API operations<\/h2>\n<p>To do the other operations, we need an API key that will allow us to create, update, and delete resources in our own Github accounts.<\/p>\n<p>In fact, for most &quot;serious&quot; services, you can&#8217;t do anything without some API key or similar credentials. Services like Google Maps, Youtube, and Spotify have very nice APIs to play with and I recommend you to look at their documentation to check how to use them with your Python code.<\/p>\n<p>To avoid the risk of Github changing their user interface, I will link to their official guide to create your own access token on <a href=\"https:\/\/docs.github.com\/en\/github\/authenticating-to-github\/creating-a-personal-access-token\">Creating a personal access token<\/a>. It is very simple and just a few clicks away.<\/p>\n<p>Just pay attention to check the boxes to create and delete repos in order to work on the next examples like the images below suggest.<\/p>\n<p>Allow operations on repos:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/api_key_options.jpg\" alt=\"\" \/><\/p>\n<p>Delete repos:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/delete.jpg\" alt=\"\" \/><\/p>\n<p>You are going to need your username and generated token to follow the next examples. Remember to change the variable <code>username<\/code> on this code to your own.<\/p>\n<p>To create a repo, we use <code>requests.post()<\/code>. <\/p>\n<p>Replace <code>token<\/code> with your own, you can keep the rest of the code the same.<\/p>\n<p>The token information goes on the headers of the request, while the data argument takes the <code>payload<\/code> in json format using <code>json.dumps()<\/code>.<\/p>\n<p>Payload is telling the API to create a new repo called &#8216;test_book&#8217; with a description &#8216;A test repo&#8217;.<\/p>\n<pre><code class=\"language-python\">import requests\nimport json\n\ntoken = &#039;3a5f50e43ec0886fb38ffe950fd3add479567863&#039;\n\nrepo = &#039;test_book&#039;\ndescription = &#039;A test repo&#039;\n\npayload = {&#039;name&#039;: repo, &#039;description&#039;: description}\n\nheaders = {&#039;Authorization&#039;: f&#039;token {token}&#039;}\n\nresponse = requests.post(f&#039;https:\/\/api.github.com\/user\/repos&#039;, \n                        headers=headers, data=json.dumps(payload))\n\nprint(response.status_code)<\/code><\/pre>\n<p>The status code of the response will be 201 (created) if your request was successful.<\/p>\n<p>When I go to &#8216;<a href=\"https:\/\/github.com\/renanmouraf?tab=repositories\">https:\/\/github.com\/renanmouraf?tab=repositories<\/a>&#8216;, I see the new repo is created:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/new_repo.jpg\" alt=\"\" \/><\/p>\n<p>To delete a repo we call <code>requests.delete()<\/code> and the headers with the access token.<\/p>\n<p>Notice we don&#8217;t need a payload since the repo name goes directly on the URL after the username.<\/p>\n<pre><code class=\"language-python\">import requests\nimport json\n\nusername = &#039;renanmouraf&#039;\ntoken = &#039;3a5f50e43ec0886fb38ffe950fd3add479567863&#039;\n\nrepo = &#039;test_book&#039;\n\nheaders = {&#039;Authorization&#039;: f&#039;token {token}&#039;}\n\nresponse = requests.delete(f&#039;https:\/\/api.github.com\/repos\/{username}\/{repo}&#039;, \n                          headers=headers)\n\nprint(response.status_code)<\/code><\/pre>\n<p>You will see a 204 (No content) because the delete operation doesn&#8217;t return anything on success. but you can check your repositories list on Github and see that &#8216;test_book&#8217; was deleted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Github is a repository for developers to keep their projects and code versioned. You can create an account for free and use it as much as you want at no cost. Some APIs are paid and a bit troublesome to set up, that&#8217;s why we are going to use the freely available Github API. The [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":3541,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[6],"class_list":["post-3534","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using the Github API in Python<\/title>\n<meta name=\"description\" content=\"In this article you will learn how to use the Github API using Python and the requests library.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/renanmf.com\/using-the-github-api-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the Github API in Python\" \/>\n<meta property=\"og:description\" content=\"In this article you will learn how to use the Github API using Python and the requests library.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/renanmf.com\/using-the-github-api-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Renan Moura - Software Engineering\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/renanmouraf\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-27T11:11:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-27T11:23:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"2240\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Renan Moura\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/renanmouraf\" \/>\n<meta name=\"twitter:site\" content=\"@renanmouraf\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Renan Moura\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/\"},\"author\":{\"name\":\"Renan Moura\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/person\\\/1a6fd46256318d200c1c8a867448e5a8\"},\"headline\":\"Using the Github API in Python\",\"datePublished\":\"2021-05-27T11:11:58+00:00\",\"dateModified\":\"2021-05-27T11:23:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/\"},\"wordCount\":737,\"publisher\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Banner-Post.jpg\",\"keywords\":[\"python\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/\",\"url\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/\",\"name\":\"Using the Github API in Python\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Banner-Post.jpg\",\"datePublished\":\"2021-05-27T11:11:58+00:00\",\"dateModified\":\"2021-05-27T11:23:26+00:00\",\"description\":\"In this article you will learn how to use the Github API using Python and the requests library.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Banner-Post.jpg\",\"contentUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2021\\\/05\\\/Banner-Post.jpg\",\"width\":2240,\"height\":1260},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/using-the-github-api-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/renanmf.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using the Github API in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#website\",\"url\":\"https:\\\/\\\/renanmf.com\\\/\",\"name\":\"Renan Moura - Software Engineering\",\"description\":\"Software development, machine learning\",\"publisher\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/renanmf.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#organization\",\"name\":\"Renan Moura\",\"url\":\"https:\\\/\\\/renanmf.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/me-e1583179172701.jpeg\",\"contentUrl\":\"https:\\\/\\\/renanmf.com\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/me-e1583179172701.jpeg\",\"width\":120,\"height\":120,\"caption\":\"Renan Moura\"},\"image\":{\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/renanmouraf\",\"https:\\\/\\\/x.com\\\/renanmouraf\",\"https:\\\/\\\/instagram.com\\\/renanmouraf\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/renanmouraf\\\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/renanmf.com\\\/#\\\/schema\\\/person\\\/1a6fd46256318d200c1c8a867448e5a8\",\"name\":\"Renan Moura\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g\",\"caption\":\"Renan Moura\"},\"description\":\"I'm a Software Engineer working in the industry for a decade now. I like to solve problems with as little code as possible. I\u2019m interested in solving all sorts of problems with technology in creative and innovative ways. From everyday shell scripts to machine learning models. I write about Software Development, Machine Learning, and Career in tech.\",\"sameAs\":[\"https:\\\/\\\/renanmf.com\\\/\",\"https:\\\/\\\/www.instagram.com\\\/renanmouraf\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/renanmouraf\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/renanmouraf\"],\"url\":\"https:\\\/\\\/renanmf.com\\\/author\\\/renanmoura\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the Github API in Python","description":"In this article you will learn how to use the Github API using Python and the requests library.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/renanmf.com\/using-the-github-api-in-python\/","og_locale":"en_US","og_type":"article","og_title":"Using the Github API in Python","og_description":"In this article you will learn how to use the Github API using Python and the requests library.","og_url":"https:\/\/renanmf.com\/using-the-github-api-in-python\/","og_site_name":"Renan Moura - Software Engineering","article_publisher":"https:\/\/www.facebook.com\/renanmouraf","article_published_time":"2021-05-27T11:11:58+00:00","article_modified_time":"2021-05-27T11:23:26+00:00","og_image":[{"width":2240,"height":1260,"url":"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg","type":"image\/jpeg"}],"author":"Renan Moura","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/renanmouraf","twitter_site":"@renanmouraf","twitter_misc":{"Written by":"Renan Moura","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#article","isPartOf":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/"},"author":{"name":"Renan Moura","@id":"https:\/\/renanmf.com\/#\/schema\/person\/1a6fd46256318d200c1c8a867448e5a8"},"headline":"Using the Github API in Python","datePublished":"2021-05-27T11:11:58+00:00","dateModified":"2021-05-27T11:23:26+00:00","mainEntityOfPage":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/"},"wordCount":737,"publisher":{"@id":"https:\/\/renanmf.com\/#organization"},"image":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg","keywords":["python"],"articleSection":["Python"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/","url":"https:\/\/renanmf.com\/using-the-github-api-in-python\/","name":"Using the Github API in Python","isPartOf":{"@id":"https:\/\/renanmf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#primaryimage"},"image":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg","datePublished":"2021-05-27T11:11:58+00:00","dateModified":"2021-05-27T11:23:26+00:00","description":"In this article you will learn how to use the Github API using Python and the requests library.","breadcrumb":{"@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/renanmf.com\/using-the-github-api-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#primaryimage","url":"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg","contentUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2021\/05\/Banner-Post.jpg","width":2240,"height":1260},{"@type":"BreadcrumbList","@id":"https:\/\/renanmf.com\/using-the-github-api-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/renanmf.com\/"},{"@type":"ListItem","position":2,"name":"Using the Github API in Python"}]},{"@type":"WebSite","@id":"https:\/\/renanmf.com\/#website","url":"https:\/\/renanmf.com\/","name":"Renan Moura - Software Engineering","description":"Software development, machine learning","publisher":{"@id":"https:\/\/renanmf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/renanmf.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/renanmf.com\/#organization","name":"Renan Moura","url":"https:\/\/renanmf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/renanmf.com\/#\/schema\/logo\/image\/","url":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/03\/me-e1583179172701.jpeg","contentUrl":"https:\/\/renanmf.com\/wp-content\/uploads\/2020\/03\/me-e1583179172701.jpeg","width":120,"height":120,"caption":"Renan Moura"},"image":{"@id":"https:\/\/renanmf.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/renanmouraf","https:\/\/x.com\/renanmouraf","https:\/\/instagram.com\/renanmouraf","https:\/\/www.linkedin.com\/in\/renanmouraf\/"]},{"@type":"Person","@id":"https:\/\/renanmf.com\/#\/schema\/person\/1a6fd46256318d200c1c8a867448e5a8","name":"Renan Moura","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/efb78bdd04aa5627f80307aed5a9b31989d901c536d1e014a29a3c3591338af8?s=96&d=mm&r=g","caption":"Renan Moura"},"description":"I'm a Software Engineer working in the industry for a decade now. I like to solve problems with as little code as possible. I\u2019m interested in solving all sorts of problems with technology in creative and innovative ways. From everyday shell scripts to machine learning models. I write about Software Development, Machine Learning, and Career in tech.","sameAs":["https:\/\/renanmf.com\/","https:\/\/www.instagram.com\/renanmouraf\/","https:\/\/www.linkedin.com\/in\/renanmouraf\/","https:\/\/x.com\/https:\/\/twitter.com\/renanmouraf"],"url":"https:\/\/renanmf.com\/author\/renanmoura\/"}]}},"_links":{"self":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/3534","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/comments?post=3534"}],"version-history":[{"count":10,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/3534\/revisions"}],"predecessor-version":[{"id":3548,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/posts\/3534\/revisions\/3548"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/media\/3541"}],"wp:attachment":[{"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/media?parent=3534"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/categories?post=3534"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/renanmf.com\/wp-json\/wp\/v2\/tags?post=3534"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}