MaxMind
Support My Account FAQ My Order
Support My Account FAQ My Order

Apache Module
C
C# Class
Java Class
MS COM Object
Pascal
Perl Module
PHP Module
Python Class
Ruby Module
VB.Net
Support Center


GeoIP C API

Download
The open source GeoIP C API includes a free GeoLite Country database. The code is licensed under the LGPL. Download C API now.

A free geolocation database, GeoLite City, is also available.

Install
This API should work on most UNIX and GNU/Linux platforms and is thread-safe.
./configure
make
make check
make install
For installing on Windows, see the READMEwin32.txt file supplied with the distribution.

Usage
This following sample code looks up the country code by IP address:
#include <GeoIP.h>
int main (int argc, char *argv[]) {
  GeoIP * gi;
  gi = GeoIP_new(GEOIP_STANDARD);
  printf("code %s\n",
    GeoIP_country_code_by_name(gi, "yahoo.com"));
}
To compile this example, run gcc -lGeoIP example.c.

For additional examples, see test/test-geoip.c and apps/geoiplookup.c.

A FreeBSD Port is available from http://cvsweb.FreeBSD.org/ports/net/GeoIP/


MaxMind, GeoIP and related marks are registered trademarks of MaxMind, Inc.
Copyright © 2008 MaxMind, Inc. All Rights Reserved. Terms of use.