Water Rights Data API End-point

Access Token. Please get in touch with the WaDE Team at WaDE_WSWC@hotmail.com to get an API access token. The token protects the API from bots and attacks. The WaDE team is planning to support a personalized token for each user as part of the WesDAAT user management system. We apologize for the inconvenience.

Water rights are now accessible through the Western States Water Data Access and Analysis Tool (WestDAAT). https://westdaat.westernstateswater.org/

You can also use the WaDE API to access water rights data across the West in a consistent JavaScript Object Notation (JSON) structure.

Here is the API endpoint and its parameters

Click on the arrow next to the "response" block in the link below to see the API schema and an example response.

Example Python code for using the API

#!/usr/bin/env python
import pandas as pd
import numpy as np
import os
import json
from pandas.io.json import json_normalize
from urllib.request import urlopen
import gmaps
import gmaps.datasets
import plotly.express as px
# Access WaDE API to get the water allocations JSON 
url = 'https://wade-api-qa.azure-api.net/v1/SiteAllocationAmounts?State='
statesShort = ["CO", "UT", "WA", "OR", "CA", "OK", "ND", "AZ"]

df100_list = []

# extract target columns
subcolumns = ['WaterSourceUUID', 'Sites', 'AllocationAmount', 'AllocationMaximum',
              'BeneficialUses']

for state in statesShort:
    urlwithfilter = url+state
    response =  urlopen(urlwithfilter)
    dataread = response.read().decode("utf-8")
    data = json.loads(dataread)
    df10 = json_normalize(data, 'Organizations')
    df20 = pd.concat([pd.DataFrame(json_normalize(x)) for x in df10['WaterAllocations']],
                     ignore_index=True)
    df30 = df20[subcolumns]
    df100_list.append(df30)

df100 = pd.concat(df100_list, sort=True, ignore_index=True)

#df100.drop_duplicates(inplace=True)
print(len(df100.index))

df100.head(5)
# get a data frame that combines lat lon with allocation values

latloncolumns = ['WaterSourceUUID','Longitude', 'Latitude',
                 'AllocationAmount', 'AllocationMaximum', 'BeneficialUses']

df300 = pd.DataFrame(columns=latloncolumns)

jy = 0
for index, rows in df100.iterrows(): 
    SitesL = rows.Sites
    for latlon in SitesL:
        #print(latlon)
        df300.loc[jy,'WaterSourceUUID'] = rows.WaterSourceUUID
        df300.loc[jy,'AllocationAmount'] = rows.AllocationAmount
        df300.loc[jy,'AllocationMaximum'] = rows.AllocationMaximum
        df300.loc[jy,'BeneficialUses'] = rows.BeneficialUses

        df300.loc[jy,'Longitude'] = latlon['Longitude']
        df300.loc[jy,'Latitude'] = latlon['Latitude']
        jy += 1

print(len(df300.index))
df300.head(5)

# outdf100.WaterSourceUUID = df100['WaterSourceUUID']
print("Drop rows without lat lon values...")

df500 = df300.dropna(subset=['Longitude', 'Latitude'])
df500 = df500.reset_index(drop=True)

print(len(df500.index))
df500.head(5)
print("Drop duplicates if there are any...")

subCols = ['Longitude', 'Latitude']

df500.drop_duplicates(subset = subCols, inplace=True)   #
df500 = df500.reset_index(drop=True)

print(len(df500.index))
df500.head(5)
# make sure the data are in the right data types
# plotly complained about allocation types being 'object'

print(df500.dtypes)

df500['AllocationAmount'] = pd.to_numeric(df500['AllocationAmount'], errors='coerce')
df500['AllocationMaximum'] = pd.to_numeric(df500['AllocationMaximum'], errors='coerce')
df500['Latitude'] = pd.to_numeric(df500['Latitude'], errors='coerce')
df500['Longitude'] = pd.to_numeric(df500['Longitude'], errors='coerce')
print(df500.dtypes)
# Plot allocation amount as a gmaps heatmap

APIKey = 'AI.......' # put your Google API key here
gmaps.configure(api_key=APIKey)

logan_coordinates = (41.6, -111.8)
denver_coordinates = (39.78, -104.59)
fig = gmaps.figure(map_type='HYBRID', center=denver_coordinates, zoom_level=4.5)

locations = df500[['Latitude', 'Longitude']]
#locations = locations[0:8701]
weights = df500['AllocationAmount']
#weights = weights1[0:8701]
fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))

fig
print("Droping null amounts...")

df500purge = df500.loc[(df500["AllocationAmount"] == '') | (df500["AllocationAmount"] == np.nan)]
if len(df500purge.index) > 0:
    dropIndex = df500.loc[(df500["AllocationAmount"] == '') | (df500["AllocationAmount"] == np.nan)].index
    outdf100 = df500.drop(dropIndex)
    outdf100 = df500.reset_index(drop=True)
print("Droping null max amounts...")

df500purge = df500.loc[(df500["AllocationMaximum"] == '') | (df500["AllocationMaximum"] == np.nan)]
if len(df500purge.index) > 0:
    dropIndex = df500.loc[(df500["AllocationMaximum"] == '') | (df500["AllocationMaximum"] == np.nan)].index
    outdf100 = df500.drop(dropIndex)
    outdf100 = df500.reset_index(drop=True)
# plot allocation amount as plotly heatmap

#need to save your mapbox token file in the same dir
px.set_mapbox_access_token(open(".mapbox_token").read())

fig = px.scatter_mapbox(df500, lat="Latitude", lon="Longitude",  
                        color="AllocationAmount", #size="AllocationMaximum",
                  color_continuous_scale=px.colors.cyclical.IceFire, size_max=5,
                        range_color=[0,1000],zoom=3, hover_data=["BeneficialUses"])
fig.show()

Last updated