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"]' "api.ip.cc/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 @- "api.ip.cc/batch?token=$TOKEN"


Or,


cat urlList | curl -XPOST --data-binary @- "api.ip.cc/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 @- "api.ip.cc/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 @- "api.ip.cc/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.


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"]' "api.ip.cc/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 @- "api.ip.cc/batch?token=$TOKEN"


Or,


cat urlList | curl -XPOST --data-binary @- "api.ip.cc/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 @- "api.ip.cc/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 @- "api.ip.cc/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.