ip2Country
ip2Country Tools
These tools are simply a wrapper for MaxMind’s GeoLite IP Database. It allows for you query the database with a given IP address, and find out the country in which it is located. Though not 100% accurate, it does give a relevant result for most IP addresses.
Key Features
- Easy to use: Nearly no programming knowledge is required to use this at it’s most basic form, i.e. to show a user which country they are in.
- Various Outputs: We can offer multiple types of output for the country, these include simple the full Country Name, the 2 letter ISO Country Code, or a redirect to a flag icon.
Example Usage
Here are just a few simple applications of the tools provided, and these can be expanded significantly to suit your needs.
Request Syntax
Any request is made using the following syntax:
http://ip2country.leefindlow.com/api.php?ip={IP_ADDRESS}&q={REQUEST}
- {IP_ADDRESS} denotes the IP address.
- {REQUEST} denotes the type of request being made (explained below).
The IP Variable is optional, and can be left blank, if done so it will be assumed that the IP address is that of the server/client performing the request.
Country Name Request
This query will simply return the full country name, or in the event that the country could not be detected it will output “Unable to resolve IP.”. The following syntax is used:
http://ip2country.leefindlow.com/api.php?q=ip2cn&ip={IP_ADDRESS}
Country Code Request
This allows for you to request the 2 letter ISO standard country code of the location of an IP address, and works in basically the same way as a Country Name request, with the same error messages. The following syntax is used:
http://ip2country.leefindlow.com/api.php?q=ip2cn&ip={IP_ADDRESS}
Flag Request
This function returns a visual representation of the country a user is from, in the form of a Flag image, 22px wide and a variable height. This is ideal if you wish to place a small icon on your web page, you request this as follows:
http://ip2country.leefindlow.com/api.php?q=ip2flag&ip={IP_ADDRESS}
This will then automatically redirect the users browser to the image, allowing for seamless integration.