API key not working?

Made an account, got the API key, stuck it on the end of the url, but still getting a 401 error.

Here’s the link.

Feel like that should be working.


it is working.

What you are seeing there is a response in the form of a json object.

If you add console.log(whateveryour response is called) and look in dev tools you will be able to work out how to get the data from it and into your app.

for instance

$('#mydiv').html('<p> the wetaher is ' + myresponse.weather.main + ' in your town<p>');

I get:

{“cod”:401, “message”: “Invalid API key. Please see http://openweathermap.org/faq#error401 for more info.”}

When I go to that link. You’re getting weather data?

Was editing above post…

yeh, i get (in chrome, http)

{"coord":{"lon":-0.13,"lat":51.51},"weather":[{"id":801,"main":"Clouds","description":"few clouds","icon":"02d"}],"base":"stations","main":{"temp":287.329,"pressure":1012.69,"humidity":67,"temp_min":287.329,"temp_max":287.329,"sea_level":1020.15,"grnd_level":1012.69},"wind":{"speed":4.76,"deg":95.0004},"clouds":{"all":12},"dt":1476443177,"sys":{"message":0.004,"country":"GB","sunrise":1476426249,"sunset":1476464855},"id":2643743,"name":"London","cod":200}

I think i know whats going on here.

are you calling the api with //api.openweathermap.org/data/2.5/weather?q=London&appid=886705b4c1182eb1c69f28eb8c520e20,

because if you stick http: in front of it in your app, like chrome browser has, it should work.

Still doesn’t work. Odd. Not my first time using an API, either.

do you have a link to your code? you’re more likley to get help from those who know if they can see the code.

Wasnt at the point where I wrote any code. I was putting the api link + key into the address bar and getting that error. It’s working now, so seems like it just took some time for my API key to start working on my side. Dumb.

Was there any resolution to this because I keep getting the same error as well!

It says it could take up to 10 minutes to validate the key but it’s been about 20 minutes now…

Here is mine… http://api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=410463b3935acea56c8171825dbb4440

Check the documentation. The sample URL looks like this:


You have an extra /city in your URL.

1 Like

Hi all! :grinning:

If anyone is still interested in this:

I got the 401 error when calling like this:

var apiCall = "https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&key=THIS_PART_BEING_THE_KEY"

But looking at the link from @BDMayhem the http request uses appid instead of key .
I changed the code and now I get some JSON in return.

The new code:

var apiCall = "https://api.openweathermap.org/data/2.5/weather?lat=35&lon=139&appid=THIS_PART_BEING_THE_KEY";

You can check out me code here .

I used https://www.hurl.it to make check the API calls.


Thank you. I had a similar problem and your solution works well.

This is just a timing issue; once you have your new api on open weather app after you have created the account; wait for around 10-15 minutes, after that the api would start working.

Already wrote a in detail about it on dev.to , i was having same problem took me hours to debug. Please read solve-problem-of-api-responds-with-401-error