{"id":13801004,"url":"https://github.com/UnexpectedMaker/micropython-youtube-api","last_synced_at":"2025-05-13T10:30:52.738Z","repository":{"id":56505770,"uuid":"169195456","full_name":"UnexpectedMaker/micropython-youtube-api","owner":"UnexpectedMaker","description":"Youtube API in MicroPython","archived":false,"fork":false,"pushed_at":"2020-11-03T14:20:36.000Z","size":37,"stargazers_count":13,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T00:05:44.167Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UnexpectedMaker.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-05T05:35:55.000Z","updated_at":"2023-11-19T01:49:44.000Z","dependencies_parsed_at":"2022-08-15T20:00:49.105Z","dependency_job_id":null,"html_url":"https://github.com/UnexpectedMaker/micropython-youtube-api","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnexpectedMaker%2Fmicropython-youtube-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnexpectedMaker%2Fmicropython-youtube-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnexpectedMaker%2Fmicropython-youtube-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UnexpectedMaker%2Fmicropython-youtube-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UnexpectedMaker","download_url":"https://codeload.github.com/UnexpectedMaker/micropython-youtube-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225198957,"owners_count":17437004,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:18.483Z","updated_at":"2024-11-18T15:31:26.715Z","avatar_url":"https://github.com/UnexpectedMaker.png","language":"Python","readme":"MicroPython Youtube API\n=======================\n\nA MicroPython based Youtube API wrapper library and example code that allows you to connect to the Google Apps API backend to obtain channel stats for aa YouTube channel.\n\nSetting up the config.json\n--------------------------\n\nThe config.json file contains entried you will need to fill in for the following items:\n* ssid - Your Wifi network SSID\n* ssid_password - Your WiFi router password\n* appkeyid - Your API kety from Google (See below on how to opbtain one)\n* channelid - Your YouTube Channel ID\n* query_interval_sec - How long between hitting GoogleApps for an updated set of data\n\n.. code-block:: json\n\n    {\n        \"ssid\": \"Enter_Wifi_SSID\",\n        \"ssid_password\": \"Enter_Wifi_Password\",\n        \"appkeyid\": \"Enter_GooleApps_API_Key\",\n        \"channelid\": \"Enter_YT_Channel_ID\",\n        \"query_interval_sec\": 60\n    }\n..\n\n\nInstalling\n----------\n\nDownload the repositry and copy the following files to your ESP8266 or ESP32 Development board running the latest mainline  MicroPython firmware\n\n* micropython_youtube_api.py\n* config.json \n* urequests.py\n* Optional: grab_stats.py from examples folder\n\nUsing the API\n----------\n\nCheck the grab_stats.py example script for a full implementation of using the library.\n\nTake note that the creation of the YoutubeAPI() instance is done using the **with** statement to create a context around the definition, so cleanup of the WiFi connection can happen when the data variable (class instance) is out of scope. \n\n.. code-block:: python\n\n    from micropython_youtube_api import YoutubeAPI\n    import network, json, time\n\n    # Read config\n    with open('config.json') as f:\n        config = json.load(f)\n\n    # Check config.json has updated credentials\n    if config['ssid'] == 'Enter_Wifi_SSID':\n        assert False, (\"config.json has not been updated with your unique keys and data\")\n\n    # Create WiFi connection and turn it on\n    wlan = network.WLAN(network.STA_IF)\n    wlan.active(True)\n\n    # Connect to WiFi router\n    print (\"Connecting to WiFi: {}\".format( config['ssid'] ) )\n    wlan.connect( config['ssid'], config['ssid_password'])\n\n    # Wait until wifi is connected\n    while not wlan.isconnected:\n        pass\n\n    # Create an instance of the YoutubeApi\n    with YoutubeAPI( config[\"channelid\"], config[\"appkeyid\"], config[\"query_interval_sec\"] ) as data:\n\n        # Read the data every X seconds\n        update_interval = 5\n        update_stats_time = time.time() - 10\n\n        while True:\n\n            if update_stats_time \u003c time.time():\n                update_stats_time = time.time() + update_interval\n\n                print (\"Subs {}\".format( data.subs ) )\n                print (\"Views {}\".format( data.views ) )\n                print (\"Videos {}\".format( data.videos ) )\n                print (\"Comments {}\".format( data.comments ) )\n..\n\nGetting a Google Apps API key (Required!)\n-----------------------------------------\n\n* Create an application [here](https://console.developers.google.com)\n* On the API Manager section, go to \"Credentials\" and create a new API key\n* Enable your application to communicate the YouTube Api [here](https://console.developers.google.com/apis/api/youtube)\n* Make sure the following URL works for you in your browser (Change the key at the end!):\nhttps://www.googleapis.com/youtube/v3/channels?part=statistics\u0026id=UCu7_D0o48KbfhpEohoP7YSQ\u0026key=PutYourNewlyGeneratedKeyHere\n\nEnjoy!\n\nBack me on Patreon?\n===================\n\nI love making and designing projects but sharing open source projects takes a lot of thought and time. I do it because I think it’s important to share knowledge and give back to the community like many have done before me.\n\nIf you find this project useful or want to see more open source projects like it, please consider backing me on Patreon to say thanks!\n\n.. image:: http://3sprockets.com.au/um/PatreonSmall.jpg\n    :width: 100\n    :alt: Patreon\n    :target: https://www.patreon.com/unexpectedmaker\n    \nhttps://www.patreon.com/unexpectedmaker\n\nUnexpected Maker\n===================\nhttp://youtube.com/c/unexpectedmaker\n\nhttp://twitter.com/unexpectedmaker\n\nhttps://www.facebook.com/unexpectedmaker/\n\nhttps://www.instagram.com/unexpectedmaker/\n\nhttps://www.tindie.com/stores/seonr/\n\n\n","funding_links":["https://www.patreon.com/unexpectedmaker"],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnexpectedMaker%2Fmicropython-youtube-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUnexpectedMaker%2Fmicropython-youtube-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUnexpectedMaker%2Fmicropython-youtube-api/lists"}