<jupyter_start><jupyter_text>YouTube Data API (Search oldest videos on a topic)![](https://lh3.googleusercontent.com/j2SJC1grxLdL94kX7uB9WclD_nqX49oJs3K82Tok1MaPcx4TvB2m7xmw-Ub4dvFORwPSzruQBWePxtizfuY1r3j4GQvi1G9z=s688)[console.developers.google.com](https://console.developers.google.com/cloud-resource-manager)<jupyter_code>api_key = "<KEY>"
from apiclient.discovery import build
youtube = build('youtube', 'v3', developerKey=api_key)
from datetime import datetime
start_time = datetime(year=2005, month=1, day=1).strftime('%Y-%m-%dT%H:%M:%SZ')
end_time = datetime(year=2008, month=1, day=1).strftime('%Y-%m-%dT%H:%M:%SZ')
res = youtube.search().list(part='snippet',
                            q='python programming',
                            type='video',
                            publishedAfter=start_time,
                            publishedBefore=end_time,
                            maxResults=50).execute()
for item in sorted(res['items'], key=lambda x:x['snippet']['publishedAt']):
    print(item['snippet']['title'], item['snippet']['publishedAt'], item['id']['videoId'])<jupyter_output>Ministry of Silly Walks 2006-06-22T11:38:35.000Z IqhlQfXUk7w
python3 2006-08-15T23:38:06.000Z 8fYhI4ZidkQ
Monty Python - Skecz o biurze podróży 2006-08-27T13:15:37.000Z NOPbwRWk6bk
python12 2006-10-14T16:59:56.000Z Lfy4uqSycyk
python15 2006-10-15T00:14:09.000Z Mlv9TZsZE78
Install Python On Windows 2006-12-21T00:52:38.000Z cnfJ72fgNk4
wii + python + linux 2007-01-26T17:40:09.000Z ishqINM7RgY
Monty Python's best sketch ever 2007-01-31T03:34:30.000Z T70-HTlKRXo
linux + python + wii = fun!!! 2007-02-03T04:12:56.000Z yznIUR8iheo
Monty Python - Spam 2007-02-15T01:47:37.000Z anwy2MPT5RE
VTS v1.0 - Testing 2007-04-10T13:48:05.000Z QbDIarIidEY
FFF/XTR Python 2007-04-22T09:27:21.000Z AliKyPSb7t4
Python 1: Installation and beginner's tutorial. 2007-05-03T08:55:29.000Z NlK_f39eXCE
Python sim demo 2007-05-03T10:55:58.000Z cl71knHg0ks
Python 2: Getting around Python modules 2007-05-06T00:12:05.000Z 94t2tTHZ25M
Python 1: Installation and beginners' tutorial 2007-05-06T08:09:24.000Z fxy1hgvLhDU
Python[...]
{'fraction_non_alphanumeric': 0.13257575757575757, 'fraction_numerical': 0.16666666666666666, 'mean_word_length': 4.575197889182058, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '29106', 'license': 'MIT', 'n_tokens_mistral': 1083, 'n_tokens_neox': 851, 'n_words': 137, 'path': 'YouTubeAPI-Examples/3.Oldest-Search.ipynb', 'repo_name': 'hazratali-bit/30-lines-code.py', 'size': '2139'}