Client Location vs Server Location

ipapi ~ ipapi.co
1 min readApr 28, 2021

--

Frequently Asked Question : ipapi is returning the location of my server instead of the client (i.e. website’s visitor). What am I doing wrong ?

Answer : There are 2 ways to use the API :

  1. https://ipapi.co/json/ : Client Side API
  • This URL would return the location of the device that made the API call i.e. it will find the IP address and the location of your website’s visitor (or mobile app).
  • This API call should originate from the Javascript code that runs in the browser.
  • Do not initiate this call from your backend server (unless you want to find the location of your server).

2. https://ipapi.co/1.2.3.4/json/ : Server Side API

  • This URL would return the location of IP address 1.2.3.4
  • This API call should originate from your backend server (i.e. PHP, Java, Python, .NET, Go, Ruby, Node.js etc. code).
  • In this case, you will have to find the IP address of your website’s visitor and pass that in the URL path. The API returns the location of the address that you’ve provided.

Please refer to more examples in ipapi docs

--

--

ipapi ~ ipapi.co
ipapi ~ ipapi.co

Written by ipapi ~ ipapi.co

IP Lookup | IP Geolocation API | IP Address Locator by Kloudend, Inc. USA. Trusted by Fortune 500 !