Walk Score API Sample Code
This is a live example of the Walk Score API:
Beds: 3
Baths: 2
AJAX API Overview
Using the Walk Score API requires working knowledge of AJAX. Specifically:
- Making an AJAX call to the Walk Score API. The example on this page uses the the Prototype JavaScript library to handle the AJAX request.
- The AJAX request is processed by a PHP page (sample code below) that retrieves the Walk Score via the Walk Score API
- The Walk Score is dynamically written into the HTML page using JavaScript
Making a Server-Side API Request
This is a PHP example of making a Walk Score API request from your server.
<?
function getWalkScore($lat, $lon) {
$url = "http://api.walkscore.com/score?format=json&lat=$lat&lon=$lon&wsapikey=YOUR-API-KEY";
$str = @file_get_contents($url);
return $str;
}
$lat = $_GET['lat'];
$lon = $_GET['lon'];
$json = getWalkScore($lat,$lon);
echo $json;
?>
Back to the Walk Score API documentation.
Contact us for tech support.
