Getting a users ip address


I’ve been searching for a way to get a users IP address that i can grab and use with the and then use that to make a request to the open weather maps api. Is their a way to do this with just javascript, or am i missing something on sending the ipapi request?


Never mind. Have been overthinking it again. :slight_smile:


Hi there,

If you just make a “GET” request to a location api, (I use ) using either JavaScript’s native XMLHttpRequest object or jQuery’s $.ajax(), then it will respond with a JSON which includes the user’s location information.

Armed with that, you can make a new request to your weather api with the city name in your query string. Something like:

https://someweatherAPI/data/q=” + cityFromFirstRequest + “&API_KEY=som ekey”

This should return the weather information for the particular location :slight_smile:

Weather underground API has an autoip feature you might be interested in.

I used You don’t need a users IP to get the JSON response. You can make a request like this: That will return the ip and gps coordinates. You’ll also need to consider using JSONP for the weather. You’ll know if you’re getting any Access-Control-Allow-Origin errors.