🏛️ Historical repository — this is the original (June 2024) public version of my radio "now playing" metadata API, preserved with its full commit history as the record of this work. For the actively maintained version, see Radioplayer_api.
This PHP project displays information about songs playing on Icecast/Shoutcast radio streams, including history, album art, lyrics, and Progressive Web App (PWA) support. The project offers flexibility to be used with either the local API or the web API, allowing you to choose the option that best suits your needs. Additionally, it is possible to rename the index.php file to index.html to use the project exclusively with the web API.
- Displays current song, artist, and album art.
- History of played songs.
- Cover art of the current song
- Fetches song lyrics using Vagalume API (Vagalume API)
- Responsive design for mobile devices.
- Now available as a Progressive Web App (PWA) for enhanced user experience!
- Support for multiple radio stations
- PHP 7.0 or higher
- Web server (e.g., Apache, Nginx)
- Enabled PHP extensions:
file_get_contents,json,stream_context_create - Internet access to fetch song metadata and album covers
- Clone the repository or download the files.
git clone https://github.com/jailsonsb2/RadioplayerAPI.git-
Make sure you have a web server configured to serve PHP files. If you are using WAMP, place the files in the
wwwfolder. -
Navigate to the project directory.
cd RadioplayerAPI-
Make sure write permissions are set for the directory where the history will be saved.
-
Edit the <script> in the index.php
<script>
window.streams = {
timeRefresh: 5000,
stations: [
{
name: "Jailson Web Rádio",
hash: "jailson",
description: "Música sem parar",
logo: "assets/jailson_logo.png",
album:
"assets/jailson_cover.png",
cover:
"assets/jailson_cover.png",
api: "get_stream_title.php?url=https://stream.zeno.fm/yn65fsaurfhvv",
stream_url: "https://stream.zeno.fm/yn65fsaurfhvv",
tv_url: "https://eu1.servers10.com:2020/VideoPlayer/8106?autoplay=1",
server: "spotify",
program: {
time: "00:00",
name: "Jailson Web Radio",
description: "AO VIVO // ON AIR",
},
social: {
facebook: "https://facebook.com/",
twitter: "https://twitter.com/",
instagram: "https://www.instagram.com//",
},
apps: {
android: "#",
ios: "#",
},
},
{
name: "BENDICIÓN STEREO",
hash: "bendicion",
description: "Bendecidos para bendecir!",
logo: "assets/default.png",
album:
"assets/cover.png",
cover:
"assets/cover.png",
api: "get_stream_title.php?url=https://sv2.globalhostlive.com/proxy/bendistereo/stream2",
stream_url: "https://sv2.globalhostlive.com/proxy/bendistereo/stream2",
tv_url: "https://eu1.servers10.com:2020/VideoPlayer/8106?autoplay=1",
server: "spotify",
program: {
time: "11:00",
name: "Bendición Stereo",
description: "EN VIVO // ON AIR",
},
social: {
facebook: "https://facebook.com/BendicionStereo",
twitter: "https://twitter.com/BendiStereo",
instagram: "https://www.instagram.com/BendiStereo/",
},
apps: {
android: "#",
ios: "#",
},
},
],
};
</script>Edit the get_stream_title.php file to add the allowed URLs of the radio streams.
$allowedUrls = [
'https://stream.zeno.fm/yn65fsaurfhvv',
'https://sv2.globalhostlive.com/proxy/bendistereo/stream2',
// Adicione outras URLs permitidas aqui
];The API can be called with the desired stream URL. For example:
http://yoursite/get_stream_title.php?url=https://stream.zeno.fm/yn65fsaurfhvv
The response will be a JSON in the following format:
{
"songtitle": "Ton Molinari - Eu Não Estou Só",
"artist": "Ton Molinari",
"song": "Eu Não Estou Só",
"source": "https://stream.zeno.fm/yn65fsaurfhvv",
"artwork": "https://exemplo.com/capa-album.jpg",
"song_history": [
{
"song": {
"title": "Música Anterior 1",
"artist": "Artista Anterior 1"
}
},
{
"song": {
"title": "Música Anterior 2",
"artist": "Artista Anterior 2"
}
}
]
}url: The radio stream URL. Must be in the list of allowed URLs.interval(optional): Metadata reading interval (in bytes). Default is19200.
- getMp3StreamTitle($streamingUrl, $interval): Reads the metadata from the radio stream and returns the title of the current song.
- extractArtistAndSong($title): Extracts the artist name and song title from the stream metadata.
- getAlbumArt($artist, $song): Searches for the album cover on iTunes.
- getHistoryFileName($url, $ignoreFirst): Generates the history file name based on the stream URL.
- updateHistory($url, $artist, $song): Updates the history of played songs for a given stream.
The API returns clear error messages in case of failures, for example:
{
"error": "Invalid URL"
}ou
{
"error": "Failed to retrieve stream title"
}The CORS header is configured to allow all origins. This can be adjusted as needed:
header('Access-Control-Allow-Origin: *');- Fork the project.
- Create a branch for your feature (
git checkout -b feature/new-feature). - Commit your changes (
git commit -am 'Add new feature'). - Push to the branch (
git push origin feature/new-feature). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
First published in mid-2024, this project descends from one of the first open-source "now playing" metadata APIs for web radio players written in plain PHP (RadioplayerAPI, June 2024). The response format it introduced — songtitle, artist, song, source, song_history — has since been widely adopted across the web radio ecosystem, including by third-party commercial products.
This project is licensed under the GNU AGPL-3.0 (see LICENSE): you are free to use, modify and redistribute it — including commercially — provided derivative works remain open source and keep the original copyright notices, even when offered only as a hosted/network service.
Closed-source / commercial licensing: to embed this code in a proprietary product without AGPL obligations, a separate commercial license is available — contact contato@jailson.es.
Copyright (C) 2024-2026 Jailson Bezerra (@jailsonsb2)
