The AzuracastClient Class

class AzuracastPy.AzuracastClient(radio_url: str | None = None, x_api_key: str | None = None, config: str | None = None)

The Azuracast API client.

This will be used to access the data and actions provided by an Azuracast web radio.

This is how to obtain an instance of this class, with explicit parameters:

from AzuracastPy import AzuracastClient

client = AzuracastClient(
    radio_url="Your radio's public URL.",
    x_api_key="Your account's API key. This can be created from your profile on the site."
)

To achieve the same thing, but with a config file:

from AzuracastPy import AzuracastClient

client = AzuracastClient(
    config="Path to the '*.ini' configuration file containing the values."
)
__init__(radio_url: str | None = None, x_api_key: str | None = None, config: str | None = None)

Constructs an Azuracast API client.

Parameters:
  • radio_url – (Optional) Your radio’s URL, which was set upon its creation. Provide this or the ‘config’ param value. Default: None.

  • x_api_key – (Optional) Your account’s API key, which can be generated from your profile. Provide this or the ‘config’ param value. Default: None.

  • config – (Optional) Path to the config file with the needed details. Provide this or the ‘radio_url’ and ‘x_api_key’ param values. Default: None.

Note

If a config param is provided, the values in the specified config file will overwrite the values of the radio_url and x_api_key params.

admin() Admin

Exposes administration actions for a radio.

Returns:

An Admin object.

Usage:

admin = client.admin()
now_playing(station_id: int | None = None) List[NowPlaying] | NowPlaying

Retrieves now playing information for a specific station or all stations.

Parameters:

station_id – (Optional) The ID of the station to retrieve data for. If None, retrieves data for all stations. Default: None.

Returns:

A list of NowPlaying objects, or a single NowPlaying object, depending on whether or not a station_id was provided.

To get the now-playing details of a single station whose id is 1:

station_now_playing = client.now_playing(1)

To get the now-playing details of all stations on the radio:

all_now_playing = client.now_playing()
station(id: int) Station

Retrieves a specific station on the radio.

Parameters:

id – The numerical ID of the station to be retrieved.

Returns:

A Station object.

Usage:

station = client.station(1)
stations() List[Station]

Retrieves list of stations on the radio.

Returns:

A list of Station objects.

Usage:

stations = client.stations()
status()
Returns:

The status of the radio’s API.

Usage:

status = client.status()
time()
Returns:

The current time.

Usage:

time = client.time()