Skip to main content

TaxTea - Django App that calculates tax rates for SaaS products

Project description


Django app that calculates tax rates for SaaS products :frog: :tea:
A little package that goes a long way. Built by Matt Strayer and contributors

Table of Contents


Taxes are hard, but that shouldn't stop you from building your dreams. When building lowercase, we found out just how hard calculating the right sales tax rate is. TaxTea does the heavy lifting, and tells you exactly what sales tax, if any, you need to charge your customers. So, sit back, sip some tea, and channel your inner Kermit because tax rates are none of your business...anymore!

Currently only supporting US 🇺🇸


  • Simple API: Get up & running in minutes.
  • Tax Nexuses, Origin, & Destination Support: The three factors in calculating tax rates. TaxTea handles them all expertly.
  • Up-to-date: No more fear of charging a wrong tax rate. TaxTea is always up to date.


pip install django-taxtea


Add the following to your Django settings:

TAXTEA_USPS_USER = "XXXXXXXX"           # required
TAXTEA_AVALARA_USER = "XXXXXXXX"        # required
TAXTEA_NEXUSES = [("AZ", "12345"),]     # required
TAXTEA_TAX_RATE_INVALIDATE_INTERVAL = 7 # optional, default is 7 (days)

Required Accounts & Information


TaxTea uses the USPS web service API to find states for Zip Codes. You'll need to register for a free account here.

NOTE: TaxTea only needs the USPS user, not the password.


TaxTea relies on Avalara for getting up-to-date tax rates for Zip Codes. The Avalara website can be confusing, but to register simply hit the API endpoint documented here.


Your TAXTEA_NEXUSES are any place where your company has a presence. For example, every company has a nexus where they incorporated. We require there to be at least one item in this list, which is your physical incorporation state/zip.

Nexuses are part of the equation of how TaxTea calculates sales tax.

The determination of sales tax sourcing is predicated on whether a given state's model for taxation is:

  • Origin-based, or
  • Destination-based

For example, if your incorporation state is an Origin-based state and a customer purchases your product who also lives in that state, it is the nexus' Zip Code that is used to determine the tax rate, not the customer's location.

Destination-based sales tax means that the sales tax will be charged at the rate of the customer location. This is applicable for out of state transactions and transactions within a state that is not an Origin-based.

Want to learn more? Here's a great article about Origin vs. Destination-based Sales tax from TaxJar.




Run migrations:

python migrate


Import the ZipCode model:

from taxtea.models import ZipCode

# Get the ZipCode Object from the database
# If no object exists for this Zip Code, it will create one by
# fetching data from the USPS API and storing it in the database.
# At this point, there will be no `tax_rate` associated with it.

zip_code = ZipCode.get("90210")

# The `applicable_tax_rate` property is the workhorse of TaxTea.
# It will fetch & store a tax rate from the Avalara API and then
# use your tax nexuses to determine which tax rate is applicable.

tax_rate = zip_code.applicable_tax_rate
# Returns a Decimal object that will look like `0.0625`

# For convenience, there is a classmethod to convert to a percent.

percentage = ZipCode.tax_rate_to_percentage(tax_rate)
# Returns a Decimal object that will look like `6.25`


Read the documentation.


TaxTea uses a list provided by TaxJar to populate the states and their tax collection methods.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-taxtea-1.0.2.tar.gz (14.0 kB view hashes)

Uploaded source

Built Distribution

django_taxtea-1.0.2-py3-none-any.whl (15.4 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page