I created a simple function to retrieve weather data for a city.
CloudPublish[
APIFunction[{"city" -> "City" :> $GeoLocationCity},
DeleteMissing[
AssociationMap[
Function[property,
WeatherData[First@GeoNearest["WeatherStation", #city],
property]], {"CloudCoverFraction", "DewPoint", "Humidity",
"Pressure", "Temperature", "Visibility", "WindChill",
"WindDirection", "WindSpeed"}]] &], Permissions -> "Public"]
I can use the function with a default city:
URLExecute[
HTTPRequest[CloudObject[
"https://www.wolframcloud.com/obj/17846929-623c-4a7a-8172-\
9837ec51a19d"], <|"Query" -> {}|>]]
The function returns the following:
<|"CloudCoverFraction" -> 0,
"DewPoint" -> Quantity[-2.19999, "DegreesCelsius"],
"Humidity" -> 0.305, "Pressure" -> Quantity[1034.1, "Millibars"],
"Temperature" -> Quantity[15, "DegreesCelsius"],
"Visibility" -> Quantity[16.09, "Kilometers"],
"WindChill" -> Quantity[14.11, "DegreesCelsius"],
"WindDirection" -> Quantity[30, "AngularDegrees"],
"WindSpeed" -> Quantity[14.76, ("Kilometers")/("Hours")]|>
The API function also supports manual inputs. For example, the following code will return data for New York City:
URLExecute[
HTTPRequest[
CloudObject[
"https://www.wolframcloud.com/obj/17846929-623c-4a7a-8172-\
9837ec51a19d"], <|"Query" -> {"city" -> "New York City"}|>]]
Here is the output:
<|"CloudCoverFraction" -> 0,
"DewPoint" -> Quantity[-8.29999, "DegreesCelsius"],
"Humidity" -> 0.248, "Pressure" -> Quantity[1035.8, "Millibars"],
"Temperature" -> Quantity[11.1, "DegreesCelsius"],
"Visibility" -> Quantity[16.09, "Kilometers"],
"WindChill" -> Quantity[8.93, "DegreesCelsius"],
"WindDirection" -> Quantity[40, "AngularDegrees"],
"WindSpeed" -> Quantity[18.36, ("Kilometers")/("Hours")]|>