Skip to content
VPNDetection

Migrate from ip-api.com

Move from ip-api.com to VPNDetection: change the request, map each ip-api.com field to its VPNDetection field, and compare the answers before you switch.

This guide moves an integration from ip-api.com to VPNDetection. It shows how the request changes, which VPNDetection field answers each of ip-api.com's, how rules that read them change, and how to compare the two services on your own traffic before you switch.

Before you begin

  • A VPNDetection API key, if you need more than the free plan's fields. Without a key, a lookup answers the free plan's fields: is_vpn, is_tor, is_relay, and the address's country and network. 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

ip-api.com's free endpoint takes no key and answers over plain HTTP. It returns the proxy, hosting and mobile flags only when you list them in fields:

bash
curl "http://ip-api.com/json/8.8.8.8?fields=status,message,query,proxy,hosting,mobile,as,asname,isp,org"

VPNDetection takes the address as the path and your key in the Authorization header:

bash
curl -H "Authorization: Bearer $VPNDETECTION_API_KEY" https://api.vpndetection.io/8.8.8.8

Its Pro endpoint takes a key as a query parameter, over HTTPS. If 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

ip-api.com answers flat fields, with one proxy flag for VPNs, proxies and Tor alike. VPNDetection answers one top-level flag for each kind of address, with a detail object beside it. Fields after Paid plan: come with a paid plan; the rest come with every plan, the free plan included.

ip-api.comVPNDetectionNotes
proxyis_vpn, is_tor, is_relay; Paid plan: is_resproxy, is_dcproxy, is_mobproxy, is_pubproxyOne flag for each kind, where ip-api.com answers one for all.
hostingPaid plan: is_hosting, hosting.providerhosting.provider names the hosting company.
as, asname, isp, orgasn.asn, asn.name, asn.domainip-api.com's as holds the number and the name in one string; VPNDetection's are separate fields.
mobilePaid plan: is_carrier, carrier.nameMobile proxy pools are flagged apart, in is_mobproxy.

The IP lookup reference documents every VPNDetection field.

3. Update your rules

The main change is from one flag to one for each kind:

  • A rule that read proxy reads is_vpn and is_tor on every plan, and the proxy flags on a paid plan.
  • VPNDetection answers every field your plan includes in every answer, so there's no fields list to maintain.
  • A field your plan doesn't include is absent rather than false, so a rule checks that a paid field is present before it acts on the value. See Plans and fields.

The equivalent of ip-api.com's proxy on VPNDetection is:

js
const r = await client.lookup(ip);
const anonymous = r.isVpn || r.isTor || r.isResproxy === true || r.isDcproxy === true
    || r.isMobproxy === true || r.isPubproxy === true;

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 ip-api.com's proxy flag and VPNDetection's differ. Save it as compare.mjs beside sample.txt, install the library with npm install vpndetection, and run node compare.mjs:

js
import { readFileSync } from 'node:fs';
import { VPNDetection } from 'vpndetection';

const client = new VPNDetection({ apiKey: process.env.VPNDETECTION_API_KEY });
const ips = readFileSync('sample.txt', 'utf8').split('\n').filter(Boolean);

for (const ip of ips) {
    const res = await fetch(`http://ip-api.com/json/${ip}?fields=status,proxy`);
    const theirs = await res.json();
    const ours = await client.lookup(ip);
    const theirFlag = theirs.proxy === true;
    const ourFlag = ours.isVpn || ours.isTor;
    if (theirFlag !== ourFlag) {
        console.log(ip, 'ip-api.com:', theirFlag, 'VPNDetection:', ourFlag);
    }
    // ip-api.com's free endpoint allows 45 requests a minute.
    await new Promise((done) => setTimeout(done, 1500));
}

With a paid VPNDetection key, use the combined flag from step 3, so proxies count on both sides.

Every provider builds its own data, so some disagreement is expected. Look up a few of the addresses on both sides. If you believe VPNDetection'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:

  1. Run both side by side. Keep deciding with ip-api.com, and log VPNDetection's answer beside it for a few days of real traffic.
  2. Switch the decisions. Decide with VPNDetection, and keep logging ip-api.com's answer while you watch for surprises.
  3. Remove ip-api.com. Once your logs are clean, delete the old client from your code and revoke its key.

Next steps

When the answers suit your rules, switch your code to VPNDetection. Protect a web app applies rules in middleware, and the guides cover sign-ups, logins, payments and country rules. Before you launch, review the go-live checklist.