Use these example PHP scripts to retrieve and display all available Advanced Search Fields for a specific MLS using the IDX Broker API.
These examples:
- Retrieve available advanced search fields
- Display field names dynamically
- Retrieve possible values for each field
- Test API connectivity and response codes
Overview
The included scripts perform API calls against the IDX Broker API to:
- Retrieve available Advanced Search Fields for an MLS
- Display those fields as clickable links
- Retrieve all available values for a selected field
This can be useful when:
- Building custom search tools
- Creating advanced search interfaces
- Troubleshooting MLS field availability
- Exploring searchable metadata within an MLS feed
Script 1 — Retrieve Advanced Field Values
This script retrieves available values for a specific advanced field.
Example endpoint:
https://api.idxbroker.com/mls/searchfieldvalues/{mlsID}?mlsPtID=1&name={fieldName}Example PHP Script
<?php
$value = $_GET["name"];
$key = $_GET["key1"];
$dev_key = $_GET["key2"];
$mlsid = $_GET["mls"];
$propt = '1';
// access URL and request method
$url = 'https://api.idxbroker.com/mls/searchfieldvalues/' . $mlsid . '?mlsPtID='. $propt . '&name=' . $value;
$method = 'GET';
// headers
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'accesskey: ' . $key,
'ancillarykey: ' . $dev_key,
'outputtype: json'
);
// set up cURL
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
// execute request
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($code >= 200 || $code < 300)
$fields = json_decode($response,true);
else
$error = $code;
echo $code;
echo '<br>';
echo 'url used, mls, and keys: ' . $url . ' and ' . $key . ' and ' . $dev_key;
echo '<br><br>';
var_dump($response);
?>What This Script Does
This script:
- Accepts an MLS ID and field name
- Performs an API request
- Returns available values for that field
- Outputs the raw API response
Required Parameters
| Parameter | Description |
|---|---|
name | Advanced field name |
key1 | IDX Broker API access key |
key2 | Partner ancillary key (optional) |
mls | MLS ID |
Script 2 — Display Available Advanced Fields
This script retrieves all available advanced search fields for an MLS and displays them as clickable links.
Example PHP Script
<html>
<head>
</head>
<body>
<?php
$test_key = $dev_test_key = $mlsID = $meth = $out = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$test_key = test_input($_POST["test_key"]);
$dev_test_key = test_input($_POST["dev_test_key"]);
$meth = test_input($_POST["meth"]);
$out = test_input($_POST["out"]);
$mlsID = test_input($_POST["mlsID"]);
}
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<h1>Quick API Advanced Fields Check</h1>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Test Key:
<input type="text" name="test_key">
Test Dev Partner Key:
<input type="text" name="dev_test_key">
<br>MLS ID:
<input type="text" name="mlsID">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
$method = 'GET';
if ($test_key == "")
{
echo '<br><br><h2>Please enter an API key to test</h2>';
}
else if ($meth == "")
{
$url = 'https://api.idxbroker.com/mls/searchfields/' . $mlsID . '?filterField=mlsPtID&filterValue=1';
$out = 'json';
$headers = array(
"Content-Type: application/x-www-form-urlencoded",
"accesskey: " . $test_key,
"ancillarykey: " . $dev_test_key,
"outputtype: " . $out
);
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($handle);
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if ($out == 'json')
{
$response = json_decode($response,true);
}
echo '<br><br>Returned response code from API: <b>';
echo $code;
echo '</b><br><br>';
echo 'URL used: ' . $url;
}
echo '<br><br>';
foreach ($response as $item) {
echo '<a href="adv_fields_values/values.php?name=' . $item["name"] . '&key1=' . $test_key . '&key2=' . $dev_test_key . '&mls=' . $mlsID . '" target="_blank">' . $item["name"] . '</a>';
echo '<br>';
}
?>
</body>
</html>What This Script Does
This script:
- Retrieves all available advanced fields for an MLS
- Displays each field as a clickable link
- Passes the field name into the values lookup script
Each link opens:
- Available field values
- Raw API response data
Example API Endpoint
https://api.idxbroker.com/mls/searchfields/{mlsID}?filterField=mlsPtID&filterValue=1Common API Response Codes
| Code | Meaning |
|---|---|
200 | Request successful |
204 | No content returned |
401 | Invalid or revoked access key |
403 | HTTPS/SSL issue |
405 | Invalid request method |
406 | Missing access key |
409 | Invalid API component |
412 | Hourly API limit exceeded |
500 | General server error |
503 | API maintenance in progress |
Security Recommendations
Avoid Exposing API Keys
These examples are intended for:
- Testing
- Development
- Internal troubleshooting
Do not expose:
- Access keys
- Ancillary keys
- Sensitive API credentials publicly
Disable SSL Bypass in Production
The example scripts include:
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);These settings should NOT be used in production environments.
Best Practices
Sanitize User Input
The included test_input() function helps sanitize submitted values before use.
Use HTTPS
Always perform IDX Broker API requests over HTTPS.
Limit Debug Output
Avoid displaying:
- Raw credentials
- Full API responses
- Debug information
on public-facing pages.
Use Cases
These scripts are commonly used for:
- Custom search builders
- Dynamic search interfaces
- MLS field discovery
- Advanced filtering tools
- API troubleshooting
- Field mapping workflows