geoip-shell icon indicating copy to clipboard operation
geoip-shell copied to clipboard

Feature Request: Integrate IPinfo Lite for distributable IP db, and support for country and ASN filtering

Open abdullahdevrel opened this issue 5 months ago • 11 comments

I work for IPinfo, I think our free IPinfo Lite DB is the perfect database this project.

  • It is updated daily, with zero compromise to accuracy. There is no range clustering, and the database provides full accuracy.
  • It includes country and ASN information in the same database.
  • The data granularity reaches individual IP level.
  • It is licensed under CC-BY-SA 4.0, permitting commercial usage, redistribution, and repackaging.
  • Available file formats include: CSV, MMDB, JSON and Parquet
  • The data is tabular and unnested, making it very easy to use. The dataset includes both IPv4 and IPv6 in a single file.

Database schema

Field Name Example Data Type Descrption
network 154.24.39.204/30 TEXT CIDR/IP range or single IP address
country Canada TEXT Country name
country_code CA TEXT Two-letter ISO 3166 country code of the IP addresses
continent North America TEXT Continent name of the IP location
continent_code NA TEXT Two-letter continent code of the IP location
asn AS174 TEXT Autonomous System Number, an organization that owns the IP range block
as_name Cogent Communications TEXT Name of the AS (Autonomous System Number) organization
as_domain cogentco.com TEXT Official domain or website of the ASN organization

Documentation: https://ipinfo.io/developers/ipinfo-lite-database

Samples: https://github.com/ipinfo/sample-database/tree/main/IPinfo%20Lite

The IP database can be simply downloaded with only an free access token:

curl -L https://ipinfo.io/data/ipinfo_lite.csv.gz?token=$TOKEN -o ipinfo_lite.csv.gz

We also have a free IPinfo Lite API service based on this database that supports unlimited requests. Let me know what you think. Thanks!

abdullahdevrel avatar Jul 06 '25 08:07 abdullahdevrel

Hi, thank you for the feature request. I will look into adding support for IPinfo.

friendly-bits avatar Jul 06 '25 23:07 friendly-bits

It appears that in order to download the database, a token is required. Which, I assume, is received upon registering on your website? Do you require a unique token for every user, or can I hard-code one token which would then be included in geoip-shell source code and provided to all geoip-shell users (also publicly accessible, since this is an open-source project)?

Also looking at your API, I couldn't find any way to request a database for specific country codes. So looks like the only way to get data for specific country codes is by downloading the complete database and then processing it?

friendly-bits avatar Jul 19 '25 13:07 friendly-bits

Hi @friendly-bits,

Thank you for reviewing my request.

It appears that in order to download the database, a token is required. Which, I assume, is received upon registering on your website?

Yes. You need to sign up for an IPinfo account to get your own IPinfo access token. You need that access token to download the IPinfo Lite database or start using the IPinfo Lite API service.

Do you require a unique token for every user, or can I hard-code one token which would then be included in geoip-shell source code and provided to all geoip-shell users (also publicly accessible, since this is an open-source project)?

You should do the latter. You can incorporate a project-specific IPinfo Access token that all your users can use. Individual users do not need to sign up for our service and use their own IPinfo access token; they can just use the project-specific access token.

Also looking at your API, I couldn't find any way to request a database for specific country codes. So looks like the only way to get data for specific country codes is by downloading the complete database and then processing it?

That is correct. We do not support country code-based IP ranges downloads. Once you download the database, you can use grep to identify the ranges.

This article is a bit dated: https://community.ipinfo.io/t/getting-all-the-asns-of-a-country-using-our-free-ip-to-country-asn-database/5623

Essentially, you need to run something like this:

grep ",Saudi Arabia," ipinfo_lite.csv > saudi_arabia_ranges.csv

abdullahdevrel avatar Jul 19 '25 13:07 abdullahdevrel

Thank you for your response. Another question: does the 'Last-Modified' field in the HTTP header always correctly reflect the last modified time of the database? Essentially I need a way to know whether user's previously downloaded data is up-to-date or not.

Example:

$ wget -O - --max-redirect=10 --tries=3 --timeout=16 -S --method HEAD https://ipinfo.io/data/ipinfo_lite.csv.gz?token=<token>
Spider mode enabled. Check if remote file exists.
--2025-07-19 17:15:11--  https://ipinfo.io/data/ipinfo_lite.csv.gz?token=<token>
Resolving ipinfo.io (ipinfo.io)... 34.117.59.81
Connecting to ipinfo.io (ipinfo.io)|34.117.59.81|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 302 Found
...
Resolving dl.ipinfo.io (dl.ipinfo.io)... 34.160.152.12
Connecting to dl.ipinfo.io (dl.ipinfo.io)|34.160.152.12|:443... connected.
HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Content-Type: application/gzip
...
  Last-Modified: Sat, 19 Jul 2025 08:01:54 GMT

In this response, can I treat 19 Jul 2025 08:01:54 GMT as reliable timestamp of the database?

friendly-bits avatar Jul 19 '25 14:07 friendly-bits

Thank you @friendly-bits. I recommend using the checksum method to know when you need to update the database. We update our data daily though so anytime you update it, should be good.

https://community.ipinfo.io/t/using-checksums-to-find-data-downloads-updates/2555

Interesting discovery, though. We push our data to GCS, and I wonder if we can modify this metadata.

abdullahdevrel avatar Jul 19 '25 16:07 abdullahdevrel

Part of the principal design of geoip-shell is efficiency. For the matter of dowloads, this means that geoip-shell only fetches database update when there is an update. Every other source supported by geoip-shell provides a way to know database timestamp without downloading it. This is in best interest of users, as well as database providers. geoip-shell advertises timestamp-based update checks since day one of its existence and I am not going to change that now. So unfortunately, until there is a way to reliably get database timestamp without downloading the database, this feature request will not be implemented.

Getting the timestamp from the Last-Modified header field is recommended by MaxMind for their database. So I would suggest IPinfo to implement the same method. Perhaps it is already implemented and this just needs to be confirmed?

friendly-bits avatar Jul 19 '25 17:07 friendly-bits

Acknowledging the issues. We will look into what we can do to support the project. Thank you for the review.

abdullahdevrel avatar Jul 19 '25 19:07 abdullahdevrel

No problem. I will gladly add support for IPinfo as soon as there is a way to get the timestamp. Looks like the format is essentially the same as the one used by MaxMind, which is already supported, so all the parsing code is already in place and well tested. If providing the timestamp via the http header is too complicated, I can implement getting it via a request to an arbitrary URL on your website.

friendly-bits avatar Jul 19 '25 20:07 friendly-bits

Hi @friendly-bits

Unfortunately, I have some bad news and some explanation. Our engineering team decided not to make this particular GCS metadata transparent. Our engineering team considers the GCS metadata to be internal information. To make timestamp information transparent, engineering needs to provide it through a dedicated API endpoint, like we have for https://ipinfo.io/me.token=$token.

However, I think we are not going to make the timestamp information available right now. Please, understand our reasoning for it:

  • Checksums verification is something we recommend users do. We believe adding the comparison logic that I demonstrated to checksum checks also receives the signal that fresh data is available to be downloaded.
  • Unlike MaxMind and other IP geolocation providers, we do not do non-frequent or specific calendar day updates. MaxMind updates its free location database twice a week and its paid database only on weekdays. We update our free database every day (obviously including the weekends as well). So, telling users when the database will be updated is not a feature that is prioritized because of the nature of our service offering -- we update the data daily.

I hope you understand our position. I understand and respect your code architecture decisions, which are perfect and flawless for the data you have been using so far.

I hope you understand that our service philosophy is slightly different compared to the industry, as we provide full accuracy, active measurement-based data and a daily updated database that focuses on data integrity and verification through checksums. If you choose to integrate data, it will not be because to support just another IP geolocation provider out there, but rather for our superior data, community support and generous licensing terms.

Thank you. I hope you consider my request.

PS: Here is an article I wrote about what superior accuracy means: https://community.ipinfo.io/t/the-north-korean-gamers-on-steam-map/6857

abdullahdevrel avatar Jul 21 '25 16:07 abdullahdevrel

This is very surprising for me. I don't see why thousands of users need to calculate the same checksum at each update on their devices. I'll have to think whether this makes sense for geoip-shell.

friendly-bits avatar Jul 21 '25 18:07 friendly-bits

Unfortunately, this feature request will have to wait until there is a way to get the timestamp of the database without downloading the database. I think this is a reasonable requirement, widely implemented by data providers in the industry, and should not be too difficult to implement.

friendly-bits avatar Jul 23 '25 04:07 friendly-bits