IP Lookup API
The IP Lookup API provides location information for any valid IP address. It works with both IPv4 and IPv6 addresses.
From 3,906 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 307ms | 342ms | 349ms | 725ms | 1054ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/iplookup GET
https://api.api-ninjas.com/v1/iplookup
Returns the location of the IP address specified. The response contains both the geographical coordinates (latitude/longitude) as well as the city and country.
Parameters
addressrequiredIP Address to query. Must be in IPv4 format
A.B.C.D(e.g.73.9.149.180) or IPv6 formatX:X:X:X:X:X:X:X(e.g.2001:0db8:85a3:0000:0000:8a2e:0370:7334).
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response Fields
A JSON object with the following fields or an error if the request is unsuccessful.
addressThe IP address of the query
timezoneThe time zone related to the IP address
latpremium onlyThe latitude coordinate of the IP address location
lonpremium onlyThe longitude coordinate of the IP address location
zippremium onlyThe ZIP code of the IP address location
citypremium onlyThe city where the IP address is located
regionThe region name where the IP address is located. In the United States, this is equivalent to the state.
region_codeThe region code of the IP address location. In the United States, this is equivalent to the 2-letter state abbreviation.
countryThe name of the country where the IP address is located
country_codeThe 2-letter country code of the IP address location
is_validThe validity status of the IP address
isppremium onlyThe Internet Service Provider associated with the IP address
Sample Request Live Demo!
Try our APIs in the API playground
Sign up for a free API key to get started — no credit card required.
https://api.api-ninjas.com/v1/iplookup?address=73.9.149.180Headers
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/iplookup?address=8.8.8.8" \
-H "X-Api-Key: YOUR_API_KEY"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.
Frequently Asked Questions
Can I use the IP Lookup API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the IP Lookup API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the IP Lookup API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the IP Lookup API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.Does the IP Lookup API support IPv6 addresses?
Yes. Theaddressparameter accepts both IPv4 format (e.g.73.9.149.180) and IPv6 format (e.g.2001:0db8:85a3:0000:0000:8a2e:0370:7334). If you need to resolve a hostname or domain instead of an IP, see the DNS Lookup API.Which response fields require a premium plan?
Thelat,lon,zip,city, andispfields are premium-only, while fields likecountry,country_code,region,region_code,timezone, andis_validare available on all plans. See pricing for details on premium access.How do I get latitude and longitude coordinates from an IP address?
A successful lookup returnslatandlonfields containing the geographic coordinates of the IP address location (these are premium-only fields). To convert those coordinates back into a human-readable address, pass them to the Reverse Geocoding API.What do the region and region_code fields represent?
Theregionfield is the region name where the IP is located, andregion_codeis its code; in the United States these correspond to the state name and its 2-letter state abbreviation respectively. To geolocate a place name or address instead of an IP, use the Geocoding API.