Sidebar Menu

GetZipCodesForCityAndState

The GetZipCodesForCityAndState method returns all possible ZIP Codes for a given city/state combination.

Endpoint

GET (HTTP): https://pav3.cdyne.com/PavService.svc/GetZipCodesForCityAndState?City={CITY}&State={STATE}&LicenseKey={LICENSEKEY}

GET (HTTPS): https://pav3.cdyne.com/PavService.svc/rest_s/GetZipCodesForCityAndState?City={CITY}&State={STATE}&LicenseKey={LICENSEKEY}

Syntax

GetZipCodesForCityAndState(City, State, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
City

City name.

String True Chesapeake
State

Two-letter state name abbreviation.

String True VA
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 GetZipCodesForCityAndState.WSDL;

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

            ZCR = PSC.GetZipCodesForCityAndState("Chesapeake", "VA", "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.");

            Console.ReadLine();
        }
    }
}
<cfhttp method="GET" url="http://pav3.cdyne.com/PavService.svc/GetZipCodesForCityAndState" result="result">
  <cfhttpparam type="URL" name="City" value="Chesapeake">
  <cfhttpparam type="URL" name="State" value="VA">
  <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 GetZipCodesForCityAndState.WSDL
Module Module1

    Sub Main()

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

        ZCR = PSC.GetZipCodesForCityAndState("Chesapeake", "VA", "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.")
        End If

        Console.ReadLine()

    End Sub

End Module
<?php
$client = new SoapClient('http://pav3.cdyne.com/PavService.svc?wsdl');
$param = array(
  'City' => 'Chesapeake'
  , 'State' => 'VA'
  , 'LicenseKey' => 'YOUR LICENSE KEY'
);
$result = $client->GetZipCodesForCityAndState($param);

echo "<pre>";
print_r($result);
echo "</pre>";
?>
{
  "ReturnCode": 0,
  "ZipCodes": [
    "23320",
    "23321",
    "23322",
    "23323",
    "23324",
    "23325",
    "23326",
    "23327",
    "23328"
  ]
}
<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>23321</a:string>
    <a:string>23322</a:string>
    <a:string>23323</a:string>
    <a:string>23324</a:string>
    <a:string>23325</a:string>
    <a:string>23326</a:string>
    <a:string>23327</a:string>
    <a:string>23328</a:string>
  </ZipCodes>
</ZipCodesResponse>