Python and Django Integration for RESTful Avalara Tax System
Clone or download
Latest commit f95aa0c Nov 14, 2017



What is PyAvaTax?

Avalara offers a fully featured web-based service to report your transactions, return your sales tax, and store all the information until you need to report it.

We developed PyAvaTax as a Python client library for easily integrating with Avalara's RESTful AvaTax API Service to report your transactions.

PyAvaTax does not require Django, though if you are using a Django system we have some admin-based goodies for you to check out (Django >= 1.6, see why )!

This API is not officially supported by Avalara - it is a third-party library developed and supported by Active Frequency.

Please report bugs using the GitHub issue tracker.


*Note*: Avalara is a US-only service, and thus all amounts passing through their system, and this API, are assumed to be US Dollars (USD)

AvaTax expects a JSON (or XML) POST to their tax/get/ URI, like this:

    "DocDate": "2012-10-24",
    "CompanyCode": "FooBar",
    "CustomerCode": "",
    "DocCode": "1001",
    "DocType": "SalesOrder",
            "AddressCode": "1",
            "Line1": "435 Ericksen Avenue Northeast",
            "Line2": "#250",
            "PostalCode": "98110"
            "AddressCode": "2",
            "Line1": "7562 Kearney St.",
            "PostalCode": "80022-1336"
            "LineNo": "1",
            "DestinationCode": "2",
            "OriginCode": "1",
            "Qty": 1,
            "Amount": "100"

Our library, accepts your data in a variety of ways. You instantiate the API like so


Then, you can perform an action (e.g. "Post Tax"), by passing in a data dictionary. We will parse it, validate it, handle the HTTP layer for you, and return a response object to you.

tax_response = api.post_tax(dictionary_data)
print tax_response.TotalTax  # this is unicode
>>> 0.86

That returned object will have all the response data from AvaTax easily accessible by dot-notation.

Or, you can use the library to construct objects from kwargs

doc = Document.new_sales_order(DocCode='1001',, CustomerCode='')
from_address = Address(Line1="435 Ericksen Avenue Northeast", Line2="#250", PostalCode="98110")
to_address = Address(Line1="7562 Kearney St.", PostalCode="80022-1336")
line = Line(Amount=10.00)
response = api.post_tax(doc)

Further Reading

Documentation is in docs, or at; see Advanced ( for instructions on running the test suite.