Instantaneous Values Service Details

You can use this service to retrieve recent and historical values for streamflow as well as data for other regular time-series parameters served by the USGS.

Instantaneous Values Service

You can use this service to retrieve recent and historical values for streamflow as well as data for other regular time-series parameters served by the USGS. This service provides these USGS water data in Extensible Markup Language (XML), Javascript Object Notation (JSON) and the legacy RDB (tab-delimited) format currently available from the USGS Water Data for the Nation site . More media types will follow.

How the service works

  • This is a REST-friendly service, which means it is URL accessible and can be run from a browser
  • The service can return recent water readings for one or more sites in one request
  • Data from October 1, 2007 to the present can be returned with one request. However, certain operational data that is not quality assured (this typically includes temperature and precipitation) is limited to 120 days or less by the local USGS water science center responsible for the data.

With thousands of sites monitored across the nation, and with the majority of these sites having measurements for more than one type of data, the amount of data available is very large. No one user is allowed to download all of the data with a single call. The service has consequently been designed and engineered to facilitate common mass queries, defaulting to returning a narrower set of data. You are encouraged to make your queries efficient too, mindful that many others need access to the data. Always specify the minimum amount of data you need in your request, using built in filters and date ranges to the maximum extent possible.

Testing the service

Probably the best way to learn how to use the service is to try it out!

The USGS provides this tool that allows you to generate syntactically correct calls to the service. You can even run the query live in your browser. The XML output may look somewhat strange if you are new to XML. When you have perfected your query you can copy and paste the URL into your application to get the precise data you need.

Test the service now

Enabling gzip compression

Typically data is downloaded as plain text via Hypertext Transfer Protocol (HTTP). However, gzip compression is supported by this service. Use of gzip compression may markedly speed up acquisition of data, particularly on large queries. It also is a more efficient use of USGS servers, so we appreciate when you are thoughtful enough to use it. Whether you can receive the data in gzip compressed formats depends on the capabilities of your client. Web browsers support gzip compression natively, but most regular users will use specialized utility programs like wget and curl to acquire data. If you can handle gzip compression, please place the following string into your HTTP request headers: Accept-Encoding: gzip, compress

curl and wget are typically used to download data. They may be configured to use gzip compression if the server will accept it. You may also explicitly have to tell it to use gzip compression. If so these tips should work:

  • curl: try adding the argument: -H 'Accept-Encoding: gzip,deflate'
  • wget: try adding the argument: --header="Accept-Encoding: gzip"

gzip files are typically returned as a file with a .gz file suffix unless you instruct your program to uncompress it. See the gzip man page for instructions on uncompressing .gz files.

Output

Please note that most recent data are marked provisional, so these data should be interpreted with caution as it is possible (although unlikely) to be incorrect. See the USGS Provisional Data Disclaimer page for more information.

Error codes

Since this system uses Hypertext Transfer Protocol (HTTP), any application errors are reported in the HTTP headers. This means that when writing applications, it is important to first examine the HTTP status code that is returned in the HTTP response. The application server will return the error code along with a message describing the error in the event there is a problem. Programmers should always check the HTTP response code and if not a 200 handle the response as an exception. Among the status codes you may see:

HTTP Error CodeHTTP Error Code DescriptionExplanation
200OKThe request was successfully executed and some data should have been returned.
304Not_ModifiedThis indicates your request was redirected using the proper URL. This may occur if the "path" of your URL is not fully qualified. Ideally a / is placed before the ? in the URL. Adding in this slash may make this go away. However, the request should still be processed. If this becomes annoying, you may also be able to tell your client program to automatically follow redirects.
400Bad_RequestThis often occurs if the URL arguments are inconsistent. An accompanying error should describe why the request was bad. Reasons include:
  • Using startDT and endDT with the period argument.
  • Mixing startDt and endDt arguments where startDt includes a time zone and endDt does not
403Access_ForbiddenThis should only occur if for some reason the USGS has blocked your Internet Protocol (IP) address from using the service. This can happen if we believe that your use of the service is so excessive that it is seriously impacting others using the service. To get unblocked, send us the URL you are using along with your client's IP using this form. We may require changes to your query and frequency of use in order to give you access to the service again.
404Not_FoundReturned if and only if the query expresses a combination of elements where data do not exist. For multi-site queries, if any data are found, it is returned for those site/parameters/date ranges where there are data. Conditions that would return a 404 Not Found include:
  • The site number(s) are invalid
  • The site number(s) exists but they do not serve time-series data
  • The site number(s) are valid but the requested parameter(s) are not served for these sites
  • No values exist for the requested date range. For example, a gage might be down for a period of time due to storm damage when it would normally have data.
500Internal_Server_ErrorIf you see this, it means there is a problem with the web service itself. It usually means the application server is down unexpectedly. This could be caused by a host of conditions but changing your query will not solve this problem. The application support team has to fix it. Most of these errors are quickly detected and the support team is notified if they occur.
503Service_UnavailableThe server is currently unable to handle the request due to a temporary overloading or maintenance of the server. The implication is that this is a temporary condition which will be alleviated after some delay.

Using the Web Service with Adobe Flex or the Flex API

Adobe Flex requires our server have a crossdomain.xml file indicating those domains that can access our web service using Adobe Flex. We are adding these on a case by case basis. If you need to access the service using Adobe Flex or the Flex API, please contact us using this form and indicate the domain of the server that will access the service.

CORS Support

This service supports the Cross-Origin Resource Sharing (CORS) specification. CORS permits browser-based asynchronous access to the service even though content originates from a server different than the one serving the web page. Otherwise the browser’s security controls would not allow content to come from USGS servers. Most, but not all browsers, support CORS. Some frameworks, like jQuery through the Ajax crossDomain setting, support CORS automatically.

URL Format

The URL must always be in this format:

https://waterservices.usgs.gov/nwis/iv/?<arguments>

where <arguments> are one or more HTTP GET parameter names and values based on the information below.

Specifying the URL Arguments

You specify the content that goes in <arguments>.

  • Each URL argument name is followed by an equal sign followed by one or more values for that argument. Where multiple values are allowed for the same argument, you can separate values with commas.
  • Arguments are separated by ampersands (&)
  • The order of the arguments in the URL does not matter.
  • If a URL argument name does not match one of the names below, it is ignored.

Here is an example of a valid URL that should return data:

https://waterservices.usgs.gov/nwis/iv/?sites=01646500&parameterCd=00060,00065

URL argument names and argument values can be in upper, lower or mixed case. They will all be handled correctly. All of the following will yield the same result:

Argument conventions

The following conventions are used below to document argument values:

arg1=[ a {,x | ,y} | b | c,d,...]

  • square brackets [] are used to show a set of possible choices, with | delineating exclusive choices. You must select one and only one of these choices.
  • curved brackets {} are used to show optional elements. They also may be delineated with | indicating exclusive choices. If used, you may select one and only one of these choices.
  • ... indicates more than item may be specified if items are delineated by commas. Note the limitation on the maximum number of argument values allowed below.

In the above example, these would be the allowed legal values:

  • arg1=a
  • arg1=a,x
  • arg1=a,y
  • arg1=b
  • arg1=c
  • arg1=c,d,e,f

Major Filters

Single Site Queries

Want to only query one site? Use site (or sites) as your major filter, and put only one site number in the list! Example:

https://waterservices.usgs.gov/nwis/iv/?site=01646500

Multiple Site Queries

  • Every query requires a major filter. Pick the major filter (sites, stateCd, huc, bBox, counties) that best retrieves the data for the sites that you are interested in.
  • You can have only one major filter per query. If you specify more than one major filter, you will get an error.

Major Filter

(select one of the following)

MeaningMinimum Number of Argument ValuesMaximum Number of Argument ValuesExamples
sites (aliases: site, location)A list of site numbers. You can specify up to 100 sites. Sites are comma separated. Sites may be prefixed with an optional agency code followed by a colon. If you don't know the site numbers you need, you can find relevant sites with the NWIS Mapper or on the USGS Water Data for the Nation site.1100&site=01646500
&sites=USGS:01646500
&sites=01646500,06306300
stateCd (alias: stateCds)
U.S. postal service (2-digit) state code. USPS List of State Codes.11&stateCd=NY
huc
(alias: hucs)
A list of hydrologic unit codes (HUC) or watersheds. Only 1 major HUC can be specified per request. A major HUC has two digits. Minor HUCs must be eight digits in length. List of HUCs.110&huc=01,02070010
bBoxA contiguous range of decimal latitude and longitude, starting with the west longitude, then the south latitude, then the east longitude, and then the north latitude with each value separated by a comma. The product of the range of latitude and longitude cannot exceed 25 degrees. Whole or decimal degrees must be specified, up to six digits of precision. Minutes and seconds are not allowed. Remember: western longitude (which includes almost all of the United States) is specified in negative degrees. Caution: many sites outside the continental US do not have latitude and longitude referenced to NAD83 and therefore can not be found using these arguments. Certain sites are not associated with latitude and longitude due to homeland security concerns and cannot be found using this filter.11&bBox=-83,36.5,-81,38.5
countyCd
(alias: countyCds)
A list of county numbers, in a 5 digit numeric format. The first two digits of a county's code are the FIPS State Code. List of county codes. Some updates were made to the FIPS code standards in 2021. NIST has provided replacement standards.120&countyCd=51059,51061

Outputs

Format

URL Argument Nameformat
Description

Used to specify the output format of the data returned.

  • rdb is a self-describing tab-delimited format used widely by the USGS, documented in a PDF file here (Adobe Acrobat Reader)
  • json is Javascript Object Notation. WaterML 1.1 will be rendered in a JSON structure as a set of name/value pairs. JSON is excellent for Web 2.0 applications. Note: json is returned with an application/json MIME type which generally has the effect in a browser of being prompted to download and save a file. In actual Web 2.0 usage this should be handled by your Javascript logic.
Syntaxformat=[rdb{,1.0} | json{,1.1}]
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &format=rdb
  • &format=rdb,1.0
  • &format=json // WaterML 1.1 translated into JSON
  • &format=json,1.1

Indent (indent)

URL Argument Namedeta
DescriptionUsed to specify whether block structured data formats (&format=waterml|json only) should include indentation for easy viewing. Four space characters are inserted for every level of indentation. Otherwise the parameter is ignored.

Syntaxindent=[on|off]
Defaultoff
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &format=json&format=on // Indented JSON wanted
  • &format=json&format=off // JSON wanted, no indentation
  • &format=rdb&format=on // Format parameter ignored, does not apply to RDB

Specifying Date Ranges

Data going back as far as October 1, 2007 are available for each site. You typically do not need all this data, so you generally express a range of dates needed. Here is how to limit the amount of values you receive:

I want to...Do this...Syntax RulesExamples
Get the latest values onlyNothing. Only the latest value is returned by default for each requested site and parameter.
  • None, no argument needed
&stateCd=ny&parameterCd=00060 // Get the latest discharge values for all time-series sites in New York state
Get a range of values from nowSpecify the period argument
  • period must be in ISO-8601 Duration format
  • Negative periods (ex: P-T2H) are not allowed
  • Data are always returned up to the most recent value, which in the case of a predictive gage might be in the future.
  • When specifying days from now, the first value will probably not be at midnight of the first day, but somewhat before exactly 24 hours from now.
&period=PT2H (Retrieve last two hours from now up to most recent instantaneous value)
&period=P7D (Retrieve last seven days up from now to most recent instantaneous value)
Get a range of values from an explicit begin or end date/timeUse the startDT and endDT arguments
  • Site local time is output, even if multiple sites are requested and sites are in different time zones. Note that the measurement time zone at a site may not be the same as the time zone actually in effect at the site.
  • Both startDt and endDt must be in ISO-8601 Date/Time format. You can express the date and time in a timezone other than site local time if you want as long as it follows the ISO standard. For example, you can express the time in Universal time: 2014-03-20T00:00Z.
  • If startDT is supplied and endDT is not, endDT ends with the most recent instantaneous value
  • startDT must be chronologically before endDT
  • If endDT is present, startDt must also be present.
  • If startDt shows the date and not the time of day (ex: 2010-09-01) the time of midnight site time is assumed (2010-09-01T00:00)
  • If endDt shows the date and not the time of day (ex: 2010-09-02) the last minute before midnight site time is assumed (2010-09-02T23:59)
  • Remember, only data from October 1, 2007 are currently available
&startDT=2010-11-22&endDT=2010-11-22 // Full day, from 00:00 to 23:59
&startDT=2010-11-22T12:00&endDT=2010-11-22T18:00
&startDT=2010-11-22&endDT=2010-11-22
&startDT=2010-11-22T12:00 // Ends with most recent instantaneous value

Minor Filters

Additional filters can be applied after specifying a major filter. This further reduces the set of expected results. Users are encouraged to use minor filters because it allows more efficient use of this service.

Parameter Code (parameterCd)

URL Argument NameparameterCd (aliases: variable, parameterCds, variables, var, vars, parmCd)
Description
  • USGS time-series parameter code
  • All parameter codes are numeric and 5 characters in length. Parameter codes are used to identify the constituent measured and the units of measure.
  • Popular codes include stage (00065), discharge in cubic feet per second (00060) and water temperature in degrees Celsius (00010)
  • Complete list of USGS parameter codes (not all parameters are served by time-series sites)
SyntaxparameterCd|variable={parameterCd1,parameterCd2,...}
Defaultreturns all regular time-series parameters for the requested sites
Minimum argument values required1
Maximum argument values allowed100
Examples
  • &parameterCd=00060 // discharge, cubic feet per second
  • &parameterCd=00060,00065 // discharge, cubic feet per second and gage height in feet
  • &variable=00060 // discharge, cubic feet per second
  • &variable=00060,00065 // discharge, cubic feet per second and gage height in feet

Site Type (siteType)

URL Argument NamesiteType (aliases: siteTypes, siteTypeCd, siteTypeCds)
Description
  • Restricts sites to those having one or more major and/or minor site types.
  • List of valid site types
  • If you request a major site type (ex: &siteType=ST) you will get all sub-site types of the same major type as well (in this case, ST-CA, ST-DCH and ST-TS)
SyntaxsiteType={siteType1,siteType2,...}
DefaultAll site types are returned
Minimum argument values required1
Maximum argument values allowedNo limit
Examples
  • &siteType=ST // Streams only
  • &siteType=ST,LA-OU // Streams and Land Outcrops only

Site was modified since (modifiedSince)

URL Argument NamemodifiedSince
Description
  • Returns all values for sites and period of record requested only if any values have changed over the last modifiedSince period.
  • modifiedSince is useful if you periodically need to poll a site but are only interested in getting data if some of it has changed.
  • It is typically be used with period, or startDT/endDT but does not have to be. In the latter case, if any values were changed during the specified modifiedSince period, only the most recent values would be retrieved for those sites. This is a typical usage, since users typically are polling a site and only want data if there are new or changed measurements.
  • ISO-8601 duration format is always used.
SyntaxmodifiedSince=ISO-8601-duration
DefaultNone
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &modifiedSince=PT2H // Retrieves all values for sites and period of record requested for any of the requested sites and parameters, but only for sites where any of the values changed during the last two hours.
  • &modifiedSince=PT2H&period=P1D // Retrieve all values for sites and period of record requested for the last 24 hours from now only for sites and parameters that had any values that changed or were added during the last two hours.
  • &modifiedSince=PT2H&startDt=2010-11-01&endDt=2010-11-02 // Retrieve all values for sites and period of record requested for sites and parameters that had values change between midnight site local time on Nov 1st, 2010 and 23:59 on Nov 2nd, 2010 site local time, only if values were changed or added within the last two hours.

Agency Code (agencyCd)

URL Argument NameagencyCd
Description
  • The list of sites returned are filtered to return only those with the provided agency code. The agency code describes the organization that maintains the site. Only one agency code is allowed and is optional.
  • An authoritative list of agency codes can be found here.
SyntaxagencyCd=agencyCd1
DefaultAll sites regardless of agency code are retrieved
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &stateCd=il&agencyCd=USCE // Only US Army Corps of Engineers sites in Illinois

Site Status (siteStatus)

URL Argument NamesiteStatus
Description
  • Selects sites based on whether or not they are active. If a site is active, it implies that it is being actively maintained. A site is considered active if:

    • it has collected time-series (automated) data within the last 183 days (6 months)
    • it has collected discrete (manually collected) data within 397 days (13 months)

    If it does not meet these criteria, it is considered inactive. Some exceptions apply. If a site is flagged by a USGS water science center as discontinued, it will show as inactive. A USGS science center can also flag a new site as active even if it has not collected any data.

    The default is all (show both active and inactive sites).

SyntaxsiteStatus=[ all | active | inactive ]
Defaultall - sites of any activity status are returned
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &siteStatus=active

Altitude (altMin and altMax)

URL Argument Name
  • altMin (alias: altMinVa)
  • altMax (alias: altMaxVa)
Description
  • These arguments allows you to select instantaneous values sites where the associated sites' altitude are within a desired altitude, expressed in feet. Altitude is based on the datum used at the site.
  • Providing a value to altMin (minimum altitude) means you want sites that have or exceed the altMin value
  • Providing a value to altMax (maximum altitude) means you want sites that have or are less than the altMax value
  • You may specify decimal feet if precision is critical
  • If both the altMin and altMax are specified, sites at or between the minimum and maximum altitude are returned
Syntax
  • altMin=minValue
  • altMax=maxValue
DefaultAll sites are retrieved, regardless of their altitude
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &altMin=1000&altMax=5000 // Return sites where the altitude is 1000 feet or greater and 5000 feet or less.
  • &altMin=12.5&altMax=13 // Return sites where the altitude is 12.5 feet or greater and 13 feet or less.

Surface water filters

Drainage Area (drainAreaMin and drainAreaMax)

URL Argument Names
  • drainAreaMin (alias: drainAreaMinVa)
  • drainAreaMax (alias: drainAreaMaxVa)
Description
  • These arguments allows you to select principally surface water sites where the associated sites' drainage areas (watersheds) are within a desired size, expressed in square miles or decimal fractions thereof.
  • Providing a value to drainAreaMin (minimum drainage area) means you want sites that have or exceed the drainAreaMin value
  • Providing a value to drainAreaMax (maximum drainage area) means you want sites that have or are less than the drainAreaMax value
  • The values may be expressed in decimals
  • If both the drainAreaMin and drainAreaMax are specified, sites at or between the minimum and maximum drainage areas values specified are returned
  • Caution: not all sites are associated with a drainage area.
  • Caution: drainage area generally only applies to surface water sites. Use with other site types, such as groundwater sites, will likely retrieve no results.
Syntax
  • drainAreaMin=minValue
  • drainAreaMax=maxValue
DefaultAll sites are retrieved, regardless of their drainage area
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &drainAreaMin=1000&drainAreaMax=5000 // Return sites where the drainage area is 1000 square miles or greater and is 5000 square miles or less.
  • &drainAreaMin=10.5&drainAreaMax=10.7 // Return sites where the drainage area is 10.5 square miles or greater and is 10.7 square miles or less.

Groundwater Filters

Aquifer Code (aquiferCd)

URL Argument Names
  • aquiferCd
Description
  • Used to filter sites to those that exist in specified national aquifers. Note: not all sites have been associated with national aquifers.
  • Enter one or more national aquifer codes, separated by commas.
  • A national aquifer code is exactly 10 characters.
  • A complete list of national aquifer codes can be found here.
Syntax
  • aquiferCd={aquiferCd1,aquiferCd2,...}|all
Defaultall
Minimum argument values required0
Maximum argument values allowed1000
Examples
  • &aquiferCd=S500EDRTRN,N100HGHPLN // returns groundwater sites for the Edwards-Trinity aquifer system and the High Plains national aquifers.

Local Aquifer Code (localAquiferCd)

URL Argument Names
  • localAquiferCd
Description
  • Used to filter sites to those that exist in specified local aquifers. Note: not all sites have been associated with local aquifers.
  • Enter one or more local aquifer codes, separated by commas.
  • A local aquifer code begins with a 2 character state abbreviation (such as TX for Texas) followed by a colon followed by the 7 character aquifer code.
  • A complete list of local aquifer codes can be found here.
Syntax
  • all|localAquiferCd={localAquiferCd1,localAquiferCd2,...}
Defaultall
Minimum argument values required0
Maximum argument values allowed1000
Examples
  • &localAquiferCd=AL:111RGLT,AL:111RSDM // returns sites for the Regolith and Saprolite local aquifers in Alabama

Well Depth (wellDepthMin and wellDepthMax)

URL Argument Names
  • wellDepthMin (alias: wellDepthMinVa)
  • wellDepthMax (alias: wellDepthMaxVa)
Description
  • These arguments allows you to select groundwater sites serving data recorded automatically where the associated sites' well depth are within a desired depth, expressed in feet from the land surface datum.
  • Express well depth as a positive number.
  • Providing a value to wellDepthMin (minimum well depth) means you want sites that have or exceed the wellDepthMin value
  • Providing a value to wellDepthMax (maximum well depth) means you want sites that have or are less than the wellDepthMax value
  • The values may be expressed in decimals
  • If both the wellDepthMin and wellDepthMax are specified, sites at or between the minimum and maximum well depth values specified are returned
  • wellDepthMax should be greater than or equal to wellDepthMin.
  • Caution: well depth applies to groundwater sites only
Syntax
  • wellDepthMin=minValue
  • wellDepthMax=maxValue
DefaultAll sites are retrieved, regardless of their well depth
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &wellDepthMin=100&wellDepthMax=500 // Return daily value sites where the well depth is 100 feet or greater and 500 feet or less.
  • &wellDepthMin=10.5&wellDepthMax=10.7 // Return daily value sites where the well depth is 10.5 feet or greater and 10.7 feet or less.

Hole Depth (holeDepthMin and holeDepthMax)

URL Argument Names
  • holeDepthMin (alias: holeDepthMinVa)
  • holeDepthMax (alias: holeDepthMaxVa)
Description
  • These arguments allows you to select groundwater sites serving data recorded automatically where the associated sites' hole depth are within a desired depth, expressed in feet from the land surface datum.
  • Express hole depth as a positive number.
  • Providing a value to holeDepthMin (minimum hole depth) means you want sites that have or exceed the holeDepthMin value
  • Providing a value to holeDepthMax (maximum hole depth) means you want sites that have or are less than the holeDepthMax value
  • The values may be expressed in decimals
  • If both the holeDepthMin and holeDepthMax are specified, sites at or between the minimum and maximum hole depth values specified are returned
  • holeDepthMax should be greater than or equal to holeDepthMin.
  • Caution: hole depth applies to groundwater sites only
Syntax
  • holeDepthMin=minValue
  • holeDepthMax=maxValue
DefaultAll sites are retrieved, regardless of their hole depth
Minimum argument values required1
Maximum argument values allowed1
Examples
  • &holeDepthMin=100&holeDepthMax=500 // Return daily values sites where the hole depth is 100 feet or greater and 500 feet or less.
  • &holeDepthMin=10.5&holeDepthMax=10.7 // Return daily value sites where the hole depth is 10.5 feet or greater and 10.7 feet or less.

Feedback

Please provide any feedback you have on this service using this form .