Last active
July 16, 2018 04:32
-
-
Save bradyt/c5bd8913c50cba8bc6f2126a8c238577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| import simplejson as json | |
| # instructions on token start at https://developer.github.com/v3/?#authentication | |
| # and end at https://github.com/settings/tokens | |
| headers = {"Authorization": "token <token>"} | |
| base_url = 'https://api.github.com/repos/<username>/<repo>' | |
| def run_query(url): | |
| request = requests.get(url, headers=headers) | |
| if request.status_code == 200: | |
| return request.json() | |
| else: | |
| raise Exception("Query failed to run by returning code of {}. {}".format(request.status_code, query)) | |
| def write_api(api): | |
| with open('<repo>' + api.replace('/', '-') + '.json', 'w') as outfile: | |
| json.dump( | |
| run_query(base_url + api), | |
| outfile, | |
| indent=4 * ' ', | |
| sort_keys=True | |
| ) | |
| if __name__ == '__main__': | |
| write_api('/issues') | |
| write_api('/issues/comments') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment