Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

TaxJar Sales Tax API for Python GitHub tag (latest SemVer)

TaxJar

Official Python client for the TaxJar API. For the API documentation, please visit https://developers.taxjar.com/api.

  • This wrapper supports 100% of the TaxJar API Version 2
  • Data returned from API calls are mapped to Python objects

Supported Python Versions
Package Dependencies
Getting Started
Authentication
Usage
Custom Options
Sandbox Environment
Tests
Contributing


Supported Python Versions

Python 2.6+ or Python 3+

Package Dependencies

TaxJar uses the following dependencies as specified in setup.py:

  • Requests HTTP library for making RESTful requests to the TaxJar API.
  • jsonobject Simple JSON object mapping for Python.

Getting Started

We recommend installing TaxJar via PyPI using pip. Before authenticating, get your API key from TaxJar. Run the following command in your terminal:

pip install taxjar

Authentication

To authenticate with our API, import the taxjar package and instantiate a new API client:

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

You're now ready to use TaxJar! Check out our quickstart guide to get up and running quickly.

Usage

categories - List all tax categories
tax_for_order - Calculate sales tax for an order
list_orders - List order transactions
show_order - Show order transaction
create_order - Create order transaction
update_order - Update order transaction
delete_order - Delete order transaction
list_refunds - List refund transactions
show_refund - Show refund transaction
create_refund - Create refund transaction
update_refund - Update refund transaction
delete_refund - Delete refund transaction
list_customers - List customers
show_customer - Show customer
create_customer - Create customer
update_customer - Update customer
delete_customer - Delete customer
rates_for_location - List tax rates for a location (by zip/postal code)
nexus_regions - List nexus regions
validate_address - Validate an address
validate - Validate a VAT number
summary_rates - Summarize tax rates for all regions


List all tax categories (API docs)

The TaxJar API provides product-level tax rules for a subset of product categories. These categories are to be used for products that are either exempt from sales tax in some jurisdictions or are taxed at reduced rates. You need not pass in a product tax code for sales tax calculations on product that is fully taxable. Simply leave that parameter out.

Definition

client.categories

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.categories()

Example Response

[
  <TaxJarCategory {
    'product_tax_code': '31000',
    'name': 'Digital Goods',
    'description': 'Digital products transferred electronically, meaning obtained by the purchaser by means other than tangible storage media.'
  }>,
  <TaxJarCategory {
    'product_tax_code': '20010',
    'name': 'Clothing',
    'description': ' All human wearing apparel suitable for general use'
  }>,
  <TaxJarCategory {
    'product_tax_code': '51010',
    'name': 'Non-Prescription',
    'description': 'Drugs for human use without a prescription'
  }>
]

Calculate sales tax for an order (API docs)

Shows the sales tax that should be collected for a given order.

Definition

client.tax_for_order

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.tax_for_order({
  'from_country': 'US',
  'from_zip': '94025',
  'from_state': 'CA',
  'from_city': 'Menlo Park',
  'from_street': '2825 Sand Hill Rd',
  'to_country': 'US',
  'to_zip': '94303',
  'to_state': 'CA',
  'to_city': 'Palo Alto',
  'to_street': '5230 Newell Road',
  'amount': 267.9,
  'shipping': 0,
  'nexus_addresses': [{
    'country': 'US',
    'state': 'CA'
  }],
  'line_items': [{
    'id': '1',
    'quantity': 1,
    'product_tax_code': '19005',
    'unit_price': 535.8,
    'discount': 267.9
  }]
})

Example Response

<TaxJarTax {
    'taxable_amount': 0,
    'tax_source': 'destination',
    'shipping': 0,
    'rate': 0,
    'order_total_amount': 267.9,
    'jurisdictions': <TaxJarJurisdictions {
        'state': 'CA',
        'county': 'SAN MATEO',
        'country': 'US',
        'city': 'EAST PALO ALTO'
    }>,
    'has_nexus': True,
    'freight_taxable': False,
    'breakdown': <TaxJarBreakdown {
        'taxable_amount': 0,
        'tax_collectable': 0,
        'state_taxable_amount': 0,
        'state_tax_rate': 0,
        'state_tax_collectable': 0,
        'special_tax_rate': 0,
        'special_district_taxable_amount': 0,
        'special_district_tax_collectable': 0,
        'line_items': [<TaxJarBreakdownLineItem {
            'taxable_amount': 0,
            'tax_collectable': 0,
            'state_taxable_amount': 0,
            'state_sales_tax_rate': 0,
            'state_amount': 0,
            'special_tax_rate': 0,
            'special_district_taxable_amount': 0,
            'special_district_amount': 0,
            'id': '1',
            'county_taxable_amount': 0,
            'county_tax_rate': 0,
            'county_amount': 0,
            'combined_tax_rate': 0,
            'city_taxable_amount': 0,
            'city_tax_rate': 0,
            'city_amount': 0
        }>],
        'county_taxable_amount': 0,
        'county_tax_rate': 0,
        'county_tax_collectable': 0,
        'combined_tax_rate': 0,
        'county_tax_collectable': 0,
        'combined_tax_rate': 0,
        'city_taxable_amount': 0,
        'city_tax_rate': 0,
        'city_tax_collectable': 0
    }>,
    'amount_to_collect': 0
}>

List order transactions (API docs)

Lists existing order transactions created through the API.

Definition

client.list_orders

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.list_orders({
  'from_transaction_date': '2016/01/01',
  'to_transaction_date': '2017/01/01'
})

Example Response

['20', '21', '22']

Show order transaction (API docs)

Shows an existing order transaction created through the API.

Definition

client.show_order

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.show_order('123')

Example Response

<TaxJarOrder {
    'transaction_id': '123',
    'user_id': 11836,
    'transaction_date': '2015-05-14T00:00:00Z',
    'transaction_reference_id': None,
    'from_country': 'US',
    'from_zip': '93107',
    'from_state': 'CA',
    'from_city': 'SANTA BARBARA',
    'from_street': '1281 State St',
    'to_country': 'US',
    'to_zip': '90002',
    'to_state': 'CA',
    'to_city': 'LOS ANGELES',
    'to_street': '123 Palm Grove Ln',
    'amount': 17,
    'shipping': 2,
    'sales_tax': '0.95',
    'line_items': [<TaxJarLineItem {
        'id': '1',
        'quantity': 1,
        'product_identifier': '12-34243-0',
        'product_tax_code': None,
        'description': 'Heavy Widget',
        'unit_price': 15,
        'discount': 0,
        'sales_tax': 0.95
    }>]
}>

Create order transaction (API docs)

Creates a new order transaction.

Definition

client.create_order

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.create_order({
    'transaction_id': '123',
    'transaction_date': '2015/05/15',
    'from_country': 'US',
    'from_zip': '94025',
    'from_state': 'CA',
    'from_city': 'Menlo Park',
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'Palo Alto',
    'to_street': '5230 Newell Road',
    'amount': 267.9,
    'shipping': 0,
    'sales_tax': 0,
    'line_items': [{
        'id: '1',
        'quantity': 1,
        'description': 'Legal Services',
        'product_tax_code': '19005',
        'unit_price': 535.8,
        'discount': 267.9,
        'sales_tax': 0
    }]
})

Example Response

<TaxJarOrder {
    'transaction_id': '123',
    'user_id': 11836,
    'provider': 'api',
    'transaction_date': '2015-05-15T00:00:00Z',
    'transaction_reference_id': None,
    'customer_id': None,
    'exemption_type': None,
    'from_country': 'US',
    'from_zip': '94025',
    'from_state': 'CA',
    'from_city': 'MENLO PARK,
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'PALO ALTO',
    'to_street': '5230 Newell Road',
    'amount': 267.9,
    'shipping': 0,
    'sales_tax': 0,
    'line_items': [<TaxJarLineItem {
        'id': '1',
        'quantity': 1
        'product_identifier': None,
        'product_tax_code': '19005',
        'description': 'Legal Services',
        'unit_price': 535.8,
        'discount': 267.9,
        'sales_tax': 0
    }>]
}>

Update order transaction (API docs)

Updates an existing order transaction created through the API.

Definition

client.update_order

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.update_order('123', {
    'amount': 283.6,
    'shipping': 5,
    'sales_tax': 1.04,
    'line_items': [
        {
            'id': '1',
            'quantity': 1,
            'description': 'Legal Services',
            'product_tax_code': '19005',
            'unit_price': 535.8,
            'discount': 267.9,
            'sales_tax': 0
        },
        {
            'id': '2',
            'quantity': 2,
            'description': 'Hoberman Switch Pitch',
            'unit_price': 10.7,
            'discount': 10.7,
            'sales_tax': 1.04
        }
    ]
})

Example Response

<TaxJarOrder {
    'transaction_id': '123',
    'user_id': 11836,
    'provider': 'api',
    'transaction_date': '2015-05-15T00:00:00Z',
    'transaction_reference_id': None,
    'customer_id': None,
    'exemption_type': None,
    'from_country': 'US',
    'from_zip': '94025',
    'from_city': 'MENLO PARK',
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'PALO ALTO',
    'to_street': '5230 Newell Road',
    'amount': 283.6,
    'shipping': 5,
    'sales_tax': 1.04,
    'line_items': [
        <TaxJarLineItem {
            'id': '1',
            'quantity': 1,
            'product_identifier': None,
            'product_tax_code': '19005',
            'description': 'Legal Services',
            'unit_price': 535.8,
            'discount': 267.9,
            'sales_tax': 0
        }>,
        <TaxJarLineItem {
            'id': '2',
            'quantity': 2,
            'product_identifier': None,
            'product_tax_code': None,
            'description': 'Hoberman Switch Pitch',
            'unit_price': 10.7,
            'discount': 10.7,
            'sales_tax': 1.04
        }>
    ]
}>

Delete order transaction (API docs)

Deletes an existing order transaction created through the API.

Definition

client.delete_order

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.delete_order('123')

Example Response

<TaxJarOrder {
  'transaction_id': '123',
  'user_id': 11836,
  'provider': 'api',
  'transaction_date': None,
  'transaction_reference_id': None,
  'customer_id': None,
  'exemption_type': None,
  'from_country': None,
  'from_zip': None,
  'from_state': None,
  'from_city': None,
  'from_street': None,
  'to_country': None,
  'to_zip': None,
  'to_state': None
  'to_city': None,
  'to_street': None,
  'amount': None,
  'shipping': None,
  'sales_tax': None,
  'line_items': []
}>

List refund transactions (API docs)

Lists existing refund transactions created through the API.

Definition

client.list_refunds

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.list_refunds({
  'from_transaction_date': '2015/05/01',
  'to_transaction_date': '2015/05/31'
})

Example Response

['20-refund', '21-refund', '22-refund']

Show refund transaction (API docs)

Shows an existing refund transaction created through the API.

Definition

client.show_refund

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.show_refund('20-refund')

Example Response

<TaxJarRefund {
    'transaction_id': '20-refund',
    'user_id': 11836,
    'provider': 'api',
    'transaction_date': '2015-05-15T00:00:00Z',
    'transaction_reference_id': '20',
    'customer_id': None,
    'exemption_type': None,
    'from_country': 'US',
    'from_zip': '93107',
    'from_state': 'CA',
    'from_city': 'SANTA BARBARA',
    'from_street': '1218 State St',
    'to_country': 'US',
    'to_zip': '90002',
    'to_state': 'CA',
    'to_city': 'LOS ANGELES',
    'to_street': '123 Palm Grove Ln',
    'amount': -17,
    'shipping': -2,
    'sales_tax': -0.95,
    'line_items': [<TaxJarLineItem {
        'id': '1',
        'quantity': 1,
        'product_identifier': '12-34243-0',
        'product_tax_code': None,
        'description': 'Heavy Widget',
        'unit_price': -15,
        'discount': 0,
        'sales_tax': -0.95,
    }>]
}>

Create refund transaction (API docs)

Creates a new refund transaction.

Definition

client.create_refund

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.create_refund({
    'transaction_id': '123-refund',
    'transaction_reference_id': '123',
    'transaction_date': '2015-05-15',
    'from_country': 'US',
    'from_zip': '94025',
    'from_state': 'CA',
    'from_city': 'Menlo Park',
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'Palo Alto',
    'to_street': '5230 Newell Road',
    'amount': -5.35,
    'shipping': -0,
    'sales_tax': -0.52,
    'line_items': [
        {
            'id': '1',
            'quantity': 1,
            'description': 'Legal Services',
            'product_tax_code': '19005',
            'unit_price': -0,
            'discount': -0,
            'sales_tax': -0
        },
        {
            'id': '2',
            'quantity': 1,
            'description': 'Hoberman Switch Pitch',
            'unit_price': -0,
            'discount': -5.35,
            'sales_tax': -0.52
        }
    ]
})

Example Response

<TaxJarRefund {
    'transaction_id': '123-refund',
    'user_id': 11836,
    'provider': 'api',
    'transaction_date': '2015-05-15T00:00:00Z',
    'transaction_reference_id': '123',
    'customer_id': None,
    'exemption_type': None,
    'from_country': 'US',
    'from_zip': '94025',
    'from_state': 'CA',
    'from_city': 'MENLO PARK',
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'PALO ALTO',
    'to_street': '5230 Newell Road',
    'amount': -5.35,
    'shipping': -0,
    'sales_tax': -0.52,
    'line_items': [
        <TaxJarLineItem {
            'id': '1',
            'quantity': 1,
            'product_identifier': None,
            'product_tax_code': '19005',
            'description': 'Legal Services',
            'unit_price': 0,
            'discount': 0,
            'sales_tax': 0
        }>,
        <TaxJarLineItem {
            'id': '2',
            'quantity': 1,
            'product_identifier': None,
            'product_tax_code': None,
            'description': 'Hoberman Switch Pitch',
            'unit_price': 0,
            'discount': -5.35,
            'sales_tax': -0.52
        }>
    ]
}>

Update refund transaction (API docs)

Updates an existing refund transaction created through the API.

Definition

client.update_refund

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.update_refund('123-refund', {
  'transaction_reference_id': '123',
  'amount': -10.35,
  'shipping': -5,
})

Example Response

<TaxJarRefund {
    'transaction_id': '123-refund',
    'user_id': 11836,
    'provider': 'api',
    'transaction_date': '2015-05-15T00:00:00Z',
    'transaction_reference_id': '123',
    'customer_id': None,
    'exemption_type': None,
    'from_country': 'US',
    'from_zip': '94025',
    'from_state': 'CA',
    'from_city': 'MENLO PARK',
    'from_street': '2825 Sand Hill Rd',
    'to_country': 'US',
    'to_zip': '94303',
    'to_state': 'CA',
    'to_city': 'PALO ALTO',
    'to_street': '5230 Newell Road',
    'amount': -10.35,
    'shipping': -5,
    'sales_tax': 0,
    'line_items': [
        <TaxJarLineItem {
            'id': '1',
            'quantity': 1,
            'product_identifier': None,
            'product_tax_code': '19005',
            'description': 'Legal Services',
            'unit_price': 0,
            'discount': 0,
            'sales_tax': 0
        }>,
        <TaxJarLineItem {
            'id': '2',
            'quantity': 1,
            'product_identifier': None,
            'product_tax_code': None,
            'description': 'Hoberman Switch Pitch',
            'unit_price': 0,
            'discount': -5.35,
            'sales_tax': -0.52
        }>
    ]
}>

Delete refund transaction (API docs)

Deletes an existing refund transaction created through the API.

Definition

client.delete_refund

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.delete_refund('123-refund')

Example Response

<TaxJarRefund {
  'transaction_id': '123-refund',
  'user_id': 11836,
  'provider': 'api',
  'transaction_date': None,
  'transaction_reference_id': None,
  'customer_id': None,
  'exemption_type': None,
  'from_country': None,
  'from_zip': None,
  'from_state': None,
  'from_city': None,
  'from_street': None,
  'to_country': None,
  'to_zip': None,
  'to_state': None,
  'to_city': None,
  'to_street': None,
  'amount': None,
  'shipping': None,
  'sales_tax': None,
  'line_items': []
}>

List customers (API docs)

Lists existing customers created through the API.

Definition

client.list_customers

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.list_customers()

Example Response

['123', '124', '125']

Show customer (API docs)

Shows an existing customer created through the API.

Definition

client.show_customer

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.show_customer('123')

Example Response

<TaxJarCustomer {
  'customer_id': '123',
  'exemption_type': 'wholesale',
  'exempt_regions': [<TaxJarExemptRegion {
    'country': 'US',
    'state': 'FL'
  }>, <TaxJarExemptRegion {
    'country': 'US',
    'state': 'PA'
  }>],
  'name': 'Dunder Mifflin Paper Company',
  'country': 'US',
  'state': 'PA',
  'zip': '18504',
  'city': 'Scranton',
  'street': '1725 Slough Avenue'
}>

Create customer (API docs)

Creates a new customer.

Definition

client.create_customer

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.create_customer({
  'customer_id': '123',
  'exemption_type': 'wholesale',
  'name': 'Dunder Mifflin Paper Company',
  'exempt_regions': [
    {
      'country': 'US',
      'state': 'FL'
    },
    {
      'country': 'US',
      'state': 'PA'
    }
  ],
  'country': 'US',
  'state': 'PA',
  'zip': '18504',
  'city': 'Scranton',
  'street': '1725 Slough Avenue'
})

Example Response

<TaxJarCustomer {
  'customer_id': '123',
  'exemption_type': 'wholesale',
  'exempt_regions': [<TaxJarExemptRegion {
    'country': 'US',
    'state': 'FL'
  }>, <TaxJarExemptRegion {
    'country': 'US',
    'state': 'PA'
  }>],
  'name': 'Dunder Mifflin Paper Company',
  'country': 'US',
  'state': 'PA',
  'zip': '18504',
  'city': 'Scranton',
  'street': '1725 Slough Avenue'
}>

Update customer (API docs)

Updates an existing customer created through the API.

Definition

client.update_customer

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.update_customer('123', {
  'exemption_type': 'wholesale',
  'name': 'Sterling Cooper',
  'exempt_regions': [
    {
      'country': 'US',
      'state': 'NY'
    }
  ],
  'country': 'US',
  'state': 'NY',
  'zip': '10010',
  'city': 'New York',
  'street': '405 Madison Ave'
})

Example Response

<TaxJarCustomer {
  'customer_id': '123',
  'exemption_type': 'wholesale',
  'exempt_regions': [<TaxJarExemptRegion {
    'country': 'US',
    'state': 'NY'
  }>],
  'name': 'Sterling Cooper',
  'country': 'US',
  'state': 'NY',
  'zip': '10010',
  'city': 'New York',
  'street': '405 Madison Ave'
}>

Delete customer (API docs)

Deletes an existing customer created through the API.

Definition

client.delete_customer

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.delete_customer('123')

Example Response

<TaxJarCustomer {
  'customer_id': '123',
  'exemption_type': 'wholesale',
  'exempt_regions': [<TaxJarExemptRegion {
    'country': 'US',
    'state': 'FL'
  }>, <TaxJarExemptRegion {
    'country': 'US',
    'state': 'PA'
  }>],
  'name': 'Dunder Mifflin Paper Company',
  'country': 'US',
  'state': 'PA',
  'zip': '18504',
  'city': 'Scranton',
  'street': '1725 Slough Avenue'
}>

List tax rates for a location (by zip/postal code) (API docs)

Shows the sales tax rates for a given location.

Please note this method only returns the full combined rate for a given location. It does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using tax_for_order to accurately calculate sales tax for an order.

Definition

client.rates_for_location

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

# United States (ZIP+4)
rates = client.rates_for_location('90404-3370')

# United States (ZIP w/ Optional Params)
rates = client.rates_for_location('90404', {
  'city': 'SANTA MONICA',
  'country': 'US'
})

# International Examples (Requires City and Country)
rates = client.rates_for_location('V5K0A1', {
  'city': 'VANCOUVER',
  'country': 'CA'
})

rates = client.rates_for_location('00150', {
  'city': 'HELSINKI',
  'country': 'FI'
})

Example Response

<TaxJarRate {
  'city': 'SANTA MONICA',
  'zip': '90404',
  'combined_district_rate': 0.025,
  'state_rate': 0.0625,
  'city_rate': 0,
  'county': 'LOS ANGELES',
  'state': 'CA',
  'combined_rate': 0.0975,
  'county_rate': 0.01,
  'freight_taxable': False
}>

List nexus regions (API docs)

Lists existing nexus locations for a TaxJar account.

Definition

client.nexus_regions

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

nexus_regions = client.nexus_regions()

Example Response

[
  <TaxJarRegion {
    'country_code': 'US',
    'country': 'United States',
    'region_code': 'CA',
    'region': 'California'
  }>,
  <TaxJarRegion {
    'country_code': 'US',
    'country': 'United States',
    'region_code': 'NY',
    'region': 'New York'
  }>,
  <TaxJarRegion {
    'country_code': 'US',
    'country': 'United States',
    'region_code': 'WA',
    'region': 'Washington'
  }>
]

Validate an address (API docs)

Validates a customer address and returns back a collection of address matches. Address validation requires a TaxJar Plus subscription.

Definition

client.validate_address

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.validate_address({
    'country': 'US',
    'state': 'AZ',
    'zip': '85297',
    'city': 'Gilbert',
    'street': '3301 South Greenfield Rd'
})

Example Response

[
    <TaxJarAddress {
        'zip': '85297-2176',
        'street': '3301 S Greenfield Rd',
        'state': 'AZ',
        'country': 'US',
        'city': 'Gilbert'
    }>
]

Validate a VAT number (API docs)

Validates an existing VAT identification number against VIES.

Definition

client.validate

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.validate({
  'vat': 'FR40303265045'
})

Example Response

<TaxJarValidation {
  'valid': True,
  'exists': True,
  'vies_available': True,
  'vies_response': <TaxJarViesResponse {
    'country_code': 'FR',
    'vat_number': '40303265045',
    'request_date': '2016-02-10',
    'valid': True,
    'name': 'SA SODIMAS',
    'address': "11 RUE AMPERE\n26600 PONT DE L ISERE"
  }>
}>

Summarize tax rates for all regions (API docs)

Retrieve minimum and average sales tax rates by region as a backup.

This method is useful for periodically pulling down rates to use if the TaxJar API is unavailable. However, it does not support nexus determination, sourcing based on a ship from and ship to address, shipping taxability, product exemptions, customer exemptions, or sales tax holidays. We recommend using tax_for_order to accurately calculate sales tax for an order.

Definition

client.summary_rates

Example Request

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78')

client.summary_rates()

Example Response

[
  <TaxJarSummaryRate {
    'average_rate': <TaxJarAverageRate {
      'rate': 0.0827,
      'label': 'Tax'
    }>,
    'region_code': 'CA',
    'minimum_rate': <TaxJarMinimumRate {
      'rate': 0.065,
      'label': 'State Tax'
    }>,
    'country': 'US',
    'region': 'California',
    'country_code': 'US'
  }>,
  <TaxJarSummaryRate {
    'average_rate': <TaxJarAverageRate {
      'rate': 0.12,
      'label': 'PST'
    }>,
    'region_code': 'BC',
    'minimum_rate': <TaxJarMinimumRate {
      'rate': 0.05,
      'label': 'GST'
    }>,
    'country': 'Canada',
    'region': 'British Columbia',
    'country_code': 'CA'
  }>,
  <TaxJarSummaryRate {
    'average_rate': <TaxJarAverageRate {
      'rate': 0.2,
      'label': 'VAT'
    }>,
    'region_code': None,
    'minimum_rate': <TaxJarMinimumRate {
      'rate': 0.2,
      'label': 'VAT'
    }>,
    'country': 'United Kingdom',
    'region': None,
    'country_code': 'UK'
  }>
]

Custom Options

Pass additional parameters when instantiating the client for the following options:

Timeouts

Set request timeout in seconds (default is 5 seconds):

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78', options={'timeout':30})

Sandbox Environment

You can easily configure the client to use the TaxJar Sandbox:

import taxjar
client = taxjar.Client(api_key='48ceecccc8af930bd02597aec0f84a78', api_url='https://api.sandbox.taxjar.com')

For testing specific error response codes, pass the custom X-TJ-Expected-Response header:

client.set_api_config('headers', {
    'X-TJ-Expected-Response': '422'
})

Tests

A unittest test suite is available to ensure API functionality:

$ python -m unittest discover tests

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new pull request
You can’t perform that action at this time.