home home Find taxes & rates home Retail sales tax  home Destination-Based Sales Tax home WA Sales Tax Rate Latitude/Longitude Lookup URL Interface WA Sales Tax Rate Latitude/Longitude Lookup URL Interface

 

This URL interface provides direct access to the Washington Department of Revenue's latitude and longitude based tax rate lookup technology platform. Using the URL interface we provide, you can access sales and use tax data by providing a latitude and longitude that reside somewhere in Washington state. The following information is the technical specifications for accessing the URL interface.

 

1.  The tax rate lookup URL interface is designed to return the current sales tax rates for a given latitude and longitude. It is designed for use by AJAX (XMLHttpRequest, Msxml2.XMLHTTP), libcurl, wget, HttpRequest, or similar HTTP protocol clients. Requests can be made to return either XML or plain text responses.

2.  The URL should be formatted as follows:
http://<servername>/LatLongRates.aspx?output=<format>&latitude=<latitude>&longitude=<longitude>

Where
<servername>   ==> Host name where the service is running.
<format>       ==> Either "xml" or "text"
<latitude>     ==> A latitude between 45.0 ~ 49.005
<longitude>    ==> A longitude between -125.0 ~ -116.0

Examples
http://dor.wa.gov/LatLongRates.aspx?output=xml&latitude=47.985&longitude=-122.596
http://dor.wa.gov/LatLongRates.aspx?output=text&latitude=46.0&longitude=-122
http://dor.wa.gov/LatLongRates.aspx?output=xml&latitude=47.2&longitude=-121.056
3.  HTTP Status Codes

The service will normally return HTTP 200 OK. If an uncaught internal error occurs, it may return an HTTP 500 internal server error. Generally, the ResultCode is the most reliable means of determining the cause of errors.

4.  Result Codes

A result code will be returned for both XML and text response formats.  The codes are defined as:

  0:  No errors occurred (operation completed successfully) 
  1:  Given latitude/longitude outside WA state boundary 
  2:  Internal error occurred
  3:  Given latitude/longitude are in an invalid format 
  4:  Required parameters are missing.
5.  Plain Text Response Format

If the format requested is "text", a simple tab delimited text string will be returned with the following format.

LocationCode=<location code>   Rate=<rate>   ResultCode=<result code>
 

Where <location code> ==> The four digit DOR location code. <rate>          ==> The total state and local tax rate. <result code>   ==> The result code described above.

Example LocationCode=3406 Rate=0.084 ResultCode=0
6.  XML Response Format

Example Response <?xml version="1.0" encoding="UTF-8" ?> <response      loccode="1900"      localrate="0.015"      rate="0.080"      code="0"      errormsg="">        <rate            name=""            county="Kittitas"            code="1900"            staterate="0.065"            localrate="0.019"/>      </response> Tags response   ==> The response package. rate       ==> The tax rate information. <response> Attributes loccode    ==> The four digit DOR location code. localrate  ==> The local tax rate. rate       ==> The combined local and state tax rate. code       ==> The result code as defined above. errormsg   ==> A description of the error that occurred. <rate> Attributes name       ==> DOR location code name (usually the city). county     ==> The county this location code resides in. code       ==> The four digit DOR location code. staterate  ==> The state portion of the sales tax rate. localrate  ==> The local portion of the sales tax rate.

7.  C# Example Call
double latitude = 47.985;

double longitude = -122.596;

WebClient wc = new WebClient();

wc.Headers.Add("User-Agent", 
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705)");

string urlPrefix = "http://dor.wa.gov/LatLongRates.aspx?output=xml";

string completeUri = urlPrefix + "&latitude=" +
                     HttpUtility.UrlEncode(latitude.ToString()) +
                     "&longitude=" + 
                     HttpUtility.UrlEncode(longitude.ToString());
                     
StreamReader reader = new StreamReader(wc.OpenRead(completeUri));

string xml = reader.ReadToEnd();

reader.Close();

// parse the XML response here...

// ...