Thursday, November 29, 2007

hostip.info - Using the Database - IP Address Lookup - Community Geotarget IP Addresses Project

Using the Database - IP Address Lookup - Community Geotarget IP Addresses Project

Simple GET
T hat said, there is an easy HTTP oriented API to locate IP addresses and Geocode them. If you don't supply the "?ip=aa.bb.cc.dd" bit, then the ip address lookup of the calling machine will be located instead (here, the aa,bb,cc,dd are decimal digits). If you add &position=true to the end of the URL then latitude and longitude will be returned also. Both HTML and XML formats are supplied for your convenience.

http://api.hostip.info/country.php
US


http://api.hostip.info/get_html.php?ip=12.215.42.19
Country: UNITED STATES (US)
City: Sugar Grove, IL


http://api.hostip.info/get_html.php?ip=12.215.42.19&position=true
Country: UNITED STATES (US)
City: Sugar Grove, IL
Latitude: 41.7696
Longitude: -88.4588


http://api.hostip.info/?ip=12.215.42.19

Country Flag
Paste the following code into your HTML to get a country flag of the ip address. The database is significantly more accurate (it ought to be 100%) for countries than for cities. It would be nice if y'all would make the flag a link to the www.hostip.info home page (http://www.hostip.info/) so they can come by if they're interested - it'll only benefit you in the long run. After all, the results get more accurate as more visitors submit their IP addresses!
Flag of visitor's location:

IP Address Lookup

Flag of any IP address:

IP Address Lookup


Embedded Applet
The following is designed to be embedded within another HTML page using the OBJECT tag. This will reproduce the zoom-in applet, (or an explanatory message with a link to fix, if the IP address lookup is unknown). Which means you can embed the applet in your own site without needing to have the local database and map data (which runs to a few gigabytes...) All you need do is include the OBJECT block below in your HTML. Note, you can also add "?ip=aaa.bbb.ccc.ddd" to the frame.html url below to map a specific IP address.
TYPE='text/html' BORDER=0
WIDTH=610 HEIGHT=330 HSPACE=0 VSPACE=0>



Commercial Geodatabase
MaxMind - If you're looking for a commercial option, this database maintains a great level of accuracy.