English | Deutsch
Play your own internet radio streams on Sonos speakers, as a service of their own in the Sonos app. No TuneIn, no extra app, no phone needed while playing.
sns-smapi is a single PHP file you put on any web hosting. It implements the small part of the Sonos Music API (SMAPI) a radio service needs and is connected to your Sonos system through a private integration in the Sonos developer portal.
Disclaimer This is an independent, unofficial project. It is not affiliated with, endorsed, sponsored or certified by Sonos, Inc. "Sonos" is a trademark of Sonos, Inc. and is used here only to describe compatibility. You need your own Sonos developer account and are responsible for complying with the Sonos Developer Terms of Service. This repository contains no Sonos software or documentation. Streams and logos of the example stations belong to their owners; make sure you may use a stream. Provided as is, without any warranty (see LICENSE).
- MP3, AAC, Ogg Vorbis and HLS streams
.plsand.m3uplaylists are resolved automatically (cached, with fallback)- Station logos and descriptions in the Sonos app
- Status page in the browser, optional debug log
- One file, no database, no dependencies
- Web hosting with PHP 8.1 or newer, reachable via HTTPS from the internet. A server that is only reachable in your home network is not enough, because Sonos also calls the service from its cloud.
- Write access to the folder of the script (for a small cache file)
- A Sonos system running the current Sonos app (S2) and a Sonos account
Open smapi.php and edit the STATIONS list at the top. Each station looks like this:
'mystation' => [
'title' => 'My Station', // name in the Sonos app
'url' => 'https://example.com/stream.aac', // stream, HLS (.m3u8) or playlist (.pls/.m3u)
'mime' => 'audio/aac', // audio format, see table
'logo' => 'https://example.com/logo.png', // optional, square, 400 to 600 px, HTTPS
'description' => 'Short text about the station', // optional
],| Format | mime |
|---|---|
| MP3 | audio/mpeg |
| AAC, HE-AAC | audio/aac |
| Ogg Vorbis | application/ogg |
| HLS (.m3u8) | application/vnd.apple.mpegURL (exactly this case) |
For playlists, use the format of the streams inside. Ogg Opus is not supported by Sonos. The key (mystation) is stored by Sonos in favorites and alarms: never rename it once the station is in use.
Upload smapi.php to your web space, e.g. https://example.com/radio/smapi.php, and open that address in a browser. You should see SMAPI ok and your stations. Keep the address short: the developer portal accepts at most 72 characters.
Sign in at developer.sonos.com with your Sonos account and create a new content integration. It starts as a Sandbox, which is what you need. Fill in the sections:
| Section | What to enter |
|---|---|
| General Information | Service name (shown in the Sonos app), website |
| Sonos Music API | Integration ID: your domain reversed, e.g. com.example.radio (cannot be changed later). Configuration Label: 1.0. SMAPI Endpoint: the address of your smapi.php. SMAPI Endpoint Version: 1.1. Leave Browse, Radio and Reporting endpoints empty. Authentication Method: Anonymous. Page Size: 100. Polling Interval: 60 |
| Brand Assets | Upload at least the service icon (required, SVG works), ideally also logo and badge |
| Localization Resources | Fill in Service Summary, Service Description and Service Promo for en-US (all required) |
| Integration Capabilities | Keep the defaults |
| Service Deployment Settings | Enter your Sonos ID, found in the Sonos app in your system's settings under "About My System". Only this Sonos system will see the service. |
| Service Configuration | Click Refresh, then Send. If accepted, the server response repeats your configuration. Otherwise it lists what is missing. |
Do not click "Convert to Production". The sandbox is meant for your own system.
In the Sonos app, open the settings, go to the services and choose "Add a service". Search for your service name and add it. Your stations now appear under your services.
If adding fails with "could not be added" right after setup, the new configuration has not reached your speakers yet. This can take several hours. Try again later; a fresh configuration usually works by the next day.
Edit STATIONS and upload the file again. Sonos notices the change automatically and reloads the list, at the latest when you reopen the service.
- Status page: open
smapi.phpin a browser. It shows the version and, for each station, the exact address Sonos receives (resolved addresses are marked[from playlist]). - Debug log: set
LOG_ENABLEDtotrueandLOG_TOKENto a long random string, then opensmapi.php?log=YOUR_TOKEN. If the log stays empty while Sonos reports an error, Sonos never reached your server. The log contains IP addresses and your Sonos household ID: switch it off afterwards and deletesmapi-log.phpfrom the server. - A station does not play: check
mimeand the stream format. Test the stream address in a browser or media player.
| File | Purpose |
|---|---|
smapi.php |
The service |
smapi-cache.json |
Created automatically, caches resolved playlists |
smapi-log.php |
Only with the debug log enabled |