/api/search/songs
Unified search across JioSaavn and YouTube. Returns up to 20 results with intelligent deduplication based on title similarity.
curl "https://api.audioflux.io/api/search/songs?q=Blinding+Lights"The heart of AudioFlux. A high-concurrency Node.js engine orchestrating real-time state synchronization, unified music search, and massive multi-user room management.
How AudioFlux keeps thousands of users on the same beat.
The PlaybackManager implements a 1-second authoritative tick. Unlike traditional players that rely on client-side timers, AudioFlux treats the Backend as the source of truth for "Time Elapsed."
currentTime >= duration.// Every 1000ms per active room
tick(roomId) {
const state = await redis.getState(roomId);
if (state.playing) {
state.currentTime += 1;
if (state.currentTime >= state.duration) {
return this.handleSongEnd(roomId);
}
}
this.io.to(roomId).emit('stateUpdate', state);
}Redis key-value schema for persistent ecosystem data.
| Key Pattern | Type | Value / Purpose |
|---|---|---|
| room:{id}:state | JSON String | Playing status, current song ID, position, loop mode. |
| room:{id}:queue | List / Array | Ordered list of Song objects pending playback. |
| user:{id}:history | Sorted Set | Recent songs played by user with timestamp scores. |
| room:{id}:viewers | Set | Active user IDs currently connected to the room. |
Complete endpoint specifications with request/response schemas.
Unified search across JioSaavn and YouTube. Returns up to 20 results with intelligent deduplication based on title similarity.
curl "https://api.audioflux.io/api/search/songs?q=Blinding+Lights"Multi-provider lyrics engine. Queries JioSaavn for synced LRC format first, then falls back to Musixmatch/Genius for plain text.
{
"lyrics": "[00:12.30] Example lyrics...",
"synced": true,
"source": "JioSaavn",
"url": "https://..."
}Bypasses YouTube region blocks by proxying audio streams through the backend. Implements chunked transfer encoding for instant playback start.
Persist a song to user's library in Redis with automatic deduplication.
{
"userId": "12345678",
"song": {
"id": "song_id_123",
"title": "Example Song",
"artist": "Artist Name"
}
}Complete bidirectional event protocol for real-time synchronization.
Initial handshake to join a room and receive full state snapshot.
Queue a new track with metadata and user attribution.
Toggle playback state for the entire room.
Force transition to next song in queue.
Jump to specific timestamp (seconds) in current track.
Cycles through Off, Track, and Queue loop modes.
Enables AI-suggested playback when queue is exhausted.
Removes specific index from room queue (Owner Only).
Rewinds to the last song in room history.
Full room snapshot sent on join (queue, viewers, playback state).
1-second heartbeat with current playback position and metadata.
Fired when songs are added/removed from the queue.
Toast messages (e.g., 'User joined', 'New song added').
Real-time presence array of current active listeners.
Fired when a song finishes to update history panels.
Targeted error messages for failed commands.
HMAC-SHA256 verification for Telegram WebApp authentication.
To prevent unauthorized access, the backend implements HMAC-SHA256 signature verification on the initData provided by Telegram WebApp SDK.
The hash is stripped from the query parameters.
A secret key is derived from the BOT_TOKEN.
Data is re-signed locally; mismatch results in 401.
| Status | Error Code | Reason |
|---|---|---|
| 401 | UNAUTHORIZED | Invalid or missing Telegram WebApp initData signature. |
| 403 | FORBIDDEN | User ID does not have administrative permissions. |
| 404 | NOT_FOUND | Target room, song, or user resource does not exist. |
The backend is optimized for the V8 engine. It uses async/await heavily to prevent event-loop blocking during heavy I/O (Redis/Search). For deployments exceeding 1,000 concurrent rooms, we recommend a Redis Cluster and Socket.IO Redis Adapter for horizontal scaling.