package maxminddb

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Maxmind is a binding to libmaxminddb with some higher level functionality on the OCaml side. Be aware that operations with the C side are liable to raise exceptions

type mmdb

Abstract type representing the C side pointer to a mmdb database in memory

type query_r = [
  1. | `String of string
  2. | `Int of int
  3. | `Float of float
  4. | `Bool of bool
]
val version : unit -> string

Get version string of Maxminddb

val create : path:string -> mmdb

Create a handle on a mmdb descriptor based off a .mmdb database file. Maxminddb comes with City, Country databases in etc

val close : mmdb -> unit

Close a handle on a mmdb descriptor, bad things will happen if you try to use the handle after you called closed on it.

val dump : ?ip:string -> mmdb -> string

Dumps the database as a string; if ip is provided then dumps the database for this particular ip address, if no ip provided then dumps Metainformation about the database itself. Note that you should do not depend on this structure: it is not JSON, just looks like it.

val lookup_path : ip:string -> query:string list -> mmdb -> query_r

For a given ip address, think 127.0.0.1, query path and mmdb handle, get the result. Note path must be safe, look at dump first

val postal_code : ip:string -> mmdb -> string

Short cut function for getting postal code from ip address

val with_mmdb : path:string -> (mmdb -> 'a) -> unit

Convenience function that opens and closes a mmdb for you

OCaml

Innovation. Community. Security.