Introducing IPify API

IPify is a simple yet powerful API that provides users with their public IP address. With IPify API, developers can easily fetch their IP address and use this information to make customized solutions based on the user's current location.

How to Use IPify API

IPify API has a straightforward usage. You only need to make a GET request to https://api.ipify.org with your API key, and you'll get your public IP address in response. You can use any HTTP client, be it JavaScript, Python or any other language to call the API with your API key. In this blog, we'll focus on how to use the IPify API in JavaScript.

To start, you need to have a JavaScript environment setup. You can use any modern web browser's console or Node.js to execute the code. Here is an example of calling the API in JavaScript:

const apiKey = 'YOUR_API_KEY';
const url = `https://api.ipify.org/?format=json&apiKey=${apiKey}`;

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data.ip))
  .catch(error => console.error(error));

The code above sends a GET request to the IPify API endpoint with your API key in the URL. It then parses the JSON response for your ip address and logs it to the console.

How to Get an API Key

To use the IPify API, you must have an API key. You can get an API key by signing up on the IPify website. Follow these steps:

  1. Visit the IPify website https://www.ipify.org/.
  2. Click the "Get API Key" button.
  3. Enter your Email and click "Get API Key."
  4. Check your email for further instructions.

You'll see your API key in your account dashboard. Keep in mind that IPify provides a free and paid version of the API. With the free version, you have a limit of 1,000 requests per day.

Conclusion

IPify API is an excellent tool to get your public IP address easily. The API is simple, with a straightforward usage and is available in different languages. In this blog, we explained how to use IPify in JavaScript and how to get an API key. Now, you can start integrating this powerful tool into your projects.

Related APIs

Public APIs — A directory of free and public apis

Built by @mddanishyusuf