Postal Address Verification API

GetCongressionalDistrictByZip

The GetCongressionalDistrictByZip method returns the Congressional District data for a given ZIP Code.

Endpoint

GET:
https://pav3.esendex.us/PavService.svc/GetCongressionalDistrictByZip?ZipCode={ZIPCODE}&LicenseKey={LICENSEKEY}

Syntax

GetCongressionalDistrictByZip(ZipCode, LicenseKey)

Request Parameters

Parameter NameDescriptionData TypeRequiredSample Value
ZipCodeZIP Code.StringTrue23320
LicenseKeyYour license key.StringTrue00000000-0000-0000-0000-000000000000

Response

Returns: CongressionalDistrictResponse object

Code Samples

You can use any programming language you want with our API, as long as it can make a REST or SOAP call. Here are examples for some of the most common platforms.

C#

// https://pav3.esendex.us/PavService.svc?wsdl was added as a Service Reference and given the name WSDL

using WSDL;

var config = PavServiceClient.EndpointConfiguration.pavws_secure;
var client = new PavServiceClient(config);
var zipCode = "23320";
var licenseKey = "YOUR_LICENSE_KEY";
var response = await client.GetCongressionalDistrictByZipAsync(zipCode, licenseKey);

var returnCodeDescription = response.ReturnCode switch
{
    0 => "Success",
    1 => "Invalid input",
    2 => "Invalid license key",
    3 => "No match",
    4 => "Multiple matches",
    _ => "Unknown return code"
};

Console.WriteLine($"Return Code: {response.ReturnCode} - {returnCodeDescription}");
Console.WriteLine($"Congressional District: {response.CongressionalDistrict}");

Console.ReadLine();

JavaScript

const params = new URLSearchParams({
    'ZipCode': '23320',
    'LicenseKey': '00000000-0000-0000-0000-000000000000'
});

const url = 'https://pav3.esendex.us/PavService.svc/GetCongressionalDistrictByZip?' + params.toString();

const options = {
    headers: {
        'Accept': 'application/json'
    }
};

const response = await fetch(url, options);
const json = await response.json();

console.log(json);

JSON Response

{
  "CongressionalDistrict": "02",
  "ReturnCode": 4
}

PHP with cURL

<?php
$client = new SoapClient('https://pav3.esendex.us/PavService.svc?wsdl');
$param = array(
  'ZipCode' => '23320'
  , 'LicenseKey' => 'YOUR LICENSE KEY'
);
$result = $client->GetCongressionalDistrictByZip($param);

echo "<pre>";
print_r($result);
echo "</pre>";
?>

Python

import httpx

headers = {"Accept": "application/json"}
url = "https://pav3.esendex.us/PavService.svc/GetCongressionalDistrictByZip"

request = {
    "ZipCode": "23320",
    "LicenseKey": "00000000-0000-0000-0000-000000000000",
}

with httpx.Client(headers=headers) as client:
    response = client.get(url=url, params=request)

response.raise_for_status()

print(response.json())

Ruby

require 'json'
require 'net/http'

headers = { Accept: 'application/json', 'Content-Type': 'application/json' }
uri = URI('https://pav3.esendex.us/PavService.svc/GetCongressionalDistrictByZip')

params = {
  'ZipCode': '23320',
  'LicenseKey': '00000000-0000-0000-0000-000000000000'
}

uri.query = URI.encode_www_form(params)
response = Net::HTTP.get(uri, headers)
raise response.message if response.is_a?(Net::HTTPClientError) || response.is_a?(Net::HTTPServerError)

puts JSON.parse(response)

XML Response

<CongressionalDistrictResponse xmlns="pav3.esendex.us" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <CongressionalDistrict>02</CongressionalDistrict>
  <ReturnCode>4</ReturnCode>
</CongressionalDistrictResponse>

Let’s start sending, together.