Sidebar Menu

GetCityNamesForZipCode

The GetCityNamesForZipCode method returns all possible city names for a given ZIP Code.

Endpoint

GET (HTTP): https://pav3.cdyne.com/PavService.svc/GetCityNamesForZipCode?ZipCode={ZIPCODE}&LicenseKey={LICENSEKEY}

GET (HTTPS): https://pav3.cdyne.com/PavService.svc/rest_s/GetCityNamesForZipCode?ZipCode={ZIPCODE}&LicenseKey={LICENSEKEY}

Syntax

GetCityNamesForZipCode(ZipCode, LicenseKey)

Request Parameters

Parameter Name Description Data Type Required Sample Value
ZipCode

ZIP Code.

String True 23456
LicenseKey

Your license key.

String True F01d89fd-5155-5455-5585-e84ab8de8591

Response

Returns: CityNamesResponse 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 GetCityNamesForZipCode.WSDL;

namespace GetCityNamesForZipCode
{
    class Program
    {
        static void Main(string[] args)
        {
            WSDL.PavServiceClient PSC = new WSDL.PavServiceClient("pavsoap");
            WSDL.CityNamesResponse CNR = new WSDL.CityNamesResponse();

            CNR = PSC.GetCityNamesForZipCode("23320", "YOUR LICENSE KEY");

            if (CNR.ReturnCode == 0)
            {
                Console.WriteLine("City Name: " + "\n");

                foreach (WSDL.City city in CNR.CityNames)
                {
                    Console.WriteLine(city.Name);
                }
            }
            else if (CNR.ReturnCode == 1)
                Console.WriteLine("Invalid input.");
            else if (CNR.ReturnCode == 2)
                Console.WriteLine("Invalid license key.");
            else if (CNR.ReturnCode == 3)
                Console.WriteLine("No match found.");

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

    Sub Main()

        Dim PSC As New PavServiceClient("pavsoap")
        Dim CNR As New CityNamesResponse

        CNR = PSC.GetCityNamesForZipCode("23320", "YOUR LICENSE KEY")

        If CNR.ReturnCode = 0 Then
            Console.WriteLine("City Name: " & vbLf)

            For Each city As WSDL.City In CNR.CityNames
                Console.WriteLine(city.Name)
            Next

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

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

        ElseIf CNR.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(
  'ZipCode' => '23320'
  , 'LicenseKey' => 'YOUR LICENSE KEY'
);
$result = $client->GetCityNamesForZipCode($param);

echo "<pre>";
print_r($result);
echo "</pre>";
?>
{
  "CityNames": [
    {
      "IsDefault": false,
      "IsMailing": true,
      "Name": "PRINCESS ANNE"
    },
    {
      "IsDefault": false,
      "IsMailing": true,
      "Name": "VA BEACH"
    },
    {
      "IsDefault": true,
      "IsMailing": true,
      "Name": "VIRGINIA BEACH"
    }
  ],
  "ReturnCode": 0
}
<CityNamesResponse xmlns="pav3.cdyne.com" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <CityNames>
    <City>
      <IsDefault>false</IsDefault>
      <IsMailing>true</IsMailing>
      <Name>PRINCESS ANNE</Name>
    </City>
    <City>
      <IsDefault>false</IsDefault>
      <IsMailing>true</IsMailing>
      <Name>VA BEACH</Name>
    </City>
    <City>
      <IsDefault>true</IsDefault>
      <IsMailing>true</IsMailing>
      <Name>VIRGINIA BEACH</Name>
    </City>
  </CityNames>
  <ReturnCode>0</ReturnCode>
</CityNamesResponse>