Every request that reaches your server carries one fact the client did not choose to tell you: the address it came from. It is the cheapest fraud signal you have, because you already hold it, and the most misused, because it looks far more precise than it is.
This lesson gets you two things from an IP address. The first is a location: a country you can mostly trust, a region and timezone you can use as defaults, and a city you should treat as a rumour. The second is the network behind it, the Autonomous System that announces the address to the rest of the internet, which tells you whether you are talking to a home broadband line, a mobile carrier or a rented server. The next three lessons build on both.
What an IP address can tell you
An IP address is a routing label, not an identity. It says which network will deliver packets to the client, and the geolocation databases behind every IP API are educated reconstructions of where those networks put their customers. They are built from registry records, ISP feeds, latency measurements and corrections people submit. Some of that is very good. None of it is a GPS fix.
Three properties follow from that, and they shape every decision in this course:
- Coarse is reliable, fine is not. Country is right for the vast majority of residential and mobile addresses. Region is usually right. City is often the location of the ISP's equipment, or the nearest big town, or the centre of the country when the database has nothing better.
- The address is not the person. Behind one IP there may be a family, a coffee shop, an office of 2,000, or a mobile carrier sharing one public address across thousands of phones (carrier-grade NAT). Behind one person there may be dozens of IPs over a week.
- The address can be borrowed. VPNs, proxies, Tor and cloud servers let anyone appear wherever they like. Detecting that is lesson 2. In this lesson, assume the address is honest and learn what it says.
Look up an IP
IP Lookup (iplookup) takes one ip query parameter on a GET and costs 10 credits. Try it on the example address from its definition:
curl "https://api.apiverve.com/v1/iplookup?ip=173.172.81.20" \
-H "x-api-key: YOUR_API_KEY"country, region and timezone are on every plan; city, coordinates and accuracyRadius are premium.
The response splits cleanly into fields every plan gets and fields that need a higher plan:
| Field | Plan | What it is good for |
|---|---|---|
country, countryName | all | ISO 3166-1 alpha-2 code and name. Defaults, compliance routing, mismatch checks |
region, regionName | all | State or province. Tax defaults, regional content |
timezone | all | IANA zone such as America/Chicago. Scheduling defaults, "local time" checks |
continent, continentName | all | Coarse routing, analytics |
city, postalCode, coordinates | premium | Display only, never decisions |
accuracyRadius | premium | How far, in kilometres, the true location may be from coordinates |
isEU | premium | EU membership of the country |
asn, asnName | premium | The network announcing the address |
Write your code so the premium fields are optional from the first line. A field that is missing on one plan and present on another should never be the difference between your code working and throwing.
region deserves a note too: for some addresses it is null even on paid plans, because the database only knows the country. The lookup for Google's public resolver 8.8.8.8 returns country: "US", a null region and city, and an accuracyRadius of 1000 km.
How accurate is it, really?
Two observations from real calls make the point better than any disclaimer.
First, the same address moves. The sample response stored in the catalog for 173.172.81.20 places it in Kansas City, Missouri. A call made the day this lesson was written placed it in Lincoln, Nebraska, roughly 300 km away, while still reporting a 20 km accuracy radius. Both answers came from the same API. ISPs reassign address blocks between regions and the databases catch up later; the radius describes the database's confidence, not a guarantee.
Second, "no idea" looks like a location. When the database knows only the country, it still returns coordinates: for many US addresses those are [37.751, -97.822], a point in rural Kansas near the geographic centre of the country, paired with an accuracy radius of 1000 km. Put that on a map without reading the radius and you will tell a user in Boston that they are in a wheat field.
So the rules:
- Decide on country, use region and timezone as defaults the user can change, and use city only for display ("Signed in near Lincoln, NE") with words that admit uncertainty.
- If you show coordinates, draw a circle of
accuracyRadius, not a pin, and hide it entirely when the radius is in the hundreds of kilometres. - Never use IP location as proof of residence for anything with legal weight. It is a hint you corroborate with a billing address, a phone number or a document.
An IP lookup returns coordinates [37.751, -97.822] with accuracyRadius 1000. What should a login-history screen show?
Answer the check above to continue.
Who owns the network: ASN lookup
Every public address is announced to the internet by an Autonomous System, a network with its own number. The ASN is often more useful than the location, because it tells you what kind of connection you are dealing with. A residential ISP, a mobile carrier and a cloud provider are three very different populations of users.
ASN Lookup (asnlookup) costs 4 credits and takes an asn parameter, not an IP:
curl "https://api.apiverve.com/v1/asnlookup?asn=AS16509" \
-H "x-api-key: YOUR_API_KEY"description is on every plan: Amazon.com, Inc. The handle AMAZON-02 and range counts are premium.
description (the registered organisation) and simple (the bare number) are on every plan; handle, country and the announced range counts are premium. Send the number with its AS prefix. The API also accepts a bare 13335, but then echoes asn back without the prefix, so a cache keyed on the response's asn field ends up with two spellings of the same network.
Where does the ASN come from? Three places:
- IP Lookup's premium
asnfield, as in the locator above. On plans that include it you getAS11427andTWC-11427-TEXASwith the location in one call. - Your edge. Many CDNs attach the client's ASN to the request before it reaches you; Cloudflare Workers, for example, expose it as
request.cf.asn. If you already have it, do not pay to look it up again. - The detectors in the next lesson, which return it on premium plans alongside their verdicts.
Notice that the AS names in IP data are registry names, not brands: TWC-11427-TEXAS is a Charter (Spectrum) network and the US address is in Nebraska, not Texas. Use ASN Lookup's description when you want an organisation name a human recognises.
An ASN result changes rarely, so cache it for a week or more. A few dozen networks will account for most of your traffic, which makes this one of the cheapest lookups in the course once the cache is warm.
What IP location is good for, and what it is not
Good uses share a property: being wrong costs little, or another signal backs the decision up.
- Defaults. Pre-select the country in a form, show prices in a likely currency, suggest a timezone. The user corrects you in one click.
- Mismatch signals. A card issued in one country, a billing address in a second and an IP in a third is worth a second look. Any one of them alone is ordinary; travellers and expats exist.
- Login anomaly hints. "New sign-in from a different country" is a fair email to send. "Account locked because the city changed" is not, given what you saw above.
- Coarse compliance routing. Showing the right consent banner or routing EU traffic to an EU deployment, with the understanding that VPN users will land on the wrong side.
Bad uses treat it as proof: refusing a sale because the city does not match the shipping address, or deciding someone's legal jurisdiction from their IP alone.
Privacy: an IP address is personal data
Under the GDPR, and in the guidance of most European regulators, an IP address can be personal data, because the ISP can link it to a subscriber. Treat it that way:
- Say in your privacy notice that you look up the location and network of visitor IP addresses for security and fraud prevention, and name the purpose.
- Store the derived, coarse result (country, network type) for as long as you need it, and the raw address only as long as your security purpose requires. A login history keeps a lot of value with a truncated address and a country.
- Do not send IPs to a lookup service that you have no reason to look up. The private-range filter above is a privacy measure as much as a credit saving.
Next you will find out when the address is not telling the truth: Detect VPN, proxy and Tor traffic.