Slipstream API Client

There are a few ways to interact with the Slipstream API directly through the Membership plugin.

PHP Slipstream API Client

While API client can be called directly via Membership::apiController, it is highly recommended to make all listing related API calls via IdxSearchModel which is provided by the Responsive IDX plugin.

// Create a new search model

$idxSearchModel = new hji\ResponsiveIDX\models\IdxSearchModel();

// Array of parameters to pass to the API method
// See API Documentation for supported parameters:
// https://slipstream-test.homejunction.com/v1/docs/

$params = array('id' => 'b8bbc818f35f210ec5236cff2978340e', 'details' => true);

// Call API method
// available methods are in hji\membership\common\utils\APIClient.

$result = $idxSearchModel->getAreas( $params );

// Check for API errors

if ($error = $idxSearchModel->getErrorMessage())
{
    var_dump($error);
}
else
{
    var_dump($result);
}

JS Slipstream API Client

You can use javascript to load and interact with the Slipstream API very easily. Since we use RequireJS for script loading, it's easy to load the library(ies) you need. Some examples are outlined below.

getArea() JS Component

getArea() is a JavaScript component provided by Membership plugin and allows user to lookup existing polygons as well as draw custom ones for the purpose of re-using these areas in API searches.

For example: a custom area can be drawn or combined with existing polygons to search for listings or schools.

Code Example

require(['hji-common/getArea'], // loads the getArea script
    function(getArea)
    {        
        var modelOptions = {
            market:    'armls',          // MLS market
            target:    '#search-by-area',// HTML wrapper selector where component's markup will be placed
        },

        /**
         * @area - array of polygons and HJI polygon pointers.
         * @area array can be passed as a value of the polygon filter of Slipstream API
         * @data - raw data for the polygons and custom drawn shapes
         */
        customCallback = function(area, data)
        {
            /* do something with the area data */
        };

        // Instantiate model and pass our options and callback

        new getArea(modelOptions, customCallback );
    }
);

Still need help? Contact Us Contact Us