Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
ZipTax

Zip-Tax.com API Class

Currently only JSON is supported.

        def get_tax_rate(postalcode = None, state = None,  city = None, format = 'JSON'):
    """
    ZipTax

    Zip-Tax.com API Class

    Currently only JSON is supported.
    """
    params = {
        'state': state,
        'postalcode': postalcode,
        'city': city,
        'key': ZIPTAX_API_KEY,
        'format': format
    }
    for a, b in params.items():
        if b is None:
            del params[a]
    params = urlencode(params)
    try:
        request = urllib2.urlopen(urlunparse((
            'http', 
            ZIPTAX_API_URL, 
            'request/%s' % ZIPTAX_API_VERSION,
            None,
            params,
            None
        )))
        request = load(request)
    except Exception, e:
        raise Ziptax_Failure(str(e))
    if request is False:
        raise Ziptax_Failure('UNKNOWN FAILURE')
    if request['rCode'] != 100:
        raise Ziptax_Failure(RESPONSE_CODES[request['rCode']])
    if len(request['results']) == 0:
        return False
    return request['results'][0]['taxSales']
        


src/p/y/python-ziptax-1.0.2/example.py   python-ziptax(Download)
 
# Getting tax rate for zipcode
print ziptax.get_tax_rate(32725)
# 0.064999997615814
 
# Catch Errors
try:
    tax_rate = ziptax.get_tax_rate(23452)