24/7/365 Support

Enabling API access for remote streaming in Ubuntu

A streaming client needs to get the details of the media available on the streaming server. The client needs to authenticate with server access the catalog and list of songs and even request offline access to store media locally. With Ampache, we can use its REST and XML APIs. Through these APIs, clients can communicate with Ampache. You can even write your own client tool using any of the supported APIs.

This recipe covers the setup process for streaming content to remote devices. As of writing this, Ampache allows all users to use all available APIs. We will learn how to modify this setting and configure it to limit access based on user accounts.

Getting ready

Open Ampache in your browser and log in with admin credentials.

How to do it…

We will create a separate user account for remote streaming. From the Ampache homepage, click on the admin icon in the top-left corner and then click on the Add User link from the User Tools section. An add user menu will be shown that looks like this:

Fill in the Username, E-mail, and Password fields for the new user account and set User Access to User.

Click the Add User button to create this user and then click Continue.

We will use this new user account to log in from the remote client.

Next, we need to configure access rights and allow this user to use APIs to stream music.

Click on the admin icon and then click on the Add ACL link under the Access Control section.

Set the name for this access control list.

Set level to Read/Write.

Set the user to the user account created in the previous step.

Set ACL type to Stream Access.

Set the start and end IP addresses to 0.0.0.0 and 255.255.255.255 respectively.

Click Create ACL to save the settings.

Click on the Add ACL link again and repeat the preceding settings, except, for ACL Type that choose API/RPC.

Now you can use Ampache streaming from your mobile client. When asked for your username and password, use our new user account, and for the streaming server URL, use your Ampache FQDN followed by /ampache, for example:

http://myampachehost.com/ampache

If your client needs an API key, you can generate one from the User Tools section.

Click on the Browse Users link and then select the user account in question. Click the edit icon to update user details and then click on the generate API key icon.

Finally, click the Update User button to save your changes.

How it works…

By default, the Ampache server creates an Access Control List that allows all access to all users. It is a good idea to create a separate user and grant only the required permissions. Here, we have created a new user account with access to the REST API and to stream content. This will allow better control over users and content, as well as allow us to set various user-specific default settings, such as default bitrate and encoding formats.

Help Category:

What Our Clients Say