The URL Lookup API provides location information for any valid URL or domain name.
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.
url
requiredValid URL to check. It supports schemes (e.g. http://example.com
) as well as schemeless (e.g. example.com
) formats.
X-Api-Key
requiredAPI Key associated with your account.
https://api.api-ninjas.com/v1/urllookup?url=example.com
Headers
X-Api-Key
Log in or sign up to get your API Key
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"
}
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.