How to get IP geolocation data via IPinfo IP Geolocation REST API?

An example of getting the user's location by IP address. The free IP geolocation API service is provided by IPInfo.io. The IP geolocation API key is sent to the server in the Authorization: Bearer {apikey} request header. You can request the IP geolocation API service by making HTTP GET requests.
How to get IP geolocation data via IPinfo IP Geolocation REST API? Send
GET /8.8.8.8 HTTP/1.1
Host: ipinfo.io
User-Agent: curl/7.68.0
Authorization: Bearer {ipinfo_apikey}

Updated: Viewed: 28224 times

What is IP Geolocation?

With the IP Geolocation API, you can determine the approximate location of a device that is used to connect to the Internet, such as a user's mobile phone or desktop computer. IP geolocation is used to provide a better service to website users, as well as for anti-fraud checks during commercial transactions. IP geolocation is performed by looking up the user's IP address in a constantly updated database of IP addresses.

How do I request the IP Geolocation API service?

To request the IP Geolocation REST API, you must provide the IP-address that you want to check as an URL parameter and your free IP Geolocation API key as the bearer token authorization header.

GET https://ipinfo.io/8.8.8.8
Authorization: Bearer {apikey}

With the free IP Geolocation API plan, you can make 50,000 geolocation API requests per month.

Generate Code Snippets for IP Geolocation API Example

Convert your IP Geolocation API request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the ReqBin code generator.