Home > Software design >  How to parse information from GitHub API JSON response?
How to parse information from GitHub API JSON response?

Time:11-15

I wanted to find a way to parse this JSON received from the GitHub REST API. I am trying to parse every description of all the repos in the response in Python.

CodePudding user response:

Something like the below:

  • Do HTTP GET to the URL

  • If staus code is OK - turn the data into list of dicts and extract the info from each dict

      import requests
      r = requests.get('https://api.github.com/users/ariv797/repos')
      if r.status_code == 200:
        data = r.json()
        desc_lst = [e['description'] for e in data]
        print(desc_lst)
    

output

['Python script for bookmyshow', 'Fidellity is a voice assistant app built using fluttter', 'Flutter package for Open Weather API integration', 'Hogwarts (Harry Potter) open sandbox game made in Unity', 'Datasets of SpaceX rockets, launches, satellites, cores, ships and more.', 'Simple extension to remove audio ads on Spotify web player', 'Just scrapes the latest version of popular programming languages']
  • Related