> ## Documentation Index
> Fetch the complete documentation index at: https://docs.driv.ly/llms.txt
> Use this file to discover all available pages before exploring further.

# Taxes & Fees

> Get started with Taxes & Fees API with our step-by-step guide.

export const StoryBoard = ({children}) => <div className="p-6 bg-gray-100/50 dark:bg-gray-800/25 rounded">
    <p className="text-base py-2 leading-6">{children}</p>
  </div>;

## Overview

The Taxes & Fees API provides detailed information on the taxes, fees, and loan payments associated with purchasing a vehicle. By providing the `VIN`, `ZIP Code`, and `Credit Score`, you can receive a comprehensive breakdown of the costs involved in the sale. This information is crucial for customers to make informed decisions about their purchase.

In this guide, we'll follow an example scenario:

<StoryBoard>
  Sara has decided to purchase a used Porsche 911. Given her budget it is unclear to her how much
  she will actually pay after all of the taxes, fees, registration, and loan payments. It is crucial
  for her to understand the full scope of potential costs.
</StoryBoard>

To complete this scenario, you will need to:

1. Make an API call
2. Process the response
3. Present the results to Sara.

## Walkthrough

<Steps>
  <Step title="Make the API Call">
    Sara has a credit score of `720` and is interested in a used car with VIN `WP0AF2A99KS165242` and lives in ZIP Code `33132`.

    <CodeGroup>
      ```javascript taxes.js theme={null}
      const vin = 'WP0AF2A99KS165242'
      const url = new URL(`https://taxes.vin/WP0AF2A99KS165242`)

      const params = {
        zip: '33132',
        creditScore: '720',
      }

      url.search = new URLSearchParams(params).toString()

      const headers = {
        Authorization: 'Bearer YOUR_API_KEY',
      }

      fetch(url, { headers }).then((r) => r.json())
      ```

      ```python taxes.py theme={null}

      import requests

      vin = "WP0AF2A99KS165242"

      url = f"https://taxes.vin/{vin}" #

      params = {
      "zip": "33132",
      "creditScore": "720",
      }

      headers = { "Authorization": "Bearer YOUR_API_KEY" }

      response = requests.get(url, params=params, headers=headers)
      data = response.json()

      ```

      ```python taxes.py (async) theme={null}

      import aiohttp

      vin = "WP0AF2A99KS165242"

      url = f"https://taxes.vin/{vin}"

      params = {
      "zip": "33132",
      "creditScore": "720",
      }

      headers = {
      "Authorization": "Bearer YOUR_API_KEY"
      }

      async def main():
      async with aiohttp.ClientSession() as session:
      async with session.get(url, params=params, headers=headers) as response:
      data = await response.json()
      print(data)

      asyncio.run(main()) # Run the event loop using our main function

      ```
    </CodeGroup>
  </Step>

  <Step title="Process the Response">
    After receiving the response, extract the necessary information to present the taxes, fees, and loan payment calculations to Sara.

    <CodeGroup>
      ```javascript taxes.js theme={null}
      const taxes = data.payments.taxes
      const fees = data.payments.fees
      const loanAmount = data.payments.loanAmount
      const monthlyPayment = data.payments.loanMonthlyPayment
      const monthlyPaymentWithTaxes = data.payments.loanMonthlyPaymentWithTaxes
      ```

      ```python taxes.py theme={null}

      taxes = data["payments"]["taxes"]
      fees = data["payments"]["fees"]
      loan_amount = data["payments"]["loanAmount"]
      monthly_payment = data["payments"]["loanMonthlyPayment"]
      monthly_payment_with_taxes = data["payments"]["loanMonthlyPaymentWithTaxes"]

      ```
    </CodeGroup>
  </Step>

  <Step title="Present the Results">
    Present the taxes, fees, and loan payment calculations to Sara. She can now make an informed decision about the potential costs and loan payments for the vehicle.

    <CodeGroup>
      ```javascript taxes.js theme={null}
      console.log('Loan Amount:', loanAmount)
      console.log('Monthly Payment (without taxes):', monthlyPayment)
      console.log('Monthly Payment (with taxes):', monthlyPaymentWithTaxes)

      console.log('\nTaxes:')
      for (const [key, value] of Object.entries(taxes)) {
        console.log(' ', key, ': $', value)
      }

      console.log('\nFees:')
      for (const [key, value] of Object.entries(fees)) {
        if (key === 'dmvFeesItemized') {
          console.log(' DMV Fees Itemized:')
          for (const dmvFee of value) {
            console.log(' ', dmvFee.name, ': $', dmvFee.value)
          }
        } else {
          console.log(' ', key, ': $', value)
        }
      }
      ```

      ```python taxes.py theme={null}

      print(f"Loan Amount: ${loan_amount:.2f}")
      print(f"Monthly Payment (without taxes): ${monthly_payment:.2f}")
      print(f"Monthly Payment (with taxes): ${monthly_payment_with_taxes:.2f}")

      print("\nTaxes:")
      for key, value in taxes.items():
      key_formatted = key.replace("SalesTax", " Sales Tax")
      print(f" {key_formatted}: ${value:.2f}")
      key_formatted = key.replace("SalesTax", " Sales Tax")
      print(f" {key_formatted}: ${value:.2f}")

      print("\nFees:")
      for key, value in fees.items():
      if key != "dmvFeesItemized":
      print(f" {key}: ${value:.2f}")
      if key != "dmvFeesItemized":
      print(f" {key}: ${value:.2f}")

          else:
              print("  DMV Fees Itemized:")
              for dmv_fee in value:
                  print(f"    {dmv_fee['name']}: ${dmv_fee['value']}")

      ```
    </CodeGroup>
  </Step>

  <Step title="Review the results">
    The output will provide Sara with a detailed breakdown of the costs, taxes, and fees associated with the automotive sale.

    <CodeGroup>
      ```json JSON (output) theme={null}
      {
        "loanAmount": "$29200.92",
        "monthlyPaymentWithoutTaxes": "$430.36",
        "monthlyPaymentWithTaxes": "$483.53",
        "taxes": {
          "citySalesTax": "$194.93",
          "combinedSalesTax": "$2663.98",
          "countySalesTax": "$64.97",
          "districtSalesTax": "$844.68",
          "stateSalesTax": "$1559.40",
          "gasGuzzlerTax": "$0.00"
        },
        "fees": {
          "titleFee": "$23",
          "registrationFee": "$65",
          "dmvFee": "$338.94",
          "combinedFees": "$546.94",
          "docFee": "$120"
        },
        "dmvFeesItemized": {
          "airQualityFee": "$6",
          "alternativeFuelTechnologyFee": "$3",
          "autoTheftDeterrenceDuiFee": "$2",
          "fingerprintIdFee": "$1",
          "highwayPatrolFee": "$29",
          "reflectorizedLicensePlateFee": "$1",
          "serviceAuthorityForFreewayEmergenciesFee": "$1",
          "smogAbatementFee": "$12",
          "transferFee": "$15",
          "transportationImprovementFee": "$100",
          "vehicleLicenseFee": "$168.94"
        }
      }
      ```

      ```python taxes.py (output) theme={null}

      Loan Amount: $29200.92
      Monthly Payment (without taxes): $430.36
      Monthly Payment (with taxes): $483.53

      Taxes:
      citySalesTax: $194.93
      combinedSalesTax: $2663.98
      countySalesTax: $64.97
      districtSalesTax: $844.68
      stateSalesTax: $1559.40
      gasGuzzlerTax: $0.00

      Fees:
      titleFee: $23
      registrationFee: $65
      dmvFee: $338.94
      combinedFees: $546.94
      docFee: $120
      DMV Fees Itemized:
      Air Quality Fee: $6
      Alternative Fuel/Technology Fee: $3
      Auto theft deterrence/DUI fee: $2
      Fingerprint ID Fee: $1
      Highway Patrol Fee: $29
      Reflectorized license plate fee: $1
      Service Authority for Freeway Emergencies fee: $1
      Smog Abatement Fee: $12
      Transfer Fee: $15
      Transportation Improvement Fee: $100
      Vehicle License Fee: $168.94

      ```
    </CodeGroup>

    <Warning>
      While the data provided by the API is as accurate as we can make it, it should be reviewed before
      making any decisions that can impact sales, taxes, or other financial decisions.
    </Warning>
  </Step>
</Steps>

## Summary

You have successfully implemented the Taxes & Fees API in your application, giving Sara a clear understanding of the costs and loan payments associated with purchasing a used Porsche 911. With this information, she can confidently proceed with the purchase.

***

## Next Steps

Review the API reference for the Taxes & Fees API

<Card title="Reference – Taxes & Fees" icon="link" href="/data/reference/title-&-registration/get-taxes-&-fees">
  Explore the Taxes & Fees API endpoint and parameters.
</Card>
