Skip to main content

Custom Music API

By default, the Music app searches the built-in library (roadshop_music_library), which is filled through player submissions and the in-app admin panel. With the Custom Music API you can replace that library entirely and serve songs from your own HTTP server.

How It Works

Server-Side Only

The request runs on the FiveM server via PerformHttpRequest. Your API key never leaves the server — the NUI frontend never sees your endpoint or credentials.

No Frontend Changes

The Music app works exactly as before: search, playlists and playback are untouched. Only the data source changes.

Unlimited Catalog

Every search hits your server live, so your catalog can be as large as you want — your server does the filtering.

YouTube & Direct Files

Each song is either a YouTube video id or a direct link to an audio file (mp3/ogg) on your own CDN.
While the Custom Music API is enabled, the built-in music library, song submissions and the music admin panel are bypassed. Songs already saved in player playlists keep working, since playlists store the song id and type directly.

Configuration

Edit MusicAPI.lua in the resource root (it is escrow_ignore, so you can edit it freely):
MusicAPI.lua
No config.lua changes and no frontend rebuild needed. Restart the resource after editing.

Request Format

For every search in the Music app, RoadCarRadio sends:
  • The Authorization header is only sent when MusicAPI.APIKey is a non-empty string.
  • An empty search parameter is sent when the player opens the search view. Return your newest or featured songs in that case.

Response Format

Respond with HTTP 200 and a JSON array of songs. At most the first 50 are used:
Wrapping the array in an object is also supported: { "songs": [ ... ] }

Song Fields

Already have an endpoint for another RoadShop resource? RoadCarRadio also accepts the interface’s own field names, so you can point it at an existing feed without rewriting it:If both are present, the standard name wins.
A song is skipped when it has no id, or neither title nor songname. On any error — non-200 status, invalid JSON, or a response with no array — the app shows an empty result list and a warning is printed to the FiveM server console.

Example: Building Your Own Endpoint

A minimal music API using Node.js and Express:
In production, serve the library from a database, add rate limiting, and cache popular queries. Direct audio files must be publicly reachable from every player’s game client — they are streamed by xSound/mx-surround on the client, not proxied through your FiveM server.

Troubleshooting

  • Check the FiveM server console for [RoadCarRadio] MusicAPI ... warnings — they name the exact failure
  • Verify your endpoint is reachable from the FiveM server (try curl on that machine, not from your desktop)
  • Confirm the response is a JSON array, or { "songs": [...] }, with id and title on every song
  • Make sure the API key in MusicAPI.lua matches what your endpoint expects
  • For url_type: "youtube", id must be the plain video id (e.g. dQw4w9WgXcQ), not a full URL
  • For url_type: "direct", id must be a full https:// URL to an audio file that players’ game clients can reach
  • Test a direct URL in your browser — it should stream the audio without a login
  • Confirm Config.AudioLibrary matches the audio resource you actually run (xsound or mxsurround)
  • Ensure MusicAPI.Enabled = true in MusicAPI.lua in the resource root
  • Restart the resource completely after changing the file
  • Check that MusicAPI.lua is listed in fxmanifest.lua under server_scripts
  • At most 50 songs per response are used. Filter server-side and return the best matches rather than your whole catalog
  • Songs without an id, or without both title and songname, are skipped silently

Installation

Requirements, setup and configuration

Commands

Including the music approval command