Download the PHP package radioapi/php without Composer
On this page you can find all versions of the php package radioapi/php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package php
Short Description A small PHP client for the RadioAPI Management, Now Playing, and Stream Router APIs.
License MIT
Homepage https://github.com/RadioAPI/RadioAPI
Informations about the package php
RadioAPI PHP SDK
A small PHP client for RadioAPI. It covers station management, public and private Now Playing requests, and Stream Router routes.
Install
The package requires PHP 8.2+ and ext-json. It uses Guzzle's ClientInterface, so you can inject your own configured HTTP client.
To publish it, release the contents of this package/ directory as the
radioapi/php repository, tag a version such as v1.0.0, and submit that
repository to Packagist. Composer will then resolve the command above.
Start here
Create a client with an API key for the Management API. Pass the root URL of your RadioAPI app, without /api/v1.
The base URL comes first so the simplest setup is also clear when using positional arguments:
Inject a configured Guzzle client only when you need custom middleware, retries, timeouts, or a test client:
For public Now Playing, use a client without an API key and the same API base URL:
Stations
The supported stream metadata providers are jcplayer (generic/ICY), azuracast, radioking, and live365. AzuraCast, RadioKing, and Live365 require stream_metadata_settings.url.
list() returns the API pagination object with data, links, and meta. create(), find(), and update() return the unwrapped resource from data.
Now Playing
Use the same authenticated client for a private station. Public stations do not need an API key:
Now Playing returns a top-level metadata object. The upstream stream field is never exposed. The payload can include name, bitrate, format, artist, song, album, genre, artwork, year, duration, elapsed, remaining, time, lyrics, explicit, songFound, and metadataFound.
When Track History is enabled for the station and the provider has history available, the response also has a history array. Treat provider metadata as optional: an unavailable field is usually an empty string or zero value.
Stream Router
Create a public route that follows a station’s current stream URL:
Or route straight to an external stream without a station:
Use exactly one of station_uuid or target_url when creating or changing a route. Valid redirect_status_code values are 302 and 307.
Errors
All non-2xx responses throw RadioApi\Exceptions\ApiException. It carries the HTTP status, RadioAPI error code, response payload, and response headers.
Malformed or empty JSON responses throw RadioApi\Exceptions\InvalidResponseException. Network failures throw RadioApi\Exceptions\TransportException with the original Guzzle exception attached as the previous exception.
Test the package
License
MIT. See LICENSE.