Skip to main content

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:

Installation

The innertube library uses Poetry and can easily be installed from source, or using pip

Latest Release

$ pip install innertube

Bleeding Edge

$ 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

PyPi Source
requests https://github.com/psf/requests
pydantic https://github.com/samuelcolvin/pydantic
addict https://github.com/mewwts/addict
attrs https://github.com/python-attrs/attrs
furl https://github.com/gruns/furl
humps https://github.com/nficano/humps
parse https://github.com/r1chardj0n3s/parse
toolz https://github.com/pytoolz/toolz

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

innertube-1.0.6.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

innertube-1.0.6-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file innertube-1.0.6.tar.gz.

File metadata

  • Download URL: innertube-1.0.6.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.10 Linux/5.4.0-89-generic

File hashes

Hashes for innertube-1.0.6.tar.gz
Algorithm Hash digest
SHA256 23d099dd5784d6da10084e0ca3b3c868e3914ac9754cd8525bb046918ba35fca
MD5 0b98eb873409d8baf9d5081c8364123b
BLAKE2b-256 6a19dafadc9c3843a5d9151f653455b2f4bdbb779b6d37be8c825d2a660310eb

See more details on using hashes here.

File details

Details for the file innertube-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: innertube-1.0.6-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-89-generic

File hashes

Hashes for innertube-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4759578a52a3036d3d61fd9a11e0aae816fb945ec74dce1ecd44197c74c68648
MD5 d89b889dbc7728d5d1b97b4cc7002838
BLAKE2b-256 ad662c310b0ea88b7ed1ff781342ee93d5c0c54fd986cab1410e23bc7ee27afc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page