Country From IP API

The API implemented allows you to retrieve the country associated with a given IP address.

URL: https://api.apipip.com/v1/ip-country/


Parameters

Name Description
address (Required) The IP address you want to look up

Headers

Name Description
X-Key (No required)

How to use Country From IP API

                
import requests

# Set the API endpoint URL
url = 'https://api.apipip.com/v1/ip-country/'

# Set the IP address you want to look up
payload = {
    "address": "160.176.33.210"
}

# Send a POST request to the API
response = requests.post(url, json=payload)

# Print the country name
print(response.text)
                
                    
                
const url = 'https://api.apipip.com/v1/ip-country/';

// Set the IP address you want to look up
const payload = {
  address: "160.176.33.210"
};

// Send a POST request to the API
fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(payload)
})
  .then(response => response.text())
  .then(data => {
    // Print the country name
    console.log(data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
                
                    
                
import Foundation

// Set the API endpoint URL
let url = URL(string: "https://api.apipip.com/v1/ip-country/")!

// Set the IP address you want to look up
let payload = ["address": "160.176.33.210"]

// Create the request
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

// Send the request
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
    if let error = error {
        print("Error: \(error)")
        return
    }
    
    guard let data = data else {
        print("No data received")
        return
    }
    
    if let responseString = String(data: data, encoding: .utf8) {
        // Print the country name
        print(responseString)
    } else {
        print("Invalid response format")
    }
}

task.resume()
                
                    

API Response

                            
{
  "country": "United States"
}
                            
                                

Note: The API works with all programming languages