Public API Docs for IPInfo.io using JavaScript

If you're looking for a reliable, easy-to-use API to gather information about any IP address, look no further than IPInfo.io. Their public API is free for up to 50,000 requests per month, and offers a ton of useful data on any IP address, including location, ISP, and more.

If you want to use IPInfo.io in your own JavaScript application, you're in luck – it's incredibly easy to do so. Here are a few examples:

Get Information on the Requesting IP Address

To get information about the IP address that the user is accessing your application from, you can simply make a GET request to https://ipinfo.io/json:

fetch('https://ipinfo.io/json')
  .then(response => response.json())
  .then(data => console.log(data))

This will return a JSON object with details on the requesting IP address, including where it's located, what ISP it's associated with, and more.

Get Information on Any IP Address

If you want to look up information on an IP address that's not the requesting one, you can do so by including the IP address at the end of the request URL:

fetch('https://ipinfo.io/8.8.8.8/json')
  .then(response => response.json())
  .then(data => console.log(data))

This will return information on the IP address 8.8.8.8, which is actually Google's DNS server.

Work with the Data Returned

Once you have the data returned from IPInfo.io, you can work with it however you like. Here's an example of how you might extract the city and region of a given IP address:

fetch('https://ipinfo.io/8.8.8.8/json')
  .then(response => response.json())
  .then(data => {
    const { city, region } = data
    console.log(`This IP address is located in ${city}, ${region}.`)
  })

Overall, the IPInfo.io API is incredibly easy to use in your own JavaScript application. Whether you need to look up information on a user's requesting IP address, or any other IP address, it's fast, reliable, and provides a wealth of information.

Related APIs