# Migrate from ipapi.is

Move from ipapi.is to InternetData: change the request, map each ipapi.is field to its InternetData field, and compare the answers before you switch.

This guide moves an integration from ipapi.is to InternetData. It shows how the request changes, which InternetData field answers each of ipapi.is'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](/get-started/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

ipapi.is takes the address in the `q` query parameter and your key in `key`:

```bash
curl "https://api.ipapi.is/?q=8.8.8.8&key=$IPAPI_IS_KEY"
```

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

```bash
curl -H "Authorization: Bearer $INTERNETDATA_API_KEY" https://api.internetdata.io/8.8.8.8
```

If your code can't set a header, send the key in the `apikey` query parameter instead; see [Authentication](/api/auth). To make the request from your code with an official library, see [Use an SDK](/get-started/sdks).

## 2. Map the fields

ipapi.is answers top-level flags, and `vpn`, `datacenter`, `egress_service`, `asn`, `company` and `abuse` objects when they apply. 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.

| ipapi.is | InternetData | Notes |
| --- | --- | --- |
| `is_vpn`, `vpn.service` | *Paid plan:* `is_vpn`, `vpn.provider_name` | `vpn.provider_name` names the VPN service. |
| `is_proxy` | *Paid plan:* `is_resproxy`, `is_dcproxy`, `is_mobproxy`, `is_pubproxy` | `is_pubproxy` answers open proxies, as `is_proxy` does; the others add residential, datacenter and mobile pools. |
| `is_tor` | `is_tor` | `is_tor` flags exits, where ipapi.is's covers every Tor relay. |
| `egress_service` | `is_relay`, `relay.provider_name` | Privacy relays and company web gateways. |
| `is_datacenter`, `datacenter.datacenter` | *Paid plan:* `is_hosting`, `hosting.provider_name`, `is_cdn` | CDNs are a separate flag. |
| `is_mobile` | *Paid plan:* `is_carrier`, `carrier` | `carrier` names the carrier. |
| `is_satellite` | *Paid plan:* `is_satellite`, `satellite` | `satellite` names the operator. |
| `asn`, `company` | `asn`; *Paid plan:* `company.name`, `company.domain`, `company.type`, `company.country` | `asn.org` and `asn.route` become `asn.name` and `asn.prefix`. |
| `abuse` | *Paid plan:* `abuse.email` and the rest of `abuse` |  |
| `is_crawler` | *Paid plan:* `is_bot`, `bot.agents` | `is_bot` also flags monitors, scanners and webhook senders; `bot.agents` names the crawler. |
| `is_abuser` | No counterpart |  |

The [IP lookup reference](/api/lookup/lookupIp) documents every InternetData field.

## 3. Update your code

Most code moves field for field:

- Code that read `asn.org` and `asn.route` reads `asn.name` and `asn.prefix`.
- `egress_service` becomes `is_relay`, with the operator in `relay.provider_name`.
- `is_crawler` becomes `is_bot`, with the crawler's name in `bot.agents` on a paid plan.
- `is_tor` flags exit nodes only, where ipapi.is's covers every relay of the Tor network.
- 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](/get-started/plans-and-fields).
- Past your organization's lookups with every field, the official libraries raise `quota_exceeded` and put the answer, the basics, on the error as `result`. Code that should carry on with the basics catches it, as the script below does. See [Handle a capped answer](/get-started/sdks#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 ipapi.is's AS number 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`:

```js
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 res = await fetch(`https://api.ipapi.is/?q=${ip}&key=${process.env.IPAPI_IS_KEY}`);
    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 the AS number.
        if (err.kind !== 'quota_exceeded' || !err.result) {
            throw err;
        }
        ours = err.result;
    }
    const theirValue = theirs.asn?.asn;
    const ourValue = ours.asn.asn;
    if (theirValue !== ourValue) {
        console.log(ip, 'ipapi.is:', 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](https://internetdata.io/contact?purpose=data-correction).

## 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 ipapi.is, and log InternetData's answer beside it for a few days of real traffic.
2. **Switch the decisions.** Decide with InternetData, and keep logging ipapi.is's answer while you watch for surprises.
3. **Remove ipapi.is.** 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](/get-started/web-apps) looks up every visitor in middleware, and the [guides](/guides) cover personalization, investigations, abuse reports and data pipelines. Before you launch, review the [go-live checklist](/get-started/production).
