C Library
PHP Module
Perl Module
Ruby Library
Python Library
Apache Module
Nginx Module
Node.js Module
Cocoa / Objective C Library
Pascal Library
D Library
Go Package
Erlang Module
Haskell Package
Debian Package
Lua Package
Kotlin Module
Scala Library
OpenResty Package
Splunk Add-on
Apache Kafka Transform
OCaml Module
Deno Module
R Package
.NET Component
Java Component
HTTP Module
ActiveX / COM DLL
IP2Location IP Geolocation OCaml Module
This IP Geolocation package is the OCaml module to support all IP2Location™ database products. It has been optimized for speed and memory utilization. Developers can use the module to query all IP2Location™ binary databases for applications written using the OCaml programming language.
opam install ip2location
open Printf
open Ip2location
(* query IP2Location BIN datababase *)
let meta = Database.open_db "/path_to_your_database_file/your_BIN_file.BIN";;
let ip = "8.8.8.8";;
let res = Database.query meta ip;;
printf "country_short: %s\n" res.country_short;;
printf "country_long: %s\n" res.country_long;;
printf "region: %s\n" res.region;;
printf "city: %s\n" res.city;;
printf "isp: %s\n" res.isp;;
printf "latitude: %f\n" res.latitude;;
printf "longitude: %f\n" res.longitude;;
printf "domain: %s\n" res.domain;;
printf "zip_code: %s\n" res.zip_code;;
printf "time_zone: %s\n" res.time_zone;;
printf "net_speed: %s\n" res.net_speed;;
printf "idd_code: %s\n" res.idd_code;;
printf "area_code: %s\n" res.area_code;;
printf "weather_station_code: %s\n" res.weather_station_code;;
printf "weather_station_name: %s\n" res.weather_station_name;;
printf "mcc: %s\n" res.mcc;;
printf "mnc: %s\n" res.mnc;;
printf "mobile_brand: %s\n" res.mobile_brand;;
printf "elevation: %f\n" res.elevation;;
printf "usage_type: %s\n" res.usage_type;;
printf "address_type: %s\n" res.address_type;;
printf "category: %s\n" res.category;;
printf "district: %s\n" res.district;;
printf "asn: %s\n" res.asn;;
printf "as: %s\n" res.asys;;
Database.close_db meta;;
Discover Your User Locations
Retrieve geolocation data for FREE now!