Skip to content

Instantly share code, notes, and snippets.

@paulopperman
Created January 4, 2018 19:28
Show Gist options
  • Save paulopperman/49b295bb5700f820eaecc73db0092701 to your computer and use it in GitHub Desktop.
Save paulopperman/49b295bb5700f820eaecc73db0092701 to your computer and use it in GitHub Desktop.
Playing around with NOAA API: https://www.ncdc.noaa.gov/cdo-web/webservices/v2
import requests
import pandas as pd
# API documentation is at https://www.ncdc.noaa.gov/cdo-web/webservices/v2
NOAA_API_TOKEN = '<from NOAA>'
headers = {'token':NOAA_API_TOKEN}
# get stations in Newport, RI
stations_response = requests.get('https://www.ncdc.noaa.gov/cdo-web/api/v2/stations?locationid=FIPS:44&sortfield=maxdate&sortorder=desc&limit=500',headers=headers)
stations = pd.io.json.json_normalize(stations_response.json()['results'])
stations = stations[stations.name.str.find("NEWPORT")==0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment