Code Examples
Example integrations using the Service Area WIZARD API in various languages.
Code Examples
cURL
curl -X POST https://app.serviceareawizard.com/api/check \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"country": "United Kingdom",
"radius": 30,
"origin": "SW1A 1AA",
"destination": "EC1A 1BB"
}'
JavaScript (Fetch)
const response = await fetch('https://app.serviceareawizard.com/api/check', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
country: 'United Kingdom',
radius: 30,
origin: 'SW1A 1AA',
destination: 'EC1A 1BB'
})
})
const data = await response.json()
if (data.success && data.data.within_radius) {
console.log('Customer is within your service area!')
} else {
console.log('Customer is outside your service area.')
}
PHP
$ch = curl_init('https://app.serviceareawizard.com/api/check');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN',
'Content-Type: application/json'
],
CURLOPT_POSTFIELDS => json_encode([
'country' => 'United Kingdom',
'radius' => 30,
'origin' => 'SW1A 1AA',
'destination' => 'EC1A 1BB'
])
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success'] && $data['data']['within_radius']) {
echo 'Customer is within your service area!';
}
Python
import requests
response = requests.post(
'https://app.serviceareawizard.com/api/check',
headers={
'Authorization': 'Bearer YOUR_API_TOKEN',
'Content-Type': 'application/json'
},
json={
'country': 'United Kingdom',
'radius': 30,
'origin': 'SW1A 1AA',
'destination': 'EC1A 1BB'
}
)
data = response.json()
if data['success'] and data['data']['within_radius']:
print('Customer is within your service area!')