All Projects → delef → geoip2.cr

delef / geoip2.cr

Licence: MIT license
MaxMind GeoIP2 Reader for Crystal

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to geoip2.cr

locus
MMDB reader for geolocation and ASN lookup of IP addresses
Stars: ✭ 93 (+520%)
Mutual labels:  geoip2, maxmind-db
nodejs-geoip2ws
Maxmind GeoIP2 Web Services for Node.js
Stars: ✭ 47 (+213.33%)
Mutual labels:  geoip2
GeoIP2-CN
小巧精悍、准确、实用 GeoIP2 数据库
Stars: ✭ 3,965 (+26333.33%)
Mutual labels:  geoip2
mmdbwriter
Go library for writing MaxMind DB (mmdb) files
Stars: ✭ 44 (+193.33%)
Mutual labels:  geoip2
MaxMind-DB-Reader-java
Java reader for the MaxMind DB format
Stars: ✭ 88 (+486.67%)
Mutual labels:  geoip2
MaxMind-DB-Reader-python
Python MaxMind DB reader extension
Stars: ✭ 131 (+773.33%)
Mutual labels:  geoip2
Geolocator-2
Learn how to find and work with locations in Django, the Yelp API, and Google Maps api.
Stars: ✭ 24 (+60%)
Mutual labels:  geoip2
GeoIP2-perl
Perl API for MaxMind's GeoIP2 web services and databases
Stars: ✭ 18 (+20%)
Mutual labels:  geoip2
nginx-more
Development repository for nginx-more package
Stars: ✭ 96 (+540%)
Mutual labels:  geoip2
GeoIP2-ruby
Ruby API for GeoIP2 webservice client and database reader
Stars: ✭ 41 (+173.33%)
Mutual labels:  geoip2
geoip2
GeoIP2 Reader for Go
Stars: ✭ 54 (+260%)
Mutual labels:  geoip2
Geoip2 Php
PHP API for GeoIP2 webservice client and database reader
Stars: ✭ 1,956 (+12940%)
Mutual labels:  geoip2
geoip2-rs
Fast GeoIP2 Reader for Rust
Stars: ✭ 25 (+66.67%)
Mutual labels:  geoip2
MaxMind-DB-Reader-ruby
Ruby reader for the MaxMind DB Database Format
Stars: ✭ 35 (+133.33%)
Mutual labels:  geoip2
MaxMind-DB-Writer-perl
Create MaxMind DB database files
Stars: ✭ 63 (+320%)
Mutual labels:  geoip2
libvmod-geoip2
A Varnish VMOD to query MaxMind GeoIP2 DB files
Stars: ✭ 37 (+146.67%)
Mutual labels:  geoip2
lua-resty-maxminddb
A Lua library for reading MaxMind's Geolocation database
Stars: ✭ 72 (+380%)
Mutual labels:  maxmind-db
clickhouse-maxmind-geoip
A demonstration how to use ClickHouse with MaxMind GeoIP2 databases for geolocaiton
Stars: ✭ 82 (+446.67%)
Mutual labels:  maxmind-geoip2-api

GeoIP2.cr

Built with Crystal Build Status Releases

Pure Crystal GeoIP2 databases reader.

Installation

Add this to your application's shard.yml:

dependencies:
  geoip2:
    github: delef/geoip2.cr

Usage

Country Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoLite2-Country.mmdb")
record = reader.country("128.101.101.101")

record.country.iso_code # => "US"
record.country.in_european_union? # => false
record.country.name # => "United States"
record.country.names["de"] # => "USA"

record.continent.code # => "NA"
record.continent.name # => "North America"

record.registered_country.iso_code # => "US"
record.registered_country.name # => "United States"

City Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoLite2-City.mmdb", ["en", "ru", "de"])
record = reader.city("128.101.101.101")

record.city.geoname_id # => 5045360
record.city.name # => "Minneapolis"
record.city.names["ru"] # => "Миннеаполис"

record.country.iso_code # => "US"
record.country.in_european_union? # => false
record.country.name # => "United States"
record.country.names["de"] # => "USA"

record.continent.code # => "NA"
record.continent.name # => "North America"

record.location.accuracy_radius # => 20
record.location.latitude # => 44.9532
record.location.longitude # => -93.158
record.location.metro_code # => 613
record.location.time_zone # => "America/Chicago"

record.postal.code # => "55104"

record.registered_country.iso_code # => "US"
record.registered_country.name # => "United States"

record.subdivisions[0].iso_code # => "MN"
record.subdivisions[0].name # => "Minnesota"

Enterprise Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoIP2-Enterprise.mmdb")
record = reader.enterprise("128.101.101.101")

record.city.name # => "Minneapolis"
record.city.confidence # => 60

record.country.iso_code # => "US"
record.country.name # => "United States"
record.country.names["zh-CN"] # => "美国"
record.country.confidence # => 99

record.subdivisions[0].name # => "Minnesota"
record.subdivisions[0].iso_code # => "MN"
record.subdivisions[0].confidence # => 77

record.postal.code # => "55455"
record.postal.confidence # => "55455"

record.location.latitude # => 44.9733
record.location.longitude # => -93.2323
record.location.accuracy_radius # => 50

Anonymous IP Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoIP2-Anonymous-IP.mmdb")
record = reader.anonymous_ip("128.101.101.101")

record.anonymous? # => false
record.anonymous_vpn? # => false
record.hosting_provider? # => false
record.public_proxy? # => false
record.tor_exit_node? # => false
record.ip_address # => "128.101.101.101"

Connection-Type Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoIP2-Connection-Type.mmdb")
record = reader.connection_type("128.101.101.101")

record.connection_type # => "Corporate"
record.ip_address # => "128.101.101.101"

Domain Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoIP2-Domain.mmdb")
record = reader.domain("128.101.101.101")

record.domain # => "umn.edu"
record.ip_address # => "128.101.101.101"

ISP Example

require "geoip2"

reader = GeoIP2.open("/path/to/GeoIP2-ISP.mmdb")
record = reader.isp("128.101.101.101")

record.autonomous_system_number # => 217
record.autonomous_system_organization # => "University of Minnesota"
record.isp # => "University of Minnesota"
record.organization # => "University of Minnesota"
record.ip_address # => "128.101.101.101"

Links

Contributing

  1. Fork it ( https://github.com/delef/geoip2.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].