URL Lookup API

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

/v1/urllookup GET

https://api.api-ninjas.com/v1/urllookup

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.


Parameters

  • url  required

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

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

url
https://api.api-ninjas.com/v1/urllookup?url=example.com

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 { "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" }

Code Examples

1 2 3 4 5 6 7 8 9 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(response.text) else: print("Error:", response.status_code, response.text)

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.