AzuracastPy is a Python package that allows for straightforward access to AzuraCast's API.
AzuracastPy can be installed using pip.
pip install AzuracastPy
With the url of a radio hosted on AzuraCast, an instance of the AzuracastClient class can be created like so (An API Key is needed for more sensitive requests):
from AzuracastPy import AzuracastClient
client = AzuracastClient(
radio_url="radio_url",
x_api_key="(Optional) api_key"
)
With this instance, radio stations can be interacted with and queried:
# Get all stations served from the hosted radio.
stations = client.stations()
print(stations)
# Get data of a specific station.
station = client.station(1)
print(station.name, station.description, station.requestable_songs())
# Create a podcast on a station (API Key required).
from AzuracastPy.enums import Languages, PodcastCategories
station = client.station(1)
new_podcast = station.podcast.create(
title="New podcast",
description="This is a random description",
language=Languages.ARABIC,
categories=[
PodcastCategories.Arts.DESIGN,
PodcastCategories.Comedy.COMEDY_INTERVIEWS
]
)
AzuracastPy's documentation is located at https://azuracastpy.readthedocs.io/en/latest/.