Migrate from ipgeolocation.io
Move from ipgeolocation.io to InternetData: change the request, map each field to InternetData's, and compare the answers first.
This guide moves an integration from ipgeolocation.io's IP Security API to InternetData. It shows how the request changes, which InternetData field answers each of ipgeolocation.io's, how code that reads them changes, and how to compare the two services on your own traffic before you switch.
Before you begin
- An InternetData API key, for every field. Without a key, a lookup answers the basics, 100 a UTC day from each address: the address's country, network and reverse DNS name, and whether it is a Tor exit or a relay. A free key answers every field on its organization's first 1,000 lookups each UTC day, enough for the comparison in step 4. See Plans and fields.
- A sample of a few hundred addresses from your own traffic, one per line in
sample.txt, for the comparison in step 4.
1. Change the request
ipgeolocation.io's IP Security API takes your key in the apiKey query parameter and the address in ip:
curl "https://api.ipgeolocation.io/v3/security?apiKey=$IPGEOLOCATION_KEY&ip=8.8.8.8"InternetData takes the address as the path and your key in the Authorization header:
curl -H "Authorization: Bearer $INTERNETDATA_API_KEY" https://api.internetdata.io/8.8.8.8If your code can't set a header, send the key in the apikey query parameter instead; see Authentication. To make the request from your code with an official library, see Use an SDK.
2. Map the fields
ipgeolocation.io answers everything in its security object. InternetData answers the location, the network, the company and the abuse contact in objects of their own, and one top-level flag for each kind of address. Fields after Paid plan: come with every field, which a paid plan answers on every lookup and a free key on its organization's first 1,000 lookups each UTC day. The rest come in every answer.
| ipgeolocation.io | InternetData | Notes |
|---|---|---|
security.is_vpn, security.vpn_provider_names | Paid plan: is_vpn, vpn.provider_name | One provider, rather than a list of names. |
security.is_proxy, security.is_residential_proxy, security.proxy_provider_names | Paid plan: is_resproxy, is_dcproxy, is_mobproxy, is_pubproxy | One flag for each kind, each with its pool's provider. |
security.is_tor | is_tor | |
security.is_relay, security.relay_provider_name | is_relay, relay.provider_name | |
security.is_cloud_provider, security.cloud_provider_name | Paid plan: is_hosting, hosting.provider_name | hosting.provider_name names the hosting company. |
security.is_bot | Paid plan: is_bot, bot | bot.provider_name names whose bot it is, and bot.verified says whether its operator vouches for the address. |
security.threat_score | No counterpart |
The IP lookup reference documents every InternetData field.
3. Update your code
Most code moves field for field:
- Code over
security.threat_scorereads the classifications instead. - One provider replaces each list of names:
vpn.provider_name, and each proxy kind'sprovider_name. is_torandis_relaycome with every plan;is_vpn, the proxy flags,is_botandbotwith a paid plan.- A field your plan doesn't include is absent rather than
false, so your code checks that a paid field is present before it reads the value. See Plans and fields. - Past your organization's lookups with every field, the official libraries raise
quota_exceededand put the answer, the basics, on the error asresult. Code that should carry on with the basics catches it, as the script below does. See Handle a capped answer.
4. Compare the answers
Before you switch, run both services on your sample and review the addresses where they disagree. This script prints each address where ipgeolocation.io's Tor flag and InternetData's differ. Save it as compare.mjs beside sample.txt, install the library with npm install @internetdata/internetdata, and run node compare.mjs:
import { readFileSync } from 'node:fs';
import { InternetData } from '@internetdata/internetdata';
const client = new InternetData({ apiKey: process.env.INTERNETDATA_API_KEY });
const ips = readFileSync('sample.txt', 'utf8').split('\n').filter(Boolean);
for (const ip of ips) {
const url = `https://api.ipgeolocation.io/v3/security?apiKey=${process.env.IPGEOLOCATION_KEY}`
+ `&ip=${ip}`;
const res = await fetch(url);
const theirs = await res.json();
let ours;
try {
ours = await client.lookup(ip);
} catch (err) {
// Past your organization's lookups with every field: the basics, which hold is_tor.
if (err.kind !== 'quota_exceeded' || !err.result) {
throw err;
}
ours = err.result;
}
const theirValue = theirs.security?.is_tor === true;
const ourValue = ours.isTor;
if (theirValue !== ourValue) {
console.log(ip, 'ipgeolocation.io:', theirValue, 'InternetData:', ourValue);
}
}Every provider builds its own data, so some disagreement is expected. Look up a few of the addresses on both sides. If you believe InternetData's answer is wrong, send us the address.
5. Switch over
Once the comparison looks right, switch in stages, so you can stop at any point without affecting your users:
- Run both side by side. Keep deciding with ipgeolocation.io, and log InternetData's answer beside it for a few days of real traffic.
- Switch the decisions. Decide with InternetData, and keep logging ipgeolocation.io's answer while you watch for surprises.
- Remove ipgeolocation.io. Once your logs are clean, delete the old client from your code and revoke its key.
Next steps
When the answers suit your code, switch it to InternetData. Add InternetData to a web app looks up every visitor in middleware, and the guides cover personalization, investigations, abuse reports and data pipelines. Before you launch, review the go-live checklist.