Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Code-Sleep-Python/ForecastDiscussion/MNAFD.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
import requests

# MPX is the office for Chanhassen National Weather Service Office.
# To find yours, go here: https://www.weather.gov/srh/nwsoffices
myOffice = "mpx"
url = "https://api.weather.gov/products/types/afd/locations/%s" % myOffice

headers = {
'User-Agent': "Python"
}

response = requests.request("GET", url, headers=headers)
latestAfd = response.json()['@graph'][0]['@id']
afdJson = requests.request("GET", latestAfd, headers=headers).json()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this return ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Freeze, kindly update on this PR.


# These are the two pieces of the JSON that have information we actually want.
print(afdJson['issuanceTime'])
print(afdJson['productText'])
5 changes: 5 additions & 0 deletions Code-Sleep-Python/ForecastDiscussion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Forecast Discussion using NWS API

It's easy to stick your head out the window and see what the weather is or to look at a website and see what the weather will be tomorrow. But do you wonder why that website says what the weather will be tomorrow?

Usually twice daily, there is an area forecast discussion put out by the National Weather Service explaining why they've made the decisions they have regarding the forecast they put out. This script will retrieve that discussion for Minneapolis (MPX) and post it in your CLI.