How to Use IP Address Lookup API

A split-screen image featuring a text editor with JSON-formatted API response on the left and a Phone app displaying IP address location on a map on the right.

In today’s digital age, getting accurate IP information is crucial for various applications such as fraud detection, geo-targeting, and even analytics. EasyAPI offers two handy endpoints for gathering comprehensive IP information. These endpoints provide data like:

  • City and Country: Know where your users are connecting from.
  • Timezone: Get the timezone, even down to its specific ID.
  • Currency: Identify the currency used in the area.
  • Date and Time: Accurate local date and time data.
  • Language: Languages spoken in the area.
  • State and Postal Code: More granularity on the location.

And much more!


An API key from EasyAPI. If you haven’t obtained this yet, you can refer to our guide on Getting Started Guide.

Step 1: Choose Your Endpoint

EasyAPI offers two endpoints to get IP information:

  1. For the Current User’s IP: https://api.easyapi.io/v1.0/ip?api_key=API_KEY
  2. For a Specific IP Address: https://api.easyapi.io/v1.0/ip/{ip}?api_key=API_KEY

Decide which one you need for your application.

Step 2: Make an API Request

For Current User's IP

Use the following command in your terminal to make an API call for the current user’s IP.

					curl -X GET "https://api.easyapi.io/v1.0/ip?api_key=YOUR_API_KEY"


For a Specific IP Address

Use the following command to get data for a specific IP address, say

					curl -X GET "https://api.easyapi.io/v1.0/ip/"

Step 3: Examine the Response

The API will return a JSON response similar to this:

         "date_time":"08/23/2023 20:39:30",
         "date_time_txt":"Wednesday, August 23, 2023 20:39:30",
         "date_time_wti":"Wed, 23 Aug 2023 20:39:30 +0100",
      "formatted_address":"Mayflower St, London SE16, UK",
         "country":"Britain (UK)",
         "currency_name":"Pound Sterling",
         "location":"51.50833333333333, -0.12527777777777777",

Understanding the JSON Response Fields

After making a successful API call, you will receive a JSON response. To better understand what each field represents, refer to the following table:

Field NameDescriptionExample Values
classRepresents the type of data“ip_info”
properties.cityThe city where the IP is located“Pescantina”
properties.countryThe country where the IP is located“Italy”
properties.country_codeThe ISO country code“IT”
properties.stateThe state or province where the IP is located“Province of Verona”
properties.state_codeThe state or province code“VR”
properties.postalThe postal code of the location“37026”
properties.locationLatitude and Longitude coordinates“45.4802,10.867”
properties.ipThe IP address“”
properties.datetimeVarious formats of the local date and timeSee Below for Subfields
properties.timezoneVarious data related to the timezone of the IPSee Below for Subfields
datetime subfields:
Field NameDescriptionExample Values
datetime.dateThe date“08/23/2023”
datetime.timeThe time“21:32:03”
datetime.yearThe year“2023”
datetime.monthThe month“08”
datetime.dayThe day“23”
timezone subfields:
Field NameDescriptionExample Values
timezone.idThe timezone ID“Europe/Rome”
timezone.capitalThe capital city of the country“Rome”
timezone.currency_nameThe name of the currency used in the country“Euro”
timezone.currency_codeThe currency code“978”
timezone.currency_alpha_codeThe ISO alpha code for the currency“EUR”

Step 4: Parse the Data

Python Implementation

You can use Python’s requests library to make the API call and parse the JSON response. Here’s an example:

					import requests
import json

response = requests.get("https://api.easyapi.io/v1.0/ip?api_key=YOUR_API_KEY")
data = json.loads(response.text)

city = data["properties"]["city"]
country = data["properties"]["country"]

print(f"City: {city}, Country: {country}")


To run this code, you’ll need to install the requests library, which can be done via pip:

					pip install requests

PHP Implementation

In PHP, you can use curl to make the API request and json_decode to parse the response:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.easyapi.io/v1.0/ip?api_key=YOUR_API_KEY");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec($ch);

$data = json_decode($response, true);

$city = $data['properties']['city'];
$country = $data['properties']['country'];

echo "City: " . $city . ", Country: " . $country;


Place this code in a PHP file and run it on your web server to get the IP details.

Step 5: Implement in Your Application

After successfully parsing the data, you can use this information in your application for various purposes like analytics, user personalization, or fraud detection.

Both Python and PHP examples demonstrate how easy it is to interact with EasyAPI’s IP information endpoints. Pick the one that fits your needs and integrate it into your application.


Congratulations on successfully navigating through the comprehensive guide on using EasyAPI’s IP Information Endpoints! Understanding the location of your users or clients is vital for a wide array of applications ranging from security measures like fraud detection to customer engagement methods like geo-targeting and analytics.

What's Next?

  • Getting Started: If you are a newcomer to EasyAPI or need a refresher, make sure to read our Getting Started Guide.

  • Timezone Detection: Need to fetch time-zone information along with IP info? Check out our Timezone API Guide for another similar endpoint that can enhance your application’s capabilities.

  • API Documentation: For developers who want an in-depth understanding of all the available functionalities, our API documentation made with redocs is available at https://docs.easyapi.io/.

With this newly acquired knowledge, you are well-equipped to implement IP information into your projects effectively. Happy coding!

Choose the Plan That Fits Your Need

Easy, transparent, and budget-friendly!