first (oldest) video from youtube data api (script with python)

Solution for first (oldest) video from youtube data api (script with python)
is Given Below:

How to get the date of the first (oldest) youtube video with the youtube data API?

I want the variable ‘endTime’ to be set not hardcoded as below, see line 3 of code)

api_key = 'example_123'
youtube = build('youtube','v3', developerKey=api_key)
endTime = datetime(year=2005, month=4,day=26).strftime('%Y-%m-%dT%H:%M:%SZ')
i=1

request = youtube.search().list(q='',part="snippet",
    type="video",maxResults=10,
    publishedBefore=endTime)
response = request.execute()
for r in sorted(
    response['items'],key=lambda x:x['snippet']['publishedAt']):    
    print(str(i)+". "
        +"Title: "+r['snippet']['title']+"   ---   "
        +"ID: "+r['id']['videoId'] + "   ---   "
        +"Published: "+ r['snippet']['publishedAt'])
    i += 1

this is the output of the script above:

###top 3 oldest videos on youtube:###
1. Title: Me at the zoo   ---   ID: jNQXAC9IVRw   ---   Published: 2005-04-24T03:31:52Z
2. Title: My Snowboarding Skillz   ---   ID: LeAltgu_pbM   ---   Published: 2005-04-24T03:56:09Z
3. Title: tribute   ---   ID: aBfUFr9SBY0   ---   Published: 2005-04-24T22:15:20Z

have any idea or a lead?