A Flask API For StreamMusic
Welcome more music services to integrate with this API, and frontend developers are welcome to propose new API adaptation requirements.
JetBrains provides free open-source licenses for this project.
Supports fetching LRC lyrics via Kugou/Aggregated API
Supports text/json API
Supports fetching music/album/artist covers
Listens on port 28883 by default, API address http://0.0.0.0:28883/lyrics
; new API address http://0.0.0.0:28883/jsonapi
; cover API address http://0.0.0.0:28883/cover
.
Parameter | Type | Default Value |
---|---|---|
--port |
int | 28883 |
--auth |
str |
The --auth
parameter is used for header authentication. If left empty, authentication is skipped. It verifies the Authorization
or Authentication
field in the header. If authentication fails, a 403 response is returned.
You can also define it using the environment variable API_AUTH
, which has lower priority than the --auth
parameter but is easier to deploy in Docker. -e API_AUTH=custom_auth_key
If private deployment is not possible, you can try using the public API first. Note: The public API fetches lyrics via Kugou and other interfaces, which may be slow and not entirely accurate.
Lyrics API address: https://api.lrc.cx/lyrics
Cover API address: https://api.lrc.cx/cover
Upload to the runtime directory, ./lrcapi --port 8080 --auth custom_auth_key
Pull this project; or download and upload to the runtime directory, then unzip the tar.gz
Install dependencies: pip install -r requirements.txt
Start the service: python3 app.py --port 8080 --auth custom_auth_key
docker run -d \
-p 28883:28883 \
-v /home/user/music:/music \
-e API_AUTH=custom_auth_key \
hisatri/lrcapi:latest
Alternatively, specify a tag (recommended)
docker run -d \
-p 28883:28883 \
-v /home/user/music:/music \
-e API_AUTH=custom_auth_key \
hisatri/lrcapi:1.5.2
A Docker-compose configuration is as follows
services:
lrcapi:
image: hisatri/lrcapi:latest
container_name: lrcapi
ports:
- "28883:28883"
volumes:
- /home/user/music:/music
environment:
- API_AUTH=custom_auth_key
restart: always
If you are using Navidrome Docker, modify /home/user/music:/music
to the host path you mapped in Navidrome;
In other words, keep the -v
parameter consistent with Navidrome.
If you are using Navidrome, map your music file directory to the Docker internal directory; for example, if your music storage directory is /www/path/music
, modify the mapping in the startup command to /www/path/music:/www/path/music
Then access http://0.0.0.0:28883/lyrics
or the new API http://0.0.0.0:28883/jsonapi
The image API address is http://0.0.0.0:28883/cover
Note: Image returns currently use a reverse proxy strategy, which may incur some upstream and downstream traffic consumption and latency.
Supports reverse proxy and SSL using Nginx or Apache.
- Request Method: POST
- Request Path: /tag
- Data Type: application/json
Tested:
- FLAC(flac)
- ID3v2(mp3)
- VorbisComment(ogg)
- title
- artist
- album
- lyrics
- 200 Success
- 404 File not found
- 421 No permission
- 422 Parsing error
- 5xx Execution error
import requests
json_data = {
"path": "/path/to/music/file",
"title": "title",
"artist": "artist",
"album": "album",
"lyrics": "lyrics"
}
url = 'http://127.0.0.1:28883/tag'
response = requests.post(url, json=json_data)
print(response.status_code)
print(response.text)
This program is based on the GPL-3.0 open-source license, and you are free to use, modify, and distribute this program. When developing secondary versions, please comply with the following requirements:
- Retain the original copyright and license notices in your derivative works.
- If you have modified this program, clearly state your modifications.
- When distributing, you need to provide the complete source code and distribute your derivative works under the GPL-3.0 license.
- Any commercial use based on this program needs to comply with the GPL-3.0 license and remain freely accessible.
- Other parts of this project (including logos, services, or slogans, etc.) are not open-sourced under the GPL 3.0 agreement.
Ensure you fully understand the requirements of the GPL-3.0 license and comply with the relevant regulations.