Created
May 9, 2012 18:34
-
-
Save harit-sunrun/2647773 to your computer and use it in GitHub Desktop.
Query CDYNE Advanced Address Verification web service using Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| This Gist will show you how to verify a postal address using CDYNE advanced address verification web service | |
| The following code assumes that you have a valid license key | |
| Document Reference : http://pav3.cdyne.com/Pavservice.svc/help/operations/VerifyAddressAdvanced | |
| """ | |
| import json | |
| import urllib2 | |
| import urllib | |
| url = 'http://pav3.cdyne.com/PavService.svc/VerifyAddressAdvanced' | |
| data = {} | |
| data['CityName'] = 'San Francisco' | |
| data['FirmOrRecipient'] = 'CDYNE' | |
| data['LicenseKey'] = 'YOUR_LICENSE_KEY' | |
| data['PrimaryAddressLine'] = '45 Fremont Street' | |
| data['ReturnCaseSensitive'] = True | |
| data['ReturnCensusInfo'] = True | |
| data['ReturnCityAbbreviation'] = True | |
| data['ReturnGeoLocation'] = True | |
| data['ReturnLegislativeInfo'] = True | |
| data['ReturnMailingIndustryInfo'] = True | |
| data['ReturnResidentialIndicator'] = True | |
| data['SecondaryAddressLine'] = '' | |
| data['State'] = 'CA' | |
| data['Urbanization'] = '' | |
| data['ZipCode'] = '94105' | |
| data_encoded = json.dumps(data) | |
| req = urllib2.Request(url, data_encoded, {'Content-Type': 'application/json'}) | |
| response = urllib2.urlopen(req) | |
| the_page = response.read() | |
| """ | |
| The response 'the_page' looks like the following | |
| { | |
| "CensusInfo": { | |
| "CMSA": "", | |
| "CensusBlockNumber": "1006", | |
| "CensusTractNumber": "0176.02", | |
| "FIPS": "06075", | |
| "MA": "084", | |
| "MSA": "", | |
| "PMSA": "7360" | |
| }, | |
| "CityName": "San Francisco", | |
| "Country": "USA", | |
| "County": "SAN FRANCISCO", | |
| "CountyNum": "075", | |
| "FinanceNumber": "56786", | |
| "FirmOrRecipient": "CDYNE", | |
| "GeoLocationInfo": { | |
| "AreaCode": "415", | |
| "AvgLatitude": "37.7910885", | |
| "AvgLongitude": "-122.397477", | |
| "FromLatitude": "37.791716", | |
| "FromLongitude": "-122.398264", | |
| "HasDaylightSavings": true, | |
| "TimeZone": "PST", | |
| "ToLatitude": "37.790461", | |
| "ToLongitude": "-122.396690" | |
| }, | |
| "IntelligentMailBarcodeKey": "fNvGhQsDCOzWhoTQuD68IA==", | |
| "LegislativeInfo": { | |
| "CongressionalDistrictNumber": "08", | |
| "StateLegislativeLower": "013", | |
| "StateLegislativeUpper": "003" | |
| }, | |
| "MailingIndustryInfo": { | |
| "CSKey": "Z22802", | |
| "CarrierRoute": "C014", | |
| "CheckDigit": "5", | |
| "DefaultFlag": true, | |
| "DeliveryPoint": "99", | |
| "DpvConfirmationIndicator": "D", | |
| "DpvCrmaIndicator": "N", | |
| "DpvFootnote1": "AA", | |
| "DpvFootnote2": "N1", | |
| "DpvFootnote3": "", | |
| "DpvNoStatIndicator": "N", | |
| "DpvVacantIndicator": "N", | |
| "ELOTAscDesc": "D", | |
| "ELOTSequenceNumber": "0185", | |
| "EwsFlag": false, | |
| "LACSFlag": "", | |
| "LACSIndicator": "", | |
| "LACSReturnCode": "", | |
| "RecordTypeCode": "H", | |
| "SuiteLinkReturnCode": "00" | |
| }, | |
| "MultipleMatches": [ | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2205", | |
| "Plus4Low": "2205", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "2900", | |
| "SecondaryLow": "2900", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2209", | |
| "Plus4Low": "2209", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "2800", | |
| "SecondaryLow": "2800", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "CALIFORNIA COASTAL", | |
| "Plus4High": "2254", | |
| "Plus4Low": "2254", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "O", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "F", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "E", | |
| "SecondaryHigh": "1970", | |
| "SecondaryLow": "1970", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2200", | |
| "Plus4Low": "2200", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "200", | |
| "SecondaryLow": "200", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2212", | |
| "Plus4Low": "2212", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "500", | |
| "SecondaryLow": "500", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2213", | |
| "Plus4Low": "2213", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "2700", | |
| "SecondaryLow": "2700", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2210", | |
| "Plus4Low": "2210", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "700", | |
| "SecondaryLow": "700", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2211", | |
| "Plus4Low": "2211", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "B", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "400", | |
| "SecondaryLow": "400", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2219", | |
| "Plus4Low": "2219", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "O", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "E", | |
| "SecondaryHigh": "1700", | |
| "SecondaryLow": "1600", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| }, | |
| { | |
| "CarrierRoute": "C014", | |
| "FinanceNumber": "56786", | |
| "Firm": "", | |
| "Plus4High": "2219", | |
| "Plus4Low": "2219", | |
| "PostDirectional": "", | |
| "PreDirectional": "", | |
| "PrimaryEO": "O", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "RecordTypeCode": "H", | |
| "SecondaryAbbreviation": "STE", | |
| "SecondaryEO": "E", | |
| "SecondaryHigh": "1930", | |
| "SecondaryLow": "1770", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "ZipCode": "94105" | |
| } | |
| ], | |
| "PMBDesignator": "", | |
| "PMBNumber": "", | |
| "PostDirectional": "", | |
| "PostnetBarcode": "f941052204995f", | |
| "PreDirectional": "", | |
| "PreferredCityName": "San Francisco", | |
| "Primary": "45", | |
| "PrimaryDeliveryLine": "45 Fremont St", | |
| "PrimaryEO": "O", | |
| "PrimaryHigh": "45", | |
| "PrimaryLow": "45", | |
| "ResidentialDeliveryIndicator": "N", | |
| "ReturnCode": 103, | |
| "Secondary": "", | |
| "SecondaryAbbreviation": "", | |
| "SecondaryDeliveryLine": "", | |
| "SecondaryEO": "B", | |
| "SecondaryHigh": "", | |
| "SecondaryLow": "", | |
| "StateAbbreviation": "CA", | |
| "StreetName": "FREMONT", | |
| "Suffix": "ST", | |
| "Urbanization": "", | |
| "ZipCode": "94105-2204" | |
| } | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment