ip2country
Version, currently 0.1.34 versions
- 0.1.5latestMay 22, 2020
- 0.1.4not indexedMay 22, 2020
- 0.1.3not indexedMay 22, 2020
- 0.1.2not indexedMay 22, 2020
github.com/confact/ip2country
IP(v4) address to country name converter for Crystal
Nothing has been indexed for 0.1.3 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
ip2country:
github: confact/ip2country
version: ~> 0.1.3Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.3. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
IP2Country
IP(v4) address to country name converter for Crystal.
Installation
Add this to your application's shard.yml:
dependencies:
ip2country:
github: arcage/ip2country
Usage
require "ip2country"
# Create a converter object.
ip2country = IP2Country.new
# Country name lookup by IP address string.
ip2country.lookup("8.8.8.8", "en") # => "United States"
ip2country.lookup("8.8.8.8", "fr") # => "États-Unis"
ip2country.lookup("8.8.8.8", "es") # => "Estados Unidos"
ip2country.lookup("8.8.8.8", "de") # => "Vereinigte Staaten"
ip2country.lookup("8.8.8.8", "ja") # => "アメリカ合衆国"
ip2country.lookup("8.8.8.8", "zh") # => "美国"
ip2country.lookup("8.8.8.8", "ko") # => "미국"
ip2country.lookup("8.8.8.8") # => "United States"(English is default)
# You can specify the default language.
ip2country = IP2Country.new("ja")
ip2country.lookup("8.8.8.8") # => "アメリカ合衆国"
# Get a hash of country names in all supported languages
ip2country.lookup_all("8.8.8.8")
# => {"de" => "Vereinigte Staaten", "en" => "United States", "es" => "Estados Unidos", "fr" => "États-Unis", "ja" => "アメリカ合衆国", "ko" => "미국", "pt" => "Estados Unidos", "zh" => "美国"}
At the first time you use, this library will fetch some conversion tables, and cache them. This may take a while.
When you want to update cache of tables, you can call IP2Country.cache_update explicitly.
Notice: You should not call it every time you use this library.
Special thanks
This library uses conversion tables(ISO 3166-1 alpha-2 country codes to country names) provided by umpirsky/country-list © Saša Stamenković umpirsky@gmail.com(license is here).
It supports many kinds of file formats(CSV, JSON, YAML, etc...) and many kinds of languages.
I sincerely respect this great work.
Contributors
- arcage ʕ·ᴥ·ʔAKJ - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.3- Tagged
- May 22, 2020
- Commit
7b49b68b9746- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/confact/ip2country
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 4