The Water Quality Data Portal (WQP) provides an easy way to access data stored in various large water quality databases through form-based queries as well as through standalone web services. The form interface and the web services offer equivalent input parameters and output formats. Submit a web service request to bypass the WQP form interface. For more information on the WQP input parameters and data retrievals, see the User Guide.


HTTPS only on the Water Quality Portal

USGS-hosted websites, which includes the Water Quality Portal, will be switching to the secure and encrypted HTTPS protocol during December, 2016.  For most users, the changes won’t be noticeable other than a visual change in web browsers indicating a private connection.  But users who write or maintain software that uses USGS web services could be impacted and should read on for details.

After this switch, requests for USGS web resources using the HTTP protocol will receive one of the 3xx Redirection HTTP status codes indicating an equivalent HTTPS URL.  Software that receives this response likely falls into one of these categories:

  1.  No change required.  Many underlying software libraries transparently process redirects and switch to the HTTPS protocol with no required programming changes.  The additional redirect will reduce performance slightly, however, so an optimization would be changing all USGS URLs to HTTPS.
  2.  Does not follow redirects automatically, change required.  Some software libraries may report redirects as errors instead of following them.  For this, change all USGS URLs to HTTPS, or alter the software to follow the redirect response.
  3.  Supports HTTPS only with additional configuration, change required.  Underlying software libraries might require additional configuration, installed modules, or invocation options to support HTTPS.
  4.  Does not support HTTPS, potentially major change required.  Some software libraries, particularly older ones, might not be capable of supporting HTTPS.  For this, alternate libraries can be sought or the software can be ported to another language or platform that supports HTTPS.

Software developers may test a software library’s redirect and HTTPS support by retrieving an arbitrary web resource, including this URL that generates a 3xx redirect to an HTTPS URL: .   The Water Quality Portal's Web Services already support HTTPS, and you can make the change to you scripts today.  If you have issues, please contact us at

This conversion is part of a federal-government-wide effort observing that “the American people expect government websites to be secure and their interactions with those websites to be private.”  


Using a web service client

The Water Quality Portal has several language-specific web service tools that may make it easier to use the WQP services if you are already using a scripting language, as the application will do the heavy lifting to get the data into a familiar data format.

Submitting a Web Services Request

The WQP web services may be queried using a RESTlike (REpresentational State Transfer) technique. This method will retrieve the same data as the WQP form when the same retrieval parameters are specified. The basic building blocks for querying the services are outlined in the following series of tables. Most non-alphanumeric characters (such as punctuation) must be "url-encoded", (for example: space is "%20").

Parameters must be appended to the base Uniform Resource Locator (URL) for the RESTlike WQP web services. The base URL is constructed differently depending on the type of information being requested. There are two options - one base URL for downloading sites and one base URL for downloading results:

  • Base URL for downloading sites --
  • Base URL for downloading results --
  • Base URL for downloading activity data –
  • Base URL for downloading activitymetric data –

Construct a RESTlike web service query by concatenating the base URL with the desired parameters and arguments (Table 1).  At least one parameter-argument pair must be specified. Separate multiple parameter-argument pairs with an ampersand ("&"). Unneeded web service parameters may be omitted. If no mime type is specified, the retrieval will default to WQX-XML format. Station and Result retrieval data elements are output in a consistent format and nomenclature. See the User Guide for a list of elements included in the station and result retrievals.

Table 1. URL-encoded retrieval parameters and arguments for WQP web services [parameter names are insensitive only to the leading capital letter].

REST parameterArgumentDiscussion
bBoxWestern-most longitude, Southern-most latitude, Eastern-most longitude, and Northern-most longitude
separated by commas, expressed in decimal degrees, WGS84, and longitudes west of Greenwich are negative.
(Example: bBox=-92.8,44.2,-88.9,46.0)
These four arguments are used together to form a quadrant of the Earth's surface for locating data-collection stations. Many stations outside the continental US do not have latitude and longitude referenced to WGS84 and therefore cannot be found using these parameters. Other stations are not associated with latitude and longitude due to Homeland Security concerns.
latLatitude for radial search, expressed in decimal degrees,WGS84These three arguments are used together to form a circle on the Earth's surface for locating data-collection stations. Many stations outside the continental US do not have latitude and longitude referenced to WGS84 and therefore cannot be found using these parameters.
longLongitude for radial search, expressed in decimal degrees, WGS84
withinDistance for radial search, expressed in decimal miles
countrycodeTwo-character Federal Information Processing Standard (FIPS) country code. (see domain service for available codes)FIPS country codes were established by the National Institute of Standards, publication 5-2.
statecodeTwo-character Federal Information Processing Standard (FIPS) country code, followed by a URL-encoded colon ("%3A"), followed by a two-digit FIPS state code. (seedomain service for available codes)FIPS state codes were established by the National Institute of Standards, publication 5-2.
countycodeTwo-character Federal Information Processing Standard (FIPS) country code, followed by a URL-encoded colon ("%3A"), followed by a two-digit FIPS state code, followed by a URL-encoded colon ("%3A"), followed by a three-digit FIPS county code. (see domain service for available codes)FIPS county codes were established by the National Institute of Standards, publication 5-2.
siteTypeOne or more case-sensitive site types, separated by semicolons. (see domain service for available site types)Restrict retrieval to stations with specified site type (location in the hydrologic cycle). The MonitoringLocationTypeName for individual records may provide more detailed information about the type of individual stations.
organizationFor USGS organization IDs, append an upper-case postal-service state abbreviation to "USGS-" to identify the USGS office managing the data collection station records. However, a few US states are serviced by one USGS office.
  • USGS-MA = Massachusetts and Rhode Island
  • USGS-MD = Maryland, Delaware, and the District of Columbia
  • USGS-PR = Caribbean Islands
  • USGS-HI = Pacific Islands
(see domain service for available organization IDs)
USGS offices sometimes provide data for stations outside the political boundaries associated with the office's organization code. Use the statecode or countycode arguments to search for stations located within those political boundaries.
siteidConcatenate an agency code, a hyphen ("-"), and a site-identification number.Each data collection station is assigned a unique site-identification number. Other agencies often use different site identification numbers for the same stations.
hucOne or more eight-digit hydrologic units, delimited by semicolons.Hydrologic unit codes identify surface watersheds. The lists and maps of hydrologic units are available from USGS.
sampleMediaOne or more case-sensitive sample media, separated by semicolons. (see domain service for available sample media)Sample media are broad general classes, and may be subdivided in the retrieved data. Examine the data elements ActivityMediaName, ActivityMediaSubdivisionName, and ResultSampleFractionText for more detailed information.
characteristicTypeOne or more case-sensitive characteristic types (groupings) separated by semicolons. (see domain service for available characteristic types)These groups will be expanded as part of the ongoing collaboration between USGS and USEPA.
characteristicNameOne or more case-sensitive characteristic names, separated by semicolons. (see domain service for available characteristic names)Characteristic names identify different types of environmental measurements. The names are derived from the USEPA Substance Registry System (SRS). USGS uses parameter codes for the same purpose and has associated most parameters to SRS names.
pCodeOne or more five-digit USGS parameter codes, separated by semicolons.
activityIdOne or more case-sensitive activity IDs, separated by semicolons.Designator that uniquely identifies an activity within an organization.
startDateLoDate of earliest desired data-collection activity, expressed as MM-DD-YYYYThese two parameters, used together or individually, restrict the retrieval to data-collection activities within a range of dates.
startDateHiDate of last desired data-collection activity, expressed as MM-DD-YYYY
mimeTypexmlOutput format is XML compatible with WQX-Outbound schema. This is the default format, and if a mimeType is not specified, the data will be in XML format
xlsxOutput format is xlsx compatible with MS-Excel 2007 and greater
csvOutput format is comma-separated columns
tsv|tabOutput format is tab-separated columns
geojsonOutput format is a narrow
kmlOutput format is KML compatible with Google Earth. This option is not available for the results service.
kmzOutput format is kmz, a compressed form of kml compatible with Google Earth. This option is not available for the results service.
ZipyesInclude the parameter to stream compressed data. Compression often greatly increases throughput, thus expediting the request. Kml files will be returned in the kml-specific zip format, .kmz.
providersSTORET|NWIS|STEWARDS (also see domain service for available codes)By default, requests are submitted to all the data providers. However, a particular provider may be specified using this parameter.
sortedyes|noBy default, tabular data are sorted by organization, monitoringLocationID, and (for results) activityID. However, sorting increases response time significantly, sometimes by orders of magnitude. If you are doing your own sorting after download, set sorted=no. For large downloads (over 5 million rows) sorting is disabled by default to ensure reasonable response times. XML requests are always sorted to accommodate the WQX data schema
dataProfilebiologicalOnly affects results endpoint at this time. The biological dataProfile returns an extended set of columns that further describe biological data
command.avoidSTORET|NWISDeprecated! By default, requests are submitted to all the data providers. This deprecated command is replaced by "providers." To support legacy applications, command.avoid=NWIS maps to providers=STORET, and command.avoid=STORET maps to providers=NWIS
mimeTypexlsDeprecated in favor of xlsx. The xls format had a limit of 63,000 rows, not practical for most wqp downloads.

Web Service Request Examples

All examples include <remove this string> to avoid spurious web service calls from web crawler robots

The following example REST web service request retrieves sites from Oklahoma County, Oklahoma, where Atrazine was measured in XML format, zipped.

https://www.water<remove this string>

This REST web service request retrieves contained within a bounding box where Caffeine was measured in KML format, zipped.

https://www.water<remove this string>,44.2,-88.9,46.0&zip=yes

Continuing from above, this REST web service request retrieves the Caffeine sample results from sites contained within a bounding box and collected on, or after, 10-01-2006 in MS-Excel format (zipped).

https://www.water<remove this string>,44.2,-88.9,46.0&startDateLo=10-01-2006&mimeType=xlsx&zip=yes

Web service Request Pre-Validation

A REST web service request may not be valid for all data providers. A web service user may perform a quick validation before submitting a request to ensure that all parameters are valid before making an expensive request for actual data. For example, the WQP mini-portal form does this before an actual data submission, and pops up a prompt to the user if problems are found.

A REST web service validation service for sites and results requests are invoked by using the exact same RESTlike URL as an actual request but using a HTTP HEAD method rather than the usual GET or POST. See the W3C specification RFC 2616 Section 9 for an explanation of HTTP methods. The exact way to invoke a URL via a HEAD request depends on your programming language, but an example is provided below for JavaScript:

function makeRequest(url) {
  	var http = new XMLHttpRequest();'HEAD', url, false);
  	var warningHeader = http.getResponseHeader("Warning");

Another option is using a command line. For example, a HEAD request can be issued as:

curl -I 'https://www.water<remove this string>,44.2,-88.9,46.0&startDateLo=10-01-2011 &mimeType=csv&characteristicName=Dissolved%20oxygen%20(DO)' 

If there are any problems, they are returned in the response via the warning header(s). See RFC 2616 Section 14 for the format of the warning header. 

NOTE: The same warning header(s) and count headers are returned on the GET request as well, so it is important to issue the command with 'debug' or 'verbose' diagnostic option turned on, and then inspect the header to ensure the service is performing as expected. For example:

wget -d -O - 'https://www.water<remove this string>,44.2,-88.9,46.0 &startDateLo=10-01-2011&mimeType=csv&characteristicName=Dissolved%20oxygen%20(DO)'
curl -v  'https://www.water<remove this string>,44.2,-88.9,46.0 &startDateLo=10-01-2011&mimeType=csv&characteristicName=Dissolved%20oxygen%20(DO)'

Either statement returns the following (indicating no NWIS results are returned):

Total-Site-Count: 170
STORET-Site-Count: 170
Warning: 299 NWIS "[characteristicName]The value of characteristicName=Dissolved 
                     oxygen (DO) is not in the list of enumerated values"

Using OGC Services to map Water Quality Portal sites based on Water Quality Portal Parameters

The Water Quality Portal has an endpoint for generating OGC-Compliant Geospatial web services.  At this time, we support Web Mapping Service (WMS) version 1.1.1 and Web Feature Service (WFS) version 1.1.1.  The service is a customized version of the WMS and WFS services provided by Geoserver.  The Geoserver WMS Reference and WFS Reference will be helpful for getting started.  The base URL for both the WMS and WFS Services is{wms|wfs}

You will want to use web mapping tools, such as Leaflet or Openlayers to be able to easily connect to these web map services.  GIS tools such as ARC GIS and QGIS should also be able to connect to these web maps services, though they have not been tested.

In a nutshell, both WFS and WMS services require an additional parameter called "SearchParams."  SearchParams is a URL-encoded version of the Water Quality Portal search parameters that you pass along with the rest of the standard OGC query parameters.  The service supports calls that return up to up to 250,000 sites.  Calls that return large numbers of sites will take longer to load for the first time, as a cache is populated.  After that, the service should respond to requests with response rates in the tens to hundreds of milliseconds.  The Cache is cleared after new data is loaded to the portal, generally once a day at night.

At this time, we support WMS GetMap, WMS GetFeatureInfo, and WMS GetLegendGraphic.

WMS Getmap 
  • For detailed information on constructing a WMS getmap request, please refer to the GetMap documentation at the Geoserver site.  

  • Here is an example GetMap Request for stream sites that have samples for atrazine.  the













Looking Up Domain Values through Web Services

The domains for retrieval parameter arguments may vary over time, as new data are added. The domain of values for the parameter arguments may be retrieved with a REST query. Use the domain-value base URL concatenated with the parameter name and arguments as shown in Table 2.  
Base URL for looking up domain values --{endpointName}?{parameter}
There needs to be at least one argument in the web service call. If you want all domain values, you can just specify the mimetype: e.g. mimeType=json
Table 2. -- Domain values web service parameters and arguments
REST parameter
Common parameters for all domain values web services
returns either XML or json. Default is xml
page number (1,2 etc)
allows for results to be paginated (especially useful for endpoints with many valid responses, allows for infinite scrolling). Use along with pagesize
e.g. 20
number of results to return per page
e.g. ph
text to match to endpoint results. This is straight string matching. When the text parameter is used, the results are returned sorted by length
Endpoints with unique query parameters in addition to common query parameters
FIPS country codes
A FIPS country code (e.g. US)
FIPS state codes. A FIPS country code argument is appended so that the URL ends as /statecode?countrycode=US
A FIPS statecode (e.g. statecode=US:01;US:04)
FIPS county codes. A FIPS statecode argument is appended so that the URL ends as /countycode?statecode=US:01;US:04;US:04
Available site types
Available organization IDs
Sample media
Characteristic types (groups)
Characteristic names. A good choice for using paginated results so that hundreds of results are not returned.
The names of the Data Sources for the Water Quality Portal