From 5dff0b75834ec74497778f3b0801126c30969ffa Mon Sep 17 00:00:00 2001 From: stellie Date: Fri, 18 Dec 2020 14:38:11 -0800 Subject: [PATCH] complete activity to retrieve user events from Github --- main.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/main.py b/main.py index f2f1db2..0e4cd89 100644 --- a/main.py +++ b/main.py @@ -1,20 +1,16 @@ +# Stella Kim +# Activity 6: Github API + import sys import json - import requests -# Use Like python githubber.py JASchilz -# (or another user name) if __name__ == "__main__": username = sys.argv[1] - # TODO: - # - # 1. Retrieve a list of "events" associated with the given user name - # 2. Print out the time stamp associated with the first event in that list. - - print("COMPLETE THE TODOs") - - - + response = requests.get( + 'https://api.github.com/users/{}/events'.format(username)) + events = json.loads(response.content) + print(events) # events associated with given username + print(events[0]['created_at']) # first event timestamp in list