Sidebar Menu

GetZipCodesWithinDistance

The GetZipCodesWithinDistance method returns all ZIP Codes within a radius around a given latitude/longitude geolocation.

Endpoint

GET (HTTP): https://pav3.cdyne.com/PavService.svc/GetZipCodesWithinDistance?Latitude={LATITUDE}&Longitude={LONGITUDE}&Radius={RADIUS}&LicenseKey={LICENSEKEY}

GET (HTTPS): https://pav3.cdyne.com/PavService.svc/rest_s/GetZipCodesWithinDistance?Latitude={LATITUDE}&Longitude={LONGITUDE}&Radius={RADIUS}&LicenseKey={LICENSEKEY}

Syntax

GetZipCodesWithinDistance(Latitude, Longtitude, Radius, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
Latitude

Latitude coordinate from -179.2311 to 179.8597.

String True 36.763075
Longtitude

Longitude coordinate from 17.8315 to 71.4411.

String True -76.258473
Radius

Radius in miles. (The maximum is 50.)

String True 2.1
LicenseKey

Your license key.

String True F01d89fd-5155-5455-5585-e84ab8de8591

Response

Returns: ZipCodesResponse object

Code Samples

// http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GetZipCodesWithinDistance.WSDL;

namespace GetZipCodesWithinDistance
{
    class Program
    {
        static void Main(string[] args)
        {
            WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
            WSDL.ZipCodesResponse ZCR = new WSDL.ZipCodesResponse();

            ZCR = PSC.GetZipCodesWithinDistance("36.761560", "-76.259964", "5", "YOUR LICENSE KEY");

            if (ZCR.ReturnCode == 0)
            {
                Console.WriteLine("ZIP Code(s) found:" + "\n");

                foreach (string Zip in ZCR.ZipCodes)
                {
                    Console.WriteLine(Zip);
                }
            }
            else if (ZCR.ReturnCode == 1)
                Console.WriteLine("Invalid input.");
            else if (ZCR.ReturnCode == 2)
                Console.WriteLine("Invalid license key.");
            else if (ZCR.ReturnCode == 3)
                Console.WriteLine("No match found.");
            else if (ZCR.ReturnCode == 4)
                Console.WriteLine("Outside of latitude/longitude range.");

            Console.ReadLine();
        }
    }
}
<cfhttp method="GET" url="http://pav3.cdyne.com/PavService.svc/GetZipCodesWithinDistance" result="result">
  <cfhttpparam type="URL" name="Latitude" value="36.761560">
  <cfhttpparam type="URL" name="Longitude" value="-76.259964">
  <cfhttpparam type="URL" name="Radius" value="5">
  <cfhttpparam type="URL" name="LicenseKey" value="YOUR LICENSE KEY">
</cfhttp>
<cfset xmlDoc = XmlParse(#result.FileContent#) />
<cfdump var="#xmlDoc#" />
' http://pav3.cdyne.com/PavService.svc?wsdl was added as Service Reference and given the name WSDL

Imports GetZipCodesWithinDistance.WSDL
Module Module1

    Sub Main()

        Dim PSC As New PavServiceClient("pavsoap")
        Dim ZCR As New ZipCodesResponse

        ZCR = PSC.GetZipCodesWithinDistance("36.761560", "-76.259964", "5", "YOUR LICENSE KEY")

        If ZCR.ReturnCode = 0 Then
            Console.WriteLine("ZIP Code(s) found: " & vbLf)

            For Each Zip As String In ZCR.ZipCodes
                Console.WriteLine(Zip)
            Next

        ElseIf ZCR.ReturnCode = 1 Then
            Console.WriteLine("Invalid input.")

        ElseIf ZCR.ReturnCode = 2 Then
            Console.WriteLine("Invalid license key.")

        ElseIf ZCR.ReturnCode = 3 Then
            Console.WriteLine("No match found.")

        ElseIf ZCR.ReturnCode = 4 Then
            Console.WriteLine("Outside of latitude/longitude range.")
        End If

        Console.ReadLine()

    End Sub

End Module
<?php
$client = new SoapClient('http://pav3.cdyne.com/PavService.svc?wsdl');
$param = array(
  'Latitude' => '36.761560'
  , 'Longitude' => '-76.259964'
  , 'Radius' => '5'
  , 'LicenseKey' => 'YOUR LICENSE KEY'
);
$result = $client->GetZipCodesWithinDistance($param);

echo "<pre>";
print_r($result);
echo "</pre>";
?>
{
  "ReturnCode": 0,
  "ZipCodes": [
    "23320",
    "23325",
    "23324"
  ]
}
<ZipCodesResponse xmlns="pav3.cdyne.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ReturnCode>0</ReturnCode>
  <ZipCodes xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <a:string>23320</a:string>
    <a:string>23325</a:string>
    <a:string>23324</a:string>
  </ZipCodes>
</ZipCodesResponse>