From 7ca70dff84965cf7647025336ffea1cdc11d86cb Mon Sep 17 00:00:00 2001 From: Sean McKellips Date: Sun, 11 Apr 2021 22:39:28 -0700 Subject: [PATCH] add activity --- main.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index f2f1db2..9c7ef8a 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,16 @@ # 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") + # print("COMPLETE THE TODOs") + api_url = 'https://api.github.com' + try: + events = requests.get(f'{api_url}/users/{username}/events') + first = events.json()[0]['created_at'] + except: + first = None - + if first: + print(f"First event for user {username} was at {first}") + else: + print("Unable to retrieve timestamp for user.") \ No newline at end of file