Lyrica is an open-source RESTful API for retrieving song lyrics from multiple sources, developed with a focus on accessibility and reliability in India 🇮🇳. It prioritizes high-quality sources like YouTube Music for timestamped lyrics and falls back to LrcLib, Genius, Lyrics.ovh, ChartLyrics, LyricsFreak, and Simp Music for comprehensive coverage. The API is built on Flask, supports asynchronous operations, includes caching for performance, rate limiting for stability, CORS for web integration, and detailed logging for debugging.
-
I have made a lyrics translation and transliteration engine if you are instrested then you can check it out on:- -https://automatic-engine-nc2j.onrender.com
-
It might be slow now because it uses ai to translate and transliterate we will soon implement the database to make it fast.
-
if you like the project then star it to motivate me THANKS!
- Multi-Source Lyrics Retrieval: Aggregates from 7 sources with prioritized sequencing.
- Timestamped Lyrics: Supports synchronized (LRC-style) lyrics from YouTube Music and LrcLib.
- Caching: TTL-based (default: 5 minutes) to minimize external API calls.
- Rate Limiting: 15 requests per minute per IP (customizable via Redis).
- CORS-Enabled: Ideal for frontend applications.
- Admin Tools: Secure endpoints for cache management.
- GUI Tester: Built-in web interface for interactive testing.
- Made in India: Optimized for Bollywood and regional music queries.
- Local Development:
http://127.0.0.1:9999 - Production Demo:
https://test-0k.onrender.com
- Current:
1.2.0
Lyrica does not require user authentication but relies on environment variables for external services:
- GENIUS_TOKEN: Required for Genius API fallback (obtain from Genius API Clients).
- YOUTUBE_COOKIE: Optional for enhanced YouTube Music access.
- ADMIN_KEY: Required for admin cache endpoints.
- RATE_LIMIT_STORAGE_URI: Defaults to
memory://; useredis://for production.
Set these in a .env file or deployment platform dashboard.
-
Clone and Install:
git clone https://github.com/Wilooper/Lyrica.git cd Lyrica pip install -r requirements.txt -
Configure Environment: Create
.env:GENIUS_TOKEN=your_genius_token ADMIN_KEY=your_secure_key -
Run Locally:
python run.pyAccess at
http://127.0.0.1:9999. -
Test with GUI: Visit
http://127.0.0.1:9999/appfor an interactive interface. -
Deploy (e.g., Render):
- Push to GitHub.
- Connect to Render, set env vars, and deploy as a Web Service.
All endpoints return JSON responses. Use URL-encoding for parameters (e.g., spaces as %20).
- URL:
GET / - Description: Retrieves API status, version, and endpoint summary.
- Parameters: None.
- Example Request:
curl http://127.0.0.1:9999/ - Response (200 OK):
{ "api": "Lyrica", "version": "1.2.0", "status": "active", "endpoints": { "lyrics": "/lyrics/?artist=ARTIST&song=SONG×tamps=true&pass=false&sequence=1,2,3", "cache": "/cache/stats", "gui": "/app" }, "timestamp": "2025-12-25 12:20:00" }
-
URL:
GET /lyrics/ -
Description: Searches for lyrics by artist and song, attempting sources in sequence. Supports custom source ordering and timestamped results.
-
Parameters:
Parameter Type Required Description Default artiststring Yes Artist name (e.g., "Arijit Singh"). - songstring Yes Song title (e.g., "Tum Hi Ho"). - timestampsboolean No Enable timestamped lyrics (only from YouTube Music/LrcLib). false passboolean No Enable custom source sequence. false sequencestring No Comma-separated source IDs (e.g., "1,3,5"); requires pass=true.- Source Sequence:
- 1: YouTube Music
- 2: LrcLib
- 3: Genius
- 4: Lyrics.ovh
- 5: ChartLyrics
- 6: LyricsFreak
- 7: Simp Music
-
Example Requests:
- Basic (plain lyrics):
curl "http://127.0.0.1:9999/lyrics/?artist=Arijit%20Singh&song=Tum%20Hi%20Ho" - With timestamps:
curl "http://127.0.0.1:9999/lyrics/?artist=Arijit%20Singh&song=Tum%20Hi%20Ho×tamps=true" - Custom sequence (skip LrcLib):
curl "http://127.0.0.1:9999/lyrics/?artist=Arijit%20Singh&song=Tum%20Hi%20Ho&pass=true&sequence=1,3,4"
- Basic (plain lyrics):
-
Success Response (200 OK, plain lyrics):
{ "status": "success", "data": { "source": "genius", "artist": "Arijit Singh", "title": "Tum Hi Ho", "lyrics": "Hum tere bin ab reh nahi sakte\nTere bina kya wajood mera...", "timestamp": "2025-12-25 12:20:00" }, "attempts": [ { "api": "youtube_music", "status": "no_results", "message": "No lyrics available" } ] } -
Success Response (200 OK, timestamped):
{ "status": "success", "data": { "source": "youtube_music", "artist": "Arijit Singh", "title": "Tum Hi Ho", "lyrics": "Hum tere bin ab reh nahi sakte\nTere bina kya wajood mera...", "timed_lyrics": [ { "text": "Hum tere bin ab reh nahi sakte", "start_time": 0, "end_time": 10000, "id": 1 } ], "hasTimestamps": true, "timestamp": "2025-12-25 12:20:00" }, "attempts": [] } -
Error Response (400 Bad Request, missing params):
{ "status": "error", "error": { "message": "Artist and song name are required", "timestamp": "2025-12-25 12:20:00" } } -
Error Response (404 Not Found, no lyrics):
{ "status": "error", "error": { "message": "No lyrics found for 'Tum Hi Ho' by 'Arijit Singh'", "attempts": [ {"api": "youtube_music", "status": "no_results"}, {"api": "lrclib", "status": "no_results"}, {"api": "genius", "status": "no_results"} ] }, "timestamp": "2025-12-25 12:20:00" } -
JavaScript Example (Frontend Integration):
fetch('http://127.0.0.1:9999/lyrics/?artist=Arijit%20Singh&song=Tum%20Hi%20Ho×tamps=true') .then(response => response.json()) .then(data => { if (data.status === 'success') { console.log('Lyrics:', data.data.lyrics); if (data.data.hasTimestamps) { console.log('Timed Lines:', data.data.timed_lyrics); } } else { console.error('Error:', data.error.message); } }) .catch(error => console.error('Fetch error:', error));
-
Clear Cache:
- URL:
POST /cache/clearorGET /admin/cache/clear?key={ADMIN_KEY} - Description: Clears all cached lyrics entries.
- Example:
curl -X POST http://127.0.0.1:9999/cache/clear - Response (200 OK):
{ "status": "success", "details": {"cleared": 42, "timestamp": "2025-12-25 12:20:00"} } - Error (403 Forbidden, invalid key):
{"error": "unauthorized"}
- URL:
-
Cache Stats:
- URL:
GET /cache/statsorGET /admin/cache/stats?key={ADMIN_KEY} - Description: Returns cache hit/miss ratios and entry counts.
- Example:
curl "http://127.0.0.1:9999/admin/cache/stats?key=your_admin_key" - Response (200 OK):
{ "status": "success", "hits": 150, "misses": 50, "total_entries": 200, "timestamp": "2025-12-25 12:20:00" }
- URL:
- URL:
GET /app - Description: A simple web-based tester for the
/lyrics/endpoint. Enter artist/song details and view results in real-time. - Example: Navigate to
http://127.0.0.1:9999/appin a browser.
-
Rate Limit: 15 requests/minute per IP. Exceeding triggers 429 Too Many Requests:
{ "status": "error", "error": { "message": "Rate limit exceeded. Please wait 35 seconds before retrying." } }Header:
Retry-After: 35 -
Common Errors:
- 400: Invalid/missing parameters.
- 403: Admin access denied.
- 429: Rate limit exceeded.
- 500: Internal server error (check logs).
- Query Tips: Use exact names (e.g., "Arijit Singh" not "Arijit"). Popular songs succeed more often.
- Timestamps: Request only when needed; falls back gracefully if unavailable.
- Custom Sequences: Use for optimization (e.g., skip slow sources:
&pass=true&sequence=3,4,5). - Caching: Responses are cached for 5 minutes; use admin tools to invalidate.
- Monitoring: Enable logging (
LOG_LEVEL=DEBUGin.env) for troubleshooting. - Production Scaling: Integrate Redis for distributed caching/rate limiting.
- Local:
python run.py - Production (Gunicorn):
gunicorn -w 4 -b 0.0.0.0:9999 run:app - Platforms: Render, Heroku, Vercel. Set env vars securely.
- Docker (Optional): See
Dockerfilein repo for containerization.
- No Lyrics: Verify env vars; test popular songs; check server logs.
- Auth Failures: Re-run
ytmusicapi setupfor YouTube; regenerate Genius token. - Rate Limits: Switch to Redis backend.
- Port Conflicts: Edit
run.pyto changeapp.run(port=8080). - Dependencies: Run
pip install flask[async]if async issues arise.
Contributions are encouraged! Fork the repo, create a feature branch, add tests, and submit a PR. Follow PEP 8 and update docs as needed. Report issues via GitHub.
- sigma67: For
ytmusicapi. - tranxuanthang & LrcLib Team: For LRC support.
- maxrave-dev: For Simp Music integration.
MIT License. See LICENSE for details.
For questions, open a GitHub issue. Happy coding with Lyrica! 🇮🇳