Python Client for Google's Private InnerTube API. Works with Youtube, YouTubeMusic etc.
Project description
innertube
Python Client for Google's Private InnerTube API. Works with: YouTube, YouTube Music, YouTube Kids, YouTube Studio
About
This library handles low-level interactions with the InnerTube API that is used by each of the YouTube services. Google hasn't made much public about the API, and recently all App interactions use protobuf making them hard to reverse-engineer. The only articles I could find online are:
- Gizmodo - How Project InnerTube Helped Pull YouTube Out of the Gutter
- Fast Company - To Take On HBO And Netflix, YouTube Had To Rewire Itself
Installation
The innertube
library uses Poetry and can easily be installed from source, or using pip
Using pip (from source)
$ pip install git+https://github.com/tombulled/innertube
Usage
>>> import innertube
>>>
>>> # Construct a client
>>> client = innertube.InnerTube(innertube.Client.WEB)
>>>
>>> # Get some data!
>>> data = client.search(query = 'foo fighters')
>>>
>>> # Power user? No problem, dispatch requests yourself
>>> data = client('browse', json = {'browseId': 'FEwhat_to_watch'})
>>>
>>> # The core endpoints are implemented, so the above is equivalent to:
>>> data = client.browse('FEwhat_to_watch')
Why not just use the YouTube Data API?
It's entirely up to you and your needs, however this library provides functionality you wont get from the Data API, but it comes at somewhat of a cost (explained below)
This Library | YouTube Data API | |
---|---|---|
No Google account required | ✓ | ✗ |
No request limit | ✓ | ✗ |
Clean, reliable, well-structured data | ✗ | ✓ |
Wait a sec! What do you mean it's not clean, reliable and well-structured??
Well, the private InnerTube API is not designed for consumption by users, it is used to render and operate the various YouTube services.
What does that mean?
Simply put, the data returned by the InnerTube API will need to be parsed and sanitised to extract the usable data as it will contain a lot of fluff that is unlikely to be of any use. These higher-level clients are in the works!
Clients
This table shows all the devices and services that work with the InnerTube API. For example, you could query the API as if you were using the YouTube app on your Tv!
YouTube | YouTubeMusic | YouTubeKids | YouTubeStudio | |
---|---|---|---|---|
Web | WEB | WEB_REMIX | WEB_KIDS | WEB_CREATOR |
Android | ANDROID | ANDROID_MUSIC | ANDROID_KIDS | ANDROID_CREATOR |
Ios | IOS | IOS_MUSIC | IOS_KIDS | IOS_CREATOR |
Tv | TVHTML5 |
Endpoints
Only the core, unauthenticated endpoints are currently implemented. However, between all of these you should be able to access all the data you need.
YouTube | YouTubeMusic | YouTubeKids | YouTubeStudio | |
---|---|---|---|---|
config | ✓ | ✓ | ✓ | ✓ |
browse | ✓ | ✓ | ✓ | ✓ |
player | ✓ | ✓ | ✓ | ✓ |
next | ✓ | ✓ | ✓ | ✗ |
search | ✓ | ✓ | ✓ | ✗ |
guide | ✓ | ✓ | ✗ | ✗ |
music/get_search_suggestions | ✗ | ✓ | ✗ | ✗ |
music/get_queue | ✗ | ✓ | ✗ | ✗ |
What about Authentication?
The InnerTube API uses OAuth2, however I have been unable to successfully implement authentication. Therefore, this library currently only provides unauthenticated access to the API.
Credits
Here's a list of the awesome libraries that helped make innertube
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file innertube-1.0.4.tar.gz
.
File metadata
- Download URL: innertube-1.0.4.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-88-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c061b172cd36321009e91a7a797d65ba5cc0fc4e1e303dadb717f880cf869bf1 |
|
MD5 | 974fef44bb861e66e8138c67aebf5fc6 |
|
BLAKE2b-256 | 8c41b39e5cff488660de5dfc3f72e46a62c6144a20144c3cd49cc30114243ed4 |
File details
Details for the file innertube-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: innertube-1.0.4-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-88-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7355f802f8f2094029ffa508968ba6cfb9e5233021ce087cc94b848cfafb9057 |
|
MD5 | 9b32bd408d91b562faa182ac6b289b3f |
|
BLAKE2b-256 | fad1cb37faaedb867dc406c7fa223f79539b263f4631a8cc2ad88496d27fd401 |