Advanced Usage

Batching Requests

Our /batch API endpoint allows you to group up to 1000 IPinfo API requests into a single request. This can really speed up processing of bulk IP lookups, and it can also be useful if you want to lookup information across our different APIs.

The /batch endpoint takes a list of URLs and responds with a JSON object with the input URLs as keys and the responses as values. The list of URLs can be provided as a newline separated list of URLs or a JSON object. Here are examples of both approaches along with the corresponding content-type headers needed. First, with a JSON array:

curl -XPOST --data '["8.8.8.8/country", "8.8.4.4/country"]' "ipinfo.io/batch?token=$TOKEN"
{
  "8.8.4.4/country": "US",
  "8.8.8.8/country": "US"
}

Second, as a newline separated list of URLs:

echo -e '8.8.8.8/country\n8.8.4.4/country' | \
curl -XPOST --data-binary @- "ipinfo.io/batch?token=$TOKEN"

Or,

cat urlList | curl -XPOST --data-binary @- "ipinfo.io/batch?token=$TOKEN"
{
  "8.8.4.4/country": "US",
  "8.8.8.8/country": "US"
}

There is also an optional filter parameter, which if set will result in any URLs for which there's no response being removed from the response. This can be useful for things like finding hostnames that exist for a range of IPs:

# Without filter
$ echo -e '8.8.8.8/hostname\n8.8.8.9/hostname' |  curl -XPOST --data-binary @- "ipinfo.io/batch?token=$TOKEN"
{
  "8.8.8.8/hostname": "dns.google",
  "8.8.8.9/hostname": ""
}

# With filter
$ echo -e '8.8.8.8/hostname\n8.8.8.9/hostname' |  curl -XPOST --data-binary @- "ipinfo.io/batch?token=$TOKEN&filter=1"
{
  "8.8.8.8/hostname": "dns.google",
}

Note that for the purposes of request volume tracking the call to /batch isn't counted, but all of the URLs within the call are. So the example above counts as 2 requests, and a single call to /batch with 100 URLs would count as 100 requests.

The batch endpoint works across all of our APIs. So you can use it with our ASN, IP ranges, and hosted domains endpoints too.

Command Line Interface (CLI)

To help with wrangling with our data on the command line, including doing batch requests trivially, you can try out our IPinfo CLI.

The CLI allows you to look up IP details in bulk or one-by-one, summarize the details of up to 1000 IPs at a time, open a map of IP locations for any set of IPs, filter IPv4 & IPv6 addresses from any input, print out IP lists for any CIDR or IP range, and much more.

See installation instructions for details on how to get setup.