Code Snippets

Code Snippets

The Code Snippets page provides practical examples and commands for leveraging IPinfo's data, services, and libraries.

Extract only IPv4 addresses using the IPinfo CLI from any text

-o stands for only and -4 is for IPv4.

cat ./acesss_logs | ipinfo grepip -o -4

Create an IPinfo summary report from IP addresseses

The command will return a link where your summary report will be available.

cat iplist.txt | curl -XPOST --data-binary @- "ipinfo.io/tools/summarize-ips?cli=1"

Create an IPinfo map from IP addresseses

The command will provide a link for your IPinfo map.

cat iplist.txt | curl -XPOST --data-binary @- "https://ipinfo.io/tools/map?cli=1"

Get a list of IPv4 prefixes owned by an ASN using JQ

curl "ipinfo.io/AS7922/json?token=$TOKEN" | jq -r '.prefixes[].netblock'