An unofficial backend API for YouTube Music, built with Go. This service provides a simple JSON interface to browse, search, and stream content from YouTube Music by leveraging its internal API.
This project uses the excellent innertube-go library to communicate with YouTube's InnerTube API.
You can test the API on this public instance (replace with actual URL if available).
- Browse Content: Explore the YouTube Music home page, charts, new releases, and various moods and genres.
- Powerful Search: Search for songs, artists, albums, and playlists.
- Playback: Retrieve streaming data for tracks.
- Queue Management: Get the next track for continuous playback.
- Lightweight & Simple: Built as a standard Go net/http server with minimal dependencies.
- Go (version 1.18 or newer)
-
Clone the repository:
git clone https://github.com/AdrienMttn/ytmusic.git cd ytmusic -
Install dependencies:
go mod tidy
-
Run the server:
go run main.go
The server will start on port 8100. You should see the following message in your terminal:
Server started at :8100
The API provides the following endpoints. All responses are in application/json format.
Only the /watch endpoint returns a stream of audio data.
Searches for content on YouTube Music.
- Query Parameter:
q(string, required) - The search term.continuation(string, optional) - A token for paginating search results.param(string, optional) - Additional search parameters (e.g.,Eg-KAQwIARAAGAAgACgAMABqAffor filtering by type).
- Example:
http://localhost:8100/search?q=Daft+Punk
Browses a specific section of YouTube Music using a browseId.
- Path Parameter:
browseId(string, required) - The ID of the page to browse.continuation(string, optional) - A token for paginating browse results.param(string, optional) - Additional parameters for browsing (e.g.,Eg-KAQwIARAAGAAgACgAMABqAffor filtering by type).
- Example:
http://localhost:8100/browse/FEmusic_home
You can get a list of common browseIds from the /browse/list endpoint.
Provides a list of common browseIds for browsing.
- Example:
http://localhost:8100/browse/list - Sample Response:
[ "FEmusic_home", "FEmusic_explore", "FEmusic_new_releases", "FEmusic_new_releases_albums", "FEmusic_charts", "FEmusic_moods_and_genres", "FEmusic_moods_and_genres_category" ]
Retrieves playback and video information for a specific track.
- Query Parameter:
v(string, required) - The video ID of the track. - Example:
http://localhost:8100/watch?v=VIDEO_ID
Retrieves the next track in the queue or playlist.
- Query Parameter:
v(string, required) - The video ID of the currently playing track.list(string, optional) - The ID of the playlist to get the next track from.param(string, optional) - Additional parameters for getting the next track (e.g.,Eg-KAQwIARAAGAAgACgAMABqAffor filtering by type).index(integer, optional) - The index of the current track in the playlist (iflistis provided).continuation(string, optional) - A token for paginating next track results.
- Example:
http://localhost:8100/next?v=VIDEO_ID
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs, feature requests, or improvements.
This project is licensed under the MIT License. See the LICENSE file for details.
This project is not affiliated with, endorsed, or sponsored by YouTube or Google. It is an independent, unofficial project. Use it at your own risk.