How to fetch watch history of youtube using unofficial youtube api?

With the datakund library we can fetch watch history on youtube. For fetching history first you need to login to youtube. Here are the steps to get watch history:-

  1. Install datakund
pip install datakund

2. Import datakund

from datakund.datakund import *

3. Login to youtube through cookies. You can see this article to fetch cookies.

obj=datakund()
youtube=obj.youtube()
cookie_list='list of cookies'
youtube.login_cookie(cookies=cookie_list)

4. Get watch history now by calling get_watch_history function.