DynamusicAPI is a simple and efficient API to search music on YouTube Music and extract audio from YouTube videos. The API is built using FastAPI and leverages youtube_dlp
for extracting audio. This documentation provides details on how to use the API endpoints btw if your in a country unsuported by youtube music the output will be bad so host it on a supported country.
To install and run DynamusicAPI, follow these steps:
-
Clone the repository:
git clone https://github.com/hiruy32/dynamusicapi.git cd dynamusicapi
-
Install dependencies:
pip install fastapi uvicorn requests youtube_dlp
-
Run the application:
uvicorn main:app --reload
Once the server is running, you can access the API at http://127.0.0.1:8000
. You can use tools like curl
, Postman, or your web browser to interact with the API endpoints.
Returns a welcome message.
Response:
{
"message": "Welcome to DynamusicAPI!"
}
Searches for music on YouTube Music based on the query provided.
Parameters:
query
(str): The search query.
Response:
- JSON response from YouTube Music API.
Example:
curl -X 'GET' \
'http://127.0.0.1:8000/search-youtube-music?query=your_search_query' \
-H 'accept: application/json'
Response Example:
{
"contents": [...]
}
Extracts audio from a YouTube video URL and provides the direct URL to the audio stream.
Parameters:
url
(str): The YouTube video URL.
Response:
audio_url
(str): The direct URL to the audio stream.response_time
(float): The time taken to process the request.
Example:
curl -X 'GET' \
'http://127.0.0.1:8000/extract-audio?url=your_youtube_video_url' \
-H 'accept: application/json'
Response Example:
{
"audio_url": "http://audio.url",
"response_time": 2.34
}
This project is licensed under the MIT License. See the LICENSE file for details.