@agnostack/taxjar-request

Please contact agnoStack via info@agnostack.com for any questions

Usage no npm install needed!

<script type="module">
  import agnostackTaxjarRequest from 'https://cdn.skypack.dev/@agnostack/taxjar-request';
</script>

README

@agnostack/taxjar-request

🎮 Minimal TaxJar API request library for Node

Installation

yarn add @agnostack/taxjar-request # npm install @agnostack/taxjar-request

Quickstart (OAuth)

const { createClient } = require('@agnostack/taxjar-request');
// import { createClient } from '@agnostack/taxjar-request'

const taxjar = new createClient({
  api_key: '...' // taxjar API Token.
});

taxjar
  .get('categories')
  .then(console.log)
  .catch(console.error);

taxjar
  .post('taxes', {
    to_country: 'US',
    to_zip: '60056',
    to_state: 'IL',
    shipping: 10,
    amount: 290,
    nexus_addresses: [
      {
        country: 'US',
        state: 'IL'
      }
    ]
  })
  .then(console.log)
  .catch(console.error);

taxjar
  .put('transactions/orders/123', {
    amount: 17,
    shipping: 2,
    line_items: [
      {
        quantity: 1,
        product_identifier: '12-34234-0',
        unit_price: 15,
        discount: 0,
        sales_tax: 0.95
      }
    ]
  })
  .then(console.log)
  .catch(console.error);

Kitchen sink

const taxjar = new createClient({
  api_key: '...',
  api_domain: '...',
  version: 'v2',
  headers: {
    // ...
  }
});

Custom headers per request

The API provides you the ability to send various request headers that change the way data is stored or retrieved.

By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type header as an additional argument to get, post, put and delete.

Note: If you add the Content-Type custom header to post, put or delete you will need to encode data yourself.

const taxjar = new createClient({
  api_key: '...'
});

const headers = {
  'X-My-Header': 'custom'
};

taxjar
  .get('products/types', headers)
  .then(console.log)
  .catch(console.error);

Contact Adam Grohs @ agnoStack for any questions.