A high-performance unofficial API for JioSaavn, written in Python using the FastAPI framework. This API allows you to fetch DRM-free songs, cover art, lyrics, albums, playlists, artist information, and more.
- Language: Python3
- Framework: FastAPI
- Libraries:
requests
: For making HTTP requests to the JioSaavn website.pyDes
: For decrypting encrypted media URLs.pydantic
: For data validation and serialization.fastapi
: For building the API.uvicorn
: For serving the API.markdown
: For rendering the README.md in the browser.
This API interacts with the JioSaavn website by scraping data and utilizing undocumented APIs. It then processes and formats the retrieved data, including decrypting media URLs, to provide a clean and consistent JSON response.
Data Flow:
- Request: A client sends a request to a specific API endpoint (e.g.,
/song/
). - Fetch: The API sends a request to the JioSaavn website to retrieve the relevant data.
- Process: The API processes the raw data, extracts necessary information, and formats it. This may include decrypting media URLs using
pyDes
and cleaning up strings. - Response: The API returns the processed data as a JSON response to the client.
- FastAPI: Chosen for its speed, ease of use, and built-in features like automatic documentation generation.
- pydantic: Used for data validation and serialization, ensuring data integrity and consistency.
- Asynchronous Requests: Using
requests
to handle requests from JioSaavn Website.
-
Clone the repository:
git clone https://github.com/anxkhn/jiosaavn-api
-
Navigate to the project directory:
cd jiosaavn-api
-
Run the application:
You have two options for running the application:
-
Option 1: Run directly using FastAPI
Install the dependencies and run the application using FastAPI (without Docker):
pip install -r requirements.txt fastapi dev main.py
-
Option 2: Run the application using Docker
Alternatively, you can run the application in Docker using Docker Compose:
docker-compose up --build
-
-
Access the application:
After running the application, you can access the following documentation pages:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
You can also visit the app directly at
http://0.0.0.0:8000
.
Songs:
/song/
: Search for songs.- Query Parameters:
query
: Search term for finding songs (required).lyrics
: Include song lyrics in the response (optional, default: False).songdata
: Fetch full song details or basic information (optional, default: True).
- Query Parameters:
/song/get
: Retrieve a specific song by its ID.- Query Parameters:
song_id
: Unique identifier of the song (required).lyrics
: Include song lyrics in the response (optional, default: False).
- Query Parameters:
Albums:
/album/
: Retrieve album details.- Query Parameters:
query
: Album URL or ID (required).lyrics
: Include song lyrics in the response (optional, default: False).
- Query Parameters:
Playlists:
/playlist/
: Retrieve playlist details.- Query Parameters:
query
: Playlist URL or ID (required).lyrics
: Include song lyrics in the response (optional, default: False).
- Query Parameters:
Lyrics:
/lyrics/
: Retrieve song lyrics.- Query Parameters:
query
: Song URL, link, or direct lyrics ID (required).
- Query Parameters:
Health:
-
/ping
: Health check on all JioSaavn endpoints, including service-specific connectivity statuses. -
Note: Kindly ensure all endpoints are working properly before use. Check the health status using the
/ping
endpoint. If everything is functioning correctly, you should receive a response similar to the following:{ "msg": "Pong!", "status": "healthy", "details": [...] }
-
TODO:
[ ] Enhance the
/ping
endpoint to include more comprehensive testing. This will involve validating actual media data (e.g., fetching and processing song, album, and playlist details) to ensure the full functionality of the services.
├── app
│ ├── schemas
│ │ ├── song_schema.py
│ │ ├── playlist_schema.py
│ │ └── album_schema.py
│ ├── services
│ │ ├── saavn_service.py
│ │ └── crypto_service.py
│ ├── routes
│ │ ├── song_routes.py
│ │ ├── playlist_routes.py
│ │ ├── lyrics_routes.py
│ │ └── album_routes.py
│ ├── core
│ │ └── exceptions.py
│ └── config.py
├── main.py
├── requirements.txt
└── README.md
app/schemas
: Contains Pydantic models for defining the structure of API responses.app/services
: Contains the core logic for interacting with the JioSaavn website and processing data.saavn_service.py
: Handles fetching and processing data from JioSaavn.crypto_service.py
: Handles decryption of media URLs.
app/routes
: Defines the API endpoints and their corresponding handlers.app/core
: Contains modules for exception handling and other core functionalities.app/config.py
: Manages application configuration settings.main.py
: The main application file that creates and runs the FastAPI app.requirements.txt
: Lists the project dependencies.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.