URL Lookup API

The URL Lookup API provides location information for any valid URL or domain name.



Returns the location of the IP address hosting the URL domain. The response contains both the geographical coordinates (latitude/longitude) as well as the city and country.


url (required) - valid URL to check. It supports schemes (e.g. http://example.com) as well as schemeless (e.g. example.com) formats.


X-Api-Key (required) - API Key associated with your account.

Sample Request URL

Live Demo!


Sample Response

  "is_valid": true,
  "country": "United States",
  "country_code": "US",
  "region_code": "MA",
  "region": "Massachusetts",
  "city": "Norwell",
  "zip": "02061",
  "lat": 42.1591,
  "lon": -70.8163,
  "timezone": "America/New_York",
  "isp": "MCI Communications Services, Inc. d/b/a Verizon Business",
  "url": "example.com"

import requests

url = 'example.com'
api_url = 'https://api.api-ninjas.com/v1/urllookup?url={}'.format(url)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
    print("Error:", response.status_code, response.text)
var url = 'example.com'
    method: 'GET',
    url: 'https://api.api-ninjas.com/v1/urllookup?url=' + url,
    headers: { 'X-Api-Key': 'YOUR_API_KEY'},
    contentType: 'application/json',
    success: function(result) {
    error: function ajaxError(jqXHR) {
        console.error('Error: ', jqXHR.responseText);
const request = require('request');
var url = 'example.com';
  url: 'https://api.api-ninjas.com/v1/urllookup?url=' + url,
  headers: {
    'X-Api-Key': 'YOUR_API_KEY'
}, function(error, response, body) {
  if(error) return console.error('Request failed:', error);
  else if(response.statusCode != 200) return console.error('Error:', response.statusCode, body.toString('utf8'));
  else console.log(body)
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

import com.fasterxml.jackson.databind.ObjectMapper;

URL url = new URL("https://api.api-ninjas.com/v1/urllookup?url=example.com");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("accept", "application/json");
InputStream responseStream = connection.getInputStream();
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(responseStream);
let url = "example.com".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: "https://api.api-ninjas.com/v1/urllookup?url="+url!)!
var request = URLRequest(url: url)
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-Api-Key")
let task = URLSession.shared.dataTask(with: request) {(data, response, error) in
    guard let data = data else { return }
    print(String(data: data, encoding: .utf8)!)
If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.