Showing results for 
Search instead for 
Did you mean: 

Tech Tip: Using the RESTful Control API with PHP - listpools

The following code uses Stingray's RESTful API to list all the pools defined on a cluster. The code is written in PHP and uses STMRESTClient. This example has more extensive comments then the following examples and most of these are applicable to all the examples. This program does a single GET request for the list of pools and then loops through that list, each element of which is an associative array, and then outputs the pool name.





# Display a list of pools

require_once '';


try {

    # Setup the connection to the REST API

    $client = new STMRestClient();

    # Do the HTTP GET to get the lists of pools

    $response = $client->get('pools');

    # Get the list of pools from the response as an object

    $pools = $response->children;

    # Loop through the list of pools

    foreach ($pools as $pool) {

        print($pool->name . "<br>\n");


} catch (STMConnectException $e) {

    /* We weren't able to connect to the Stingray Traffic Manager REST API

       The most likely reasons for this are:

       - the hostname of the Stingray instance is incorrect

       - this client doesn't have network access to the Stingray instance or port 9070

       - the RESTful API is disabled

       - the RESTful API is using using a different port */

    print ("Error connecting to the REST API: " . $e->getMessage());

} catch (STMAuthException $e) {

    /* We were able to connect to the Stingray Traffic Manager REST API but could not log in

       The user name or password were incorrect.  If they weren't specified then the default

       values are being used and may need to be changed or the user name and password can

       be specified */

    print ("Error logging into the REST API: " . $e->getMessage());

} catch (exception $e) {

    print ('Error: ' . $e->getMessage());





Running the example


This code was tested with PHP 5.3.3 and uses the STMRestClient class that can be found here: Tech Tip: A Stingray Traffic Manager REST Client for PHP


To run this program, Make it available via a web server and the output should be:






Read More



Version history
Revision #:
2 of 2
Last update:
‎01-06-2021 04:19:PM
Updated by:
Labels (1)