Created
December 8, 2018 00:47
-
-
Save aaronaddleman/33ac31c2f7fb3f83cd68cb583c840679 to your computer and use it in GitHub Desktop.
This file contains 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
{"metadata":{"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"}},"nbformat_minor":2,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Getting information from https://github.com/d3/d3\n\n* Please use the API to retrieve the last year’s history of commits to the repo.\n* Attach a text file with the raw json of results returned from the API.\n* We are curious about activity in the d3 github repository over the past year. \n* Please use the API to retrieve the last year’s history of commits to the repo. \n* What week in the last year had the greatest number of commits? \n* Provide the week and a brief sentence walking us through how you solved this question. \n* You will submit your code in the next question.\n\n# Resources\n\nDocumentation pertaining to commit statistics:\n\nhttps://developer.github.com/v3/repos/statistics/\n\nHow do I turn epoch dates into something comprehensible?\n\nhttps://stackoverflow.com/questions/21958851/convert-unix-epoch-time-to-human-readabledate-on-mac-osx-bsd","metadata":{}},{"cell_type":"code","source":"import json\nimport requests","metadata":{"trusted":true},"execution_count":1,"outputs":[]},{"cell_type":"code","source":"api_token = ''\napi_url_base = 'https://api.github.com'","metadata":{"trusted":true},"execution_count":46,"outputs":[]},{"cell_type":"code","source":"headers = {'Content-Type': 'application/json',\n 'Authorization': '{0}'.format(api_token)}\nheaders","metadata":{"trusted":true},"execution_count":47,"outputs":[{"execution_count":47,"output_type":"execute_result","data":{"text/plain":"{'Content-Type': 'application/json',\n 'Authorization': '7c307a305f344792302966107e0526726b5ffc65'}"},"metadata":{}}]},{"cell_type":"code","source":"def get_account_info():\n api_url = 'https://api.github.com/users/{0}'.format('aaronaddleman')\n response = requests.get(api_url, headers=headers)\n\n if response.status_code == 200:\n return json.loads(response.content.decode('utf-8'))\n else:\n return None","metadata":{"trusted":true},"execution_count":48,"outputs":[]},{"cell_type":"code","source":"data = get_account_info()","metadata":{"trusted":true},"execution_count":49,"outputs":[]},{"cell_type":"code","source":"data","metadata":{"trusted":true},"execution_count":50,"outputs":[{"execution_count":50,"output_type":"execute_result","data":{"text/plain":"{'login': 'aaronaddleman',\n 'id': 7731713,\n 'node_id': 'MDQ6VXNlcjc3MzE3MTM=',\n 'avatar_url': 'https://avatars1.githubusercontent.com/u/7731713?v=4',\n 'gravatar_id': '',\n 'url': 'https://api.github.com/users/aaronaddleman',\n 'html_url': 'https://github.com/aaronaddleman',\n 'followers_url': 'https://api.github.com/users/aaronaddleman/followers',\n 'following_url': 'https://api.github.com/users/aaronaddleman/following{/other_user}',\n 'gists_url': 'https://api.github.com/users/aaronaddleman/gists{/gist_id}',\n 'starred_url': 'https://api.github.com/users/aaronaddleman/starred{/owner}{/repo}',\n 'subscriptions_url': 'https://api.github.com/users/aaronaddleman/subscriptions',\n 'organizations_url': 'https://api.github.com/users/aaronaddleman/orgs',\n 'repos_url': 'https://api.github.com/users/aaronaddleman/repos',\n 'events_url': 'https://api.github.com/users/aaronaddleman/events{/privacy}',\n 'received_events_url': 'https://api.github.com/users/aaronaddleman/received_events',\n 'type': 'User',\n 'site_admin': False,\n 'name': 'Aaron Addleman',\n 'company': None,\n 'blog': 'http://aaronaddleman.com',\n 'location': 'San Francisco',\n 'email': None,\n 'hireable': True,\n 'bio': 'Cloud Air Bender',\n 'public_repos': 77,\n 'public_gists': 11,\n 'followers': 6,\n 'following': 4,\n 'created_at': '2014-05-29T04:26:05Z',\n 'updated_at': '2018-11-11T16:01:32Z'}"},"metadata":{}}]},{"cell_type":"code","source":"type(data)","metadata":{"trusted":true},"execution_count":44,"outputs":[{"execution_count":44,"output_type":"execute_result","data":{"text/plain":"dict"},"metadata":{}}]},{"cell_type":"code","source":"data['login']","metadata":{"trusted":true},"execution_count":45,"outputs":[{"execution_count":45,"output_type":"execute_result","data":{"text/plain":"'aaronaddleman'"},"metadata":{}}]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment