0
votes

I'm trying to use open weather API, I just created an account and got my API key, after I wrote https://api.openweathermap.org/data/2.5/weather?q=London&appid=<--myapikey-->

in zsh, it returns:

[1] 12567 zsh: no matches found: https://api.openweathermap.org/data/2.5/weather?q=London jack@jackengtwistios-Mac-mini node-andrew % [1] + exit 1 curl https://api.openweathermap.org/data/2.5/weather?q=London

in bash:

[1] 12715 jackengtwistios-Mac-mini:node-andrew jack$ {"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

but in chrome brower it just returns the expected result:

{"coord":{"lon":-0.1257,"lat":51.5085},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":279.99,"feels_like":279.99,"temp_min":278.87,"temp_max":280.86,"pressure":1017,"humidity":72},"visibility":10000,"wind":{"speed":0.45,"deg":331,"gust":2.24},"clouds":{"all":7},"dt":1637851503,"sys":{"type":2,"id":2019646,"country":"GB","sunrise":1637825718,"sunset":1637856008},"timezone":0,"id":2643743,"name":"London","cod":200}

1
"Invalid API key" - where in your CURL are you passing the api key? - Neil

1 Answers

0
votes

OP shows that this URL works in Chrome:

https://api.openweathermap.org/data/2.5/weather?q=London&appid=<--myapikey-->

But this is what is being used in cURL

curl https://api.openweathermap.org/data/2.5/weather?q=London

It's missing the appid parameter