Obtaining Geolocation in Play using IP Address

Table of contents
Reading Time: < 1 minute

In this blog , I will explain how to obtain Geolocation in Play Scala application from IP address of user . You can easily fetch user’s current location or near by location by his IP address .

1) You will require API key to be able to use this feature. To get API key , just go to IPInfoDB .

2) Get user’s IP address

3) Provide the IPInfoDB’s API Key

4) Then obtain the user’s location from the following link

5) At last get the data from the Input Stream of connection

will provide you Geolocation in JSON format with all details including Latitude and Longitude.

Note :- Add following line in application.conf file

Otherwise Play application wont be able to fetch Public IP Address of User.

Written by 

Himanshu Gupta is a software architect having more than 9 years of experience. He is always keen to learn new technologies. He not only likes programming languages but Data Analytics too. He has sound knowledge of "Machine Learning" and "Pattern Recognition". He believes that best result comes when everyone works as a team. He likes listening to Coding ,music, watch movies, and read science fiction books in his free time.

4 thoughts on “Obtaining Geolocation in Play using IP Address1 min read

Comments are closed.