In [2]:
import requests
import json
import os
import credentials

In [3]:
baseurl = "https://www.ncdc.noaa.gov/cdo-web/api/v2/"
endpoint_data = "data"
endpoint_datasets = "datasets"
endpoint_datatypes = "datatypes"
endpoint_stations = "stations"
dataset = "GSOM"
stationid = "GHCND:USW00026615"  # bethel, i think
custom_headers = {
    "token": credentials.token
}
datatypes = ["EMNT", "EMXT", "EMSD", "EMXP"]
params = {
    "datasetid": "GSOM",
    "datatypeid": datatypes,
    "startdate": "2017-07-01",
    "enddate": "2017-07-31",
    "stationid": "GHCND:USW00026615",
    "units": "standard",
}
all_stations = ["USW00026411",
                "USW00025308",
                "USW00025309",
                "USW00025339",
                "USW00025501",
                "USW00025503",
                "USW00025507",
                "USW00025624",
                "USW00026451",
                "USW00025713",
                "USW00026415",
                "USW00026425",
                "USW00026442",
                "USW00026510",
                "USW00026528",
                "USW00026533",
                "USW00026615",
                "USW00026616",
                "USW00026617",
                "USW00027502",]

Request 1: Available datatypes for a dataset, e.g. daily or monthly normals


In [4]:
fullbase = requests.compat.urljoin(baseurl, endpoint_datatypes)

In [16]:
r = requests.get(
    fullbase, 
    headers=custom_headers,
#    params={'limit':1000},
    params={'limit':1000, 'datasetid':"NORMAL_DLY"},
)

In [17]:
r.headers


Out[17]:
{'Transfer-Encoding': 'chunked', 'Access-Control-Allow-Headers': 'token', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Date': 'Wed, 16 Aug 2017 19:05:31 GMT', 'Strict-Transport-Security': 'max-age=31536000', 'Content-Type': 'application/json;charset=UTF-8', 'Connection': 'close', 'Server': 'Apache-Coyote/1.1'}

In [18]:
r.text


Out[18]:
'{"metadata":{"resultset":{"offset":1,"count":60,"limit":1000}},"results":[{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 45F","datacoverage":1,"id":"DLY-CLDD-BASE45"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 50F","datacoverage":1,"id":"DLY-CLDD-BASE50"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 55F","datacoverage":1,"id":"DLY-CLDD-BASE55"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 57F","datacoverage":1,"id":"DLY-CLDD-BASE57"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 60F","datacoverage":1,"id":"DLY-CLDD-BASE60"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 70F","datacoverage":1,"id":"DLY-CLDD-BASE70"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 72F","datacoverage":1,"id":"DLY-CLDD-BASE72"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily cooling degree days with base 65F","datacoverage":1,"id":"DLY-CLDD-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily diurnal temperature range","datacoverage":1,"id":"DLY-DUTR-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term standard deviations of daily diurnal temperature range","datacoverage":1,"id":"DLY-DUTR-STDDEV"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 40F","datacoverage":1,"id":"DLY-GRDD-BASE40"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 45F","datacoverage":1,"id":"DLY-GRDD-BASE45"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 50F","datacoverage":1,"id":"DLY-GRDD-BASE50"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 55F","datacoverage":1,"id":"DLY-GRDD-BASE55"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 57F","datacoverage":1,"id":"DLY-GRDD-BASE57"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 60F","datacoverage":1,"id":"DLY-GRDD-BASE60"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 65F","datacoverage":1,"id":"DLY-GRDD-BASE65"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 70F","datacoverage":1,"id":"DLY-GRDD-BASE70"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with base 72F","datacoverage":1,"id":"DLY-GRDD-BASE72"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with truncated bases 48F and 86F","datacoverage":1,"id":"DLY-GRDD-TB4886"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily growing degree days with truncated bases 50F and 86F","datacoverage":1,"id":"DLY-GRDD-TB5086"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 40F","datacoverage":1,"id":"DLY-HTDD-BASE40"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 45F","datacoverage":1,"id":"DLY-HTDD-BASE45"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 50F","datacoverage":1,"id":"DLY-HTDD-BASE50"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 55F","datacoverage":1,"id":"DLY-HTDD-BASE55"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 57F","datacoverage":1,"id":"DLY-HTDD-BASE57"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 60F","datacoverage":1,"id":"DLY-HTDD-BASE60"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily heating degree days with base 65F","datacoverage":1,"id":"DLY-HTDD-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"25th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-25PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"50th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-50PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"75th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-75PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of precipitation >= 0.01 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-PCTALL-GE001HI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of precipitation >= 0.10 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-PCTALL-GE010HI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of precipitation >= 0.50 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-PCTALL-GE050HI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of precipitation >= 1.00 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-PRCP-PCTALL-GE100HI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"25th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-25PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"50th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-50PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"75th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-75PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snowfall >= 0.1 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-PCTALL-GE001TI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snowfall >= 1.0 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-PCTALL-GE010TI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snowfall >= 3.0 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-PCTALL-GE030TI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snowfall >= 5.0 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-PCTALL-GE050TI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snowfall >= 10 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNOW-PCTALL-GE100TI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"25th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-25PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"50th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-50PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"75th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-75PCTL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snow depth >= 1 inch for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-PCTALL-GE001WI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snow depth >= 3 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-PCTALL-GE003WI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snow depth >= 5 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-PCTALL-GE005WI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Probability of snow depth >= 10 inches for 29-day windows centered on each day of the year","datacoverage":1,"id":"DLY-SNWD-PCTALL-GE010WI"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily average temperature","datacoverage":1,"id":"DLY-TAVG-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term standard deviations of daily average temperature","datacoverage":1,"id":"DLY-TAVG-STDDEV"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily maximum temperature","datacoverage":1,"id":"DLY-TMAX-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term standard deviations of daily maximum temperature","datacoverage":1,"id":"DLY-TMAX-STDDEV"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term averages of daily minimum temperature","datacoverage":1,"id":"DLY-TMIN-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term standard deviations of daily minimum temperature","datacoverage":1,"id":"DLY-TMIN-STDDEV"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term average month-to-date precipitation totals","datacoverage":1,"id":"MTD-PRCP-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term average month-to-date snowfall totals","datacoverage":1,"id":"MTD-SNOW-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term average year-to-date precipitation totals","datacoverage":1,"id":"YTD-PRCP-NORMAL"},{"mindate":"2010-01-01","maxdate":"2010-12-31","name":"Long-term average year-to-date snowfall totals","datacoverage":1,"id":"YTD-SNOW-NORMAL"}]}'

In [19]:
json.loads(r.text)


Out[19]:
{'metadata': {'resultset': {'count': 60, 'limit': 1000, 'offset': 1}},
 'results': [{'datacoverage': 1,
   'id': 'DLY-CLDD-BASE45',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 45F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE50',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 50F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE55',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 55F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE57',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 57F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE60',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 60F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE70',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 70F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-BASE72',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 72F'},
  {'datacoverage': 1,
   'id': 'DLY-CLDD-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily cooling degree days with base 65F'},
  {'datacoverage': 1,
   'id': 'DLY-DUTR-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily diurnal temperature range'},
  {'datacoverage': 1,
   'id': 'DLY-DUTR-STDDEV',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term standard deviations of daily diurnal temperature range'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE40',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 40F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE45',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 45F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE50',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 50F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE55',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 55F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE57',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 57F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE60',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 60F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE65',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 65F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE70',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 70F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-BASE72',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with base 72F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-TB4886',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with truncated bases 48F and 86F'},
  {'datacoverage': 1,
   'id': 'DLY-GRDD-TB5086',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily growing degree days with truncated bases 50F and 86F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE40',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 40F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE45',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 45F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE50',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 50F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE55',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 55F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE57',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 57F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-BASE60',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 60F'},
  {'datacoverage': 1,
   'id': 'DLY-HTDD-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily heating degree days with base 65F'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-25PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '25th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-50PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '50th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-75PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '75th percentiles of daily nonzero precipitation totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-PCTALL-GE001HI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of precipitation >= 0.01 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-PCTALL-GE010HI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of precipitation >= 0.10 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-PCTALL-GE050HI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of precipitation >= 0.50 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-PRCP-PCTALL-GE100HI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of precipitation >= 1.00 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-25PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '25th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-50PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '50th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-75PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '75th percentiles of daily nonzero snowfall totals for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-PCTALL-GE001TI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snowfall >= 0.1 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-PCTALL-GE010TI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snowfall >= 1.0 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-PCTALL-GE030TI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snowfall >= 3.0 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-PCTALL-GE050TI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snowfall >= 5.0 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNOW-PCTALL-GE100TI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snowfall >= 10 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-25PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '25th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-50PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '50th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-75PCTL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': '75th percentiles of daily nonzero snow depth for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-PCTALL-GE001WI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snow depth >= 1 inch for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-PCTALL-GE003WI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snow depth >= 3 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-PCTALL-GE005WI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snow depth >= 5 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-SNWD-PCTALL-GE010WI',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Probability of snow depth >= 10 inches for 29-day windows centered on each day of the year'},
  {'datacoverage': 1,
   'id': 'DLY-TAVG-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily average temperature'},
  {'datacoverage': 1,
   'id': 'DLY-TAVG-STDDEV',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term standard deviations of daily average temperature'},
  {'datacoverage': 1,
   'id': 'DLY-TMAX-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily maximum temperature'},
  {'datacoverage': 1,
   'id': 'DLY-TMAX-STDDEV',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term standard deviations of daily maximum temperature'},
  {'datacoverage': 1,
   'id': 'DLY-TMIN-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term averages of daily minimum temperature'},
  {'datacoverage': 1,
   'id': 'DLY-TMIN-STDDEV',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term standard deviations of daily minimum temperature'},
  {'datacoverage': 1,
   'id': 'MTD-PRCP-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term average month-to-date precipitation totals'},
  {'datacoverage': 1,
   'id': 'MTD-SNOW-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term average month-to-date snowfall totals'},
  {'datacoverage': 1,
   'id': 'YTD-PRCP-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term average year-to-date precipitation totals'},
  {'datacoverage': 1,
   'id': 'YTD-SNOW-NORMAL',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Long-term average year-to-date snowfall totals'}]}

Request 2: Data for a station


In [13]:
fullbase = requests.compat.urljoin(baseurl, endpoint_data)
r = requests.get(
    fullbase, 
    headers=custom_headers,
    params=params,
)

In [14]:
json.loads(r.text)


Out[14]:
{'metadata': {'resultset': {'count': 3, 'limit': 25, 'offset': 1}},
 'results': [{'attributes': ',W,07,+',
   'datatype': 'EMNT',
   'date': '2017-07-01T00:00:00',
   'station': 'GHCND:USW00026615',
   'value': 41.0},
  {'attributes': ',,W,17,',
   'datatype': 'EMXP',
   'date': '2017-07-01T00:00:00',
   'station': 'GHCND:USW00026615',
   'value': 0.6},
  {'attributes': ',W,21,',
   'datatype': 'EMXT',
   'date': '2017-07-01T00:00:00',
   'station': 'GHCND:USW00026615',
   'value': 77.0}]}

In [101]:
r.headers


Out[101]:
{'Access-Control-Allow-Methods': 'GET', 'Date': 'Tue, 15 Aug 2017 02:38:44 GMT', 'Access-Control-Allow-Headers': 'token', 'Connection': 'close', 'Access-Control-Allow-Origin': '*', 'Server': 'Apache-Coyote/1.1', 'Strict-Transport-Security': 'max-age=31536000', 'Content-Type': 'application/json;charset=UTF-8', 'Transfer-Encoding': 'chunked'}

Request 3: Available datasets


In [80]:
fullbase = requests.compat.urljoin(baseurl, endpoint_datasets)
r = requests.get(
    fullbase, 
    headers=custom_headers,
)

In [81]:
json.loads(r.text)


Out[81]:
{'metadata': {'resultset': {'count': 11, 'limit': 25, 'offset': 1}},
 'results': [{'datacoverage': 1,
   'id': 'GHCND',
   'maxdate': '2017-08-08',
   'mindate': '1763-01-01',
   'name': 'Daily Summaries',
   'uid': 'gov.noaa.ncdc:C00861'},
  {'datacoverage': 1,
   'id': 'GSOM',
   'maxdate': '2017-07-01',
   'mindate': '1763-01-01',
   'name': 'Global Summary of the Month',
   'uid': 'gov.noaa.ncdc:C00946'},
  {'datacoverage': 1,
   'id': 'GSOY',
   'maxdate': '2017-01-01',
   'mindate': '1763-01-01',
   'name': 'Global Summary of the Year',
   'uid': 'gov.noaa.ncdc:C00947'},
  {'datacoverage': 0.95,
   'id': 'NEXRAD2',
   'maxdate': '2017-08-09',
   'mindate': '1991-06-05',
   'name': 'Weather Radar (Level II)',
   'uid': 'gov.noaa.ncdc:C00345'},
  {'datacoverage': 0.95,
   'id': 'NEXRAD3',
   'maxdate': '2017-08-07',
   'mindate': '1994-05-20',
   'name': 'Weather Radar (Level III)',
   'uid': 'gov.noaa.ncdc:C00708'},
  {'datacoverage': 1,
   'id': 'NORMAL_ANN',
   'maxdate': '2010-01-01',
   'mindate': '2010-01-01',
   'name': 'Normals Annual/Seasonal',
   'uid': 'gov.noaa.ncdc:C00821'},
  {'datacoverage': 1,
   'id': 'NORMAL_DLY',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Normals Daily',
   'uid': 'gov.noaa.ncdc:C00823'},
  {'datacoverage': 1,
   'id': 'NORMAL_HLY',
   'maxdate': '2010-12-31',
   'mindate': '2010-01-01',
   'name': 'Normals Hourly',
   'uid': 'gov.noaa.ncdc:C00824'},
  {'datacoverage': 1,
   'id': 'NORMAL_MLY',
   'maxdate': '2010-12-01',
   'mindate': '2010-01-01',
   'name': 'Normals Monthly',
   'uid': 'gov.noaa.ncdc:C00822'},
  {'datacoverage': 0.25,
   'id': 'PRECIP_15',
   'maxdate': '2014-01-01',
   'mindate': '1970-05-12',
   'name': 'Precipitation 15 Minute',
   'uid': 'gov.noaa.ncdc:C00505'},
  {'datacoverage': 1,
   'id': 'PRECIP_HLY',
   'maxdate': '2014-01-01',
   'mindate': '1900-01-01',
   'name': 'Precipitation Hourly',
   'uid': 'gov.noaa.ncdc:C00313'}]}

Request 4: Information about our stations


In [23]:
for station in all_stations:
    path = os.path.join(endpoint_stations, "GHCND:{}".format(station))
    fullbase = requests.compat.urljoin(baseurl, path)
    r = requests.get(
        fullbase, 
        headers=custom_headers,
    )
    print(json.dumps(json.loads(r.text), indent=2))


{
  "datacoverage": 1,
  "mindate": "1929-12-01",
  "maxdate": "2017-08-12",
  "elevation": 131.7,
  "name": "FAIRBANKS INTERNATIONAL AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -147.8761,
  "latitude": 64.8039,
  "id": "GHCND:USW00026411"
}
{
  "datacoverage": 1,
  "mindate": "1941-01-01",
  "maxdate": "2017-08-12",
  "elevation": 33.2,
  "name": "ANNETTE WEATHER SERVICE OFFICE AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -131.5787,
  "latitude": 55.0389,
  "id": "GHCND:USW00025308"
}
{
  "datacoverage": 1,
  "mindate": "1936-09-01",
  "maxdate": "2017-08-12",
  "elevation": 4.9,
  "name": "JUNEAU AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -134.564,
  "latitude": 58.3566,
  "id": "GHCND:USW00025309"
}
{
  "datacoverage": 1,
  "mindate": "1917-04-01",
  "maxdate": "2017-08-12",
  "elevation": 10.1,
  "name": "YAKUTAT AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -139.6712,
  "latitude": 59.512,
  "id": "GHCND:USW00025339"
}
{
  "datacoverage": 1,
  "mindate": "1945-01-01",
  "maxdate": "2017-08-12",
  "elevation": 24.4,
  "name": "KODIAK AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -152.48556,
  "latitude": 57.75111,
  "id": "GHCND:USW00025501"
}
{
  "datacoverage": 1,
  "mindate": "1942-01-01",
  "maxdate": "2017-08-12",
  "elevation": 20.4,
  "name": "KING SALMON AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -156.6563,
  "latitude": 58.6829,
  "id": "GHCND:USW00025503"
}
{
  "datacoverage": 1,
  "mindate": "1932-09-01",
  "maxdate": "2017-08-12",
  "elevation": 19.5,
  "name": "HOMER AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -151.4908,
  "latitude": 59.642,
  "id": "GHCND:USW00025507"
}
{
  "datacoverage": 1,
  "mindate": "1942-03-25",
  "maxdate": "2017-08-12",
  "elevation": 23.8,
  "name": "COLD BAY AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -162.7325,
  "latitude": 55.22083,
  "id": "GHCND:USW00025624"
}
{
  "datacoverage": 1,
  "mindate": "1952-04-01",
  "maxdate": "2017-08-12",
  "elevation": 36.6,
  "name": "ANCHORAGE TED STEVENS INTERNATIONAL AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -150.0278,
  "latitude": 61.169,
  "id": "GHCND:USW00026451"
}
{
  "datacoverage": 1,
  "mindate": "1943-11-05",
  "maxdate": "2017-08-12",
  "elevation": 10.7,
  "name": "ST PAUL ISLAND AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -170.22222,
  "latitude": 57.15528,
  "id": "GHCND:USW00025713"
}
{
  "datacoverage": 1,
  "mindate": "1917-06-01",
  "maxdate": "2017-08-12",
  "elevation": 389.2,
  "name": "BIG DELTA AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -145.7214,
  "latitude": 63.9944,
  "id": "GHCND:USW00026415"
}
{
  "datacoverage": 1,
  "mindate": "1907-03-01",
  "maxdate": "2017-08-12",
  "elevation": 476.1,
  "name": "GULKANA AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -145.4588,
  "latitude": 62.1591,
  "id": "GHCND:USW00026425"
}
{
  "datacoverage": 1,
  "mindate": "1917-05-01",
  "maxdate": "2015-11-13",
  "elevation": 29,
  "name": "VALDEZ WEATHER SERVICE OFFICE, AK US",
  "elevationUnit": "METERS",
  "longitude": -146.3517,
  "latitude": 61.1303,
  "id": "GHCND:USW00026442"
}
{
  "datacoverage": 1,
  "mindate": "1939-04-01",
  "maxdate": "2017-08-12",
  "elevation": 101.5,
  "name": "MCGRATH AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -155.6103,
  "latitude": 62.9574,
  "id": "GHCND:USW00026510"
}
{
  "datacoverage": 1,
  "mindate": "1918-06-01",
  "maxdate": "2017-08-12",
  "elevation": 106.7,
  "name": "TALKEETNA AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -150.095,
  "latitude": 62.32,
  "id": "GHCND:USW00026528"
}
{
  "datacoverage": 1,
  "mindate": "1945-01-01",
  "maxdate": "2017-08-12",
  "elevation": 196,
  "name": "BETTLES AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -151.5154,
  "latitude": 66.9169,
  "id": "GHCND:USW00026533"
}
{
  "datacoverage": 1,
  "mindate": "1923-08-01",
  "maxdate": "2017-08-12",
  "elevation": 31.1,
  "name": "BETHEL AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -161.8293,
  "latitude": 60.785,
  "id": "GHCND:USW00026615"
}
{
  "datacoverage": 1,
  "mindate": "1897-09-01",
  "maxdate": "2017-08-12",
  "elevation": 9.1,
  "name": "KOTZEBUE RALPH WEIN MEMORIAL AIRPORT, AK ",
  "elevationUnit": "METERS",
  "longitude": -162.63333,
  "latitude": 66.86667,
  "id": "GHCND:USW00026616"
}
{
  "datacoverage": 1,
  "mindate": "1900-08-01",
  "maxdate": "2017-08-12",
  "elevation": 4,
  "name": "NOME MUNICIPAL AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -165.44,
  "latitude": 64.5111,
  "id": "GHCND:USW00026617"
}
{
  "datacoverage": 1,
  "mindate": "1901-09-01",
  "maxdate": "2017-08-12",
  "elevation": 9.4,
  "name": "BARROW W POST W ROGERS AIRPORT, AK US",
  "elevationUnit": "METERS",
  "longitude": -156.7815,
  "latitude": 71.2834,
  "id": "GHCND:USW00027502"
}

In [18]:
fullbase = requests.compat.urljoin(baseurl, endpoint_stations, "GHCND:{}".format(station))

In [19]:
fullbase


Out[19]:
'https://www.ncdc.noaa.gov/cdo-web/api/v2/stations'

On a side note: Python integers that start with 0o (zero - lowercase o) are octal. 7 * 8 + 7 = 63.


In [75]:
0o77


Out[75]:
63

In [ ]: