Webservice Extras
The geoPlugin webservice extras builds on the base webservices and are always being added to, based on your ideas and requests.
If you have any request for a webservice extras, please let us know and we'll do what we can to incorporate it.
Much of these data are provided by geonames and are provided under the Creative Commons 4.0 license. Use of these data we provide mean you agree to abide by the CC4 license.
Latitude/Longitude to Place
Not only can geoPlugin provide you with geolocation of IP addresses, but we can also reverse geocode any given latitude and longitude coordinates to a place.
This reverse geocoding allows you to specify the latitude and longitude coordinates and will output the nearest populated place in PHP, JSON, XML, or CSV formats.
To reverse geocode a latitude/longitude coordinate pair, simply call:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
replace XXX and YYY with the latitude and longitude values, respectively.
If no lat/lon values are provided, lookup is based on the referring IP.
If you wish to reverse geocode an IP to place, use:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
If no populated place is found within a 10-mile radius of your given coordinates, the server will return null
The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:
For PHP:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
For JSON:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
For XML:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
The location of 17.3724/78.4378 (you) is:
Place: Hyderabad
Country Code: IN
Region: Telangana
Latitude: 17.3840500
Longitude: 78.4563600
Distance (miles): 1.46
Distance (km): 2.36
Place to Latitude/Longitude
Rather than reverse geocoding of latitude/longitude to place, geoPlugin can forward geocode a place to it's latitude longitude coordinates.
This forward geocoding allows you to specify the place and the country to output the lat/lon values (and more) in PHP, JSON, XML, or CSV formats.
To forward geocode a place to a latitude/longitude coordinate pair, simply call:
http://www.geoplugin.net/extras/forward_place.gp?place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
the 'place' GET variable is an ASCII-encoded place name that is URL-encoded the 'country' GET variable is a two-letter ISO 3166 country code - see https://www.geoplugin.com/iso3166
The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:
For PHP:
http://www.geoplugin.net/extras/forward_place.gp?format=php&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
For JSON:
http://www.geoplugin.net/extras/forward_place.gp?format=php&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
For XML:
http://www.geoplugin.net/extras/forward_place.gp?format=php&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
Forward geocoding your place (Hyderabad, IN) gives:
1:
geoplugin_latitude: 17.3840500
geoplugin_longitude: 78.4563600
geoplugin_place: Hyderabad
geoplugin_region: Telangana
geoplugin_regionCode: 40
geoplugin_countryCode: IN
Nearby Places
Rather than give you the exact nearest populated place to a set of latitude/logitude coordinates, geoPlugin can reverse geocode an IP or latitude and longitude values to provide you with any number of populated places nearby.
As with the base webservices, with the exception of Javascript (use JSON for that), places nearby can be output in PHP, JSON, or XML to suite your needs.
To find places nearby a geographical location starting from an IP address, simply call:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
replace x.x.x.x with a valid IP address.
To find places nearby a geographical location starting from Latitude/Longitude values, simply call:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
replace XXX and YYY with the latitude and longitude values, respectively.
If no latitude or longitude values are set, then the lat/long values from PHP's $_SERVER['REMOTE_ADDR'] will be used, which may not be desirable
You can specify how many results to return by tagging on the limit variable eg
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
to return a maximum of 10 results
Additionally, you can specify the radius (in miles) of the search for nearby places, by tagging on the radius variable eg
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
to return all nearby populated places within 50 miles of the given point.
The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:
For PHP:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
For JSON:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
For XML:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
Nearby places to you include
1:
Place: Hyderabad
Region: Telangana
Latitude: 17.3840500
Longitude: 78.4563600
Distance (miles): 1.46
Distance (km): 2.36
Direction (degrees) 9.52
Direction (heading)
2:
Place: Haidar Sāhibgūda
Region: Telangana
Latitude: 17.3672700
Longitude: 78.3916200
Distance (miles): 3.07
Distance (km): 4.93
Direction (degrees) 142
Direction (heading) SE
3:
Place: Mailārdevpalli
Region: Andhra Pradesh
Latitude: 17.3188700
Longitude: 78.4503300
Distance (miles): 3.79
Distance (km): 6.1
Direction (degrees) 179.46
Direction (heading) S
4:
Place: Barkas
Region: Andhra Pradesh
Latitude: 17.3181500
Longitude: 78.4832400
Distance (miles): 4.8
Distance (km): 7.72
Direction (degrees) 178.11
Direction (heading) S
5:
Place: Gaddi Annaram
Region: Telangana
Latitude: 17.3668700
Longitude: 78.5242000
Distance (miles): 5.71
Distance (km): 9.19
Direction (degrees) 127.64
Direction (heading) SE
Nearest Transport
A new addition to the reverse geocoding extras is the ability to find the nearest transport hub to an IP or lat/lon coordinates.
We have thousands of main airport hubs in our database and for Europe, many thousands of train stations. For the rest of the world, we have train stations, but this isn't complete. If you know of a train station database for your country, drop us a line and we'll try add it.
As with the base webservices, with the exception of Javascript (use JSON for that), places nearby can be output in PHP, JSON, or XML to suite your needs. To find the nearest transport hub to a an IP address, simply call:
To find the nearest transport hub to a an IP address, simply call:
http://www.geoplugin.net/extras/transport.gp?ip=x.x.x.x
replace x.x.x.x with a valid IP address. If no IP is given, the requesting IP is used like for all API requests.
To find the nearest transport hub to starting from Latitude/Longitude values, simply call:
http://www.geoplugin.net/extras/transport.gp?lat=XXX&lon=YYY
replace XXX and YYY with the latitude and longitude values, respectively.
The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:
For PHP:
http://www.geoplugin.net/extras/transport.gp?ip=x.x.x.x&format=php http://www.geoplugin.net/extras/transport.gp?lat=XXX&lon=YYY&format=php
For JSON:
http://www.geoplugin.net/extras/transport.gp?ip=x.x.x.x&format=json http://www.geoplugin.net/extras/transport.gp?lat=XXX&lon=YYY&format=json
For XML:
http://www.geoplugin.net/extras/transport.gp?ip=x.x.x.x&format=xml http://www.geoplugin.net/extras/transport.gp?lat=XXX&lon=YYY&format=xml
By default, only airports are returned (for which we have the most data).
If you want other transport hubs, tag on the type request variable as such:
“type” options:
- type=airport (Airports: Default)
- type=station (Stations)
- type=port (Maritime ports)
- type=all (All the above from nearest to furthest)
example:
http://www.geoplugin.net/extras/transport.gp?ip=x.x.x.x&format=json&type=station
For default airports, the top 5 results for you would be:
Nearest Airports to you include:
1:
geoplugin_type: airport
geoplugin_name: Rajiv Gandhi International Airport
geoplugin_city: Hyderabad
geoplugin_country: India
geoplugin_countryCode: IN
geoplugin_IATA: HYD
geoplugin_ICAO: VOHS
geoplugin_latitude: 17.2313175
geoplugin_longitude: 78.4298553
geoplugin_distanceMiles: 9.76
geoplugin_distanceKilometers: 15.71
geoplugin_directionAngle: 179.85
geoplugin_directionHeading: S
2:
geoplugin_type: airport
geoplugin_name: Nanded Airport
geoplugin_city: Nanded
geoplugin_country: India
geoplugin_countryCode: IN
geoplugin_IATA: NDC
geoplugin_ICAO: VAND
geoplugin_latitude: 19.1833000
geoplugin_longitude: 77.3167038
geoplugin_distanceMiles: 145.13
geoplugin_distanceKilometers: 233.56
geoplugin_directionAngle: 62.68
geoplugin_directionHeading: ENE
3:
geoplugin_type: airport
geoplugin_name: Murod Kond Airport
geoplugin_city: Latur
geoplugin_country: India
geoplugin_countryCode: IN
geoplugin_IATA: LTU
geoplugin_ICAO: VALT
geoplugin_latitude: 18.4115010
geoplugin_longitude: 76.4646990
geoplugin_distanceMiles: 148.27
geoplugin_distanceKilometers: 238.61
geoplugin_directionAngle: 115.23
geoplugin_directionHeading: ESE
4:
geoplugin_type: airport
geoplugin_name: Vijayawada Airport
geoplugin_city:
geoplugin_country: India
geoplugin_countryCode: IN
geoplugin_IATA: VGA
geoplugin_ICAO: VOBZ
geoplugin_latitude: 16.5303993
geoplugin_longitude: 80.7967987
geoplugin_distanceMiles: 166.4
geoplugin_distanceKilometers: 267.79
geoplugin_directionAngle: 49.36
geoplugin_directionHeading: NE
5:
geoplugin_type: airport
geoplugin_name: Kadapa Airport
geoplugin_city: Kadapa
geoplugin_country: India
geoplugin_countryCode: IN
geoplugin_IATA: CDP
geoplugin_ICAO: VOCP
geoplugin_latitude: 14.5100000
geoplugin_longitude: 78.7727780
geoplugin_distanceMiles: 199.01
geoplugin_distanceKilometers: 320.28
geoplugin_directionAngle: 154.88
geoplugin_directionHeading: SSE
Latitude/Longitude to Postal Code
The reverse geocoding of a latitude/longitude coordinate pair to populated place given above uses a database of many millions of geospatial coordinates and is very well developed, especially for developed countries.
However, because of copyright and cost issues, we cannot provide postal codes (zip codes) for all of these places.
Nonetheless, we can provide reverse geocoding of latitude/longitude coordinate pairs to postal codes for about a million of these locations.
This post code web service can be accessed using:
http://www.geoplugin.net/extras/location.gp?lat=XXX&lon=YYY
To provide the nearest populated place with a post code within a 10-mile radius of your given coordinates.
Like always, the format= variable can be appended to specify PHP, JSON, or XML outputs.
The closest place with a post code we have on file for 17.3724/78.4378 (you) is:
Place: Attapur
Country Code: IN
Post Code: 756045
Latitude: 17.3686008
Longitude: 78.4356003
Distance (miles): 0.3
Distance (km): 0.48
Confidence: 4
Postal Code to Latitude/Longitude
Rather than reverse geocoding of latitude/longitude to a Postal Code, geoPlugin can forward geocode a postcode to it's latitude longitude coordinates.
This forward geocoding allows you to specify the postcode and the country to output the lat/lon values (and more) in PHP, JSON, XML, or CSV formats.
To forward geocode a postcode to a latitude/longitude coordinate pair, simply call:
http://www.geoplugin.net/extras/forward_postcode.gp?place={URL-Encoded Postcode}&country={ISO 3166 2-letter Country Code}
the 'postcode' GET variable is a URL-encoded postcode
the 'country' GET variable is a two-letter ISO 3166 country code - see https://www.geoplugin.com/iso3166
The default output is a PHP serialized array.
You can change the output by tagging on the format request variable as such:
For PHP:
http://www.geoplugin.net/extras/forward_place.gp?format=php&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
For JSON:
http://www.geoplugin.net/extras/forward_place.gp?format=json&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
For XML:
http://www.geoplugin.net/extras/forward_place.gp?format=xml&place={URL-Encoded-ASCII-Place}&country={ISO 3166 2-letter Country Code}
Place: Attapur
Country Code: IN
Post Code: 756045
Latitude: 17.3686008
Longitude: 78.4356003
Distance (miles): 0.3
Distance (km): 0.48
Confidence: 4
EU Cookie Law
If you or your organization are based in the European Union, or your website is intended for people located inside the European Union, and your website uses cookies, you are required by European law to inform your European visitors that your site uses cookies and require their consent before setting any cookies.
This is the so-called new “EU cookie law”.
If your visitor is outside the European Union, you are not required to ask for consent prior to setting cookies.
Use the CookieLaw geoPlugin Javascript extra to determine if your visitor is required to consent to setting cookies (ie the visitor comes from one of the 27 European countries).
The output from cookielaw.js is a Javascript function providing a Boolean true/false response allowing you to decide whether you need to ask permission from your visitor (true) or not (false) to set cookies.
<script src="http://www.geoplugin.net/extras/cookielaw.js" type="text/javascript"></script>
the output for you is:
function geoplugin_cookieConsent () { return 'false'; }
GDPR
The General Data Protection Regulation (GDPR) (EU) is a regulation in EU law on data protection and privacy for all individuals within the European Union (EU) and the European Economic Area (EEA).
The GDPR contains provisions and requirements pertaining to the processing of personally identifiable information of individuals inside the European Union, and applies to all enterprises, regardless of location, that are doing business with the European Economic Area.
A processor of personal data must clearly disclose any data collection, declare the lawful basis and purpose for data processing, how long data is being retained, and if it is being shared with any third-parties or outside of the EU. This is outlined in our Privacy Policy and User agreement that you abide to by using any of geoPlugin's web services.
All main geoPlugin IP geolocation webservices identify whether the person is protected by GDPR by the variable geoplugin_inEU. If the value is 1, then you must apply the EU GDPR protection rule. If the value is 0, then the visitor is outside the EU and GDPR does not apply.
For example,
calling the Javascript IP geolocation webservice, the result for you is:
function geoplugin_inEU () { return '0'; }
calling the JSON IP geolocation webservice,, the result for you is:
"geoplugin_inEU":0,
calling the PHP IP geolocation webservice, the result for you is:
'geoplugin_inEU' => 0,
EU VAT Rate
European acts in the field of taxation have to be adopted by unanimity. The current provisions on VAT rates are thus the result of different compromises agreed by all the EU Ministers of Finance.
The VAT Directive sets the framework for the VAT rates in the EU, but it gives national governments freedom to set the number and level of rates they choose, but are to be applied as the standard rate for all goods and services.
If you are an EU business, doing business with an EU client, you must apply the VAT rate of the country your client resides in, not your country.
At geoPlugin, we help you determine what that rate is by specifying the General VAT rate (specified as a percentage) of your visitor's country
All main geoPlugin IP geolocation webservices identify whether the person is in the EU by the variable geoplugin_inEU.
If the value is 1, then the variable geoplugin_euVATrate tells you the %VAT that is required on any purchases for that person.
If the client is not in the EU, then the value of geoplugin_euVATrate is false.
calling the Javascript IP geolocation webservice,, the result for you is:
function geoplugin_inEU () { return '0'; }
function geoplugin_euVATrate () { return 'undefined'; }
calling the JSON IP geolocation webservice, the result for you is:
"geoplugin_inEU":0,
"geoplugin_euVATrate":undefined,
calling the PHP IP geolocation webservice, the result for you is:
'geoplugin_inEU' => 0,
'geoplugin_euVATrate' => undefined,
and so on for XML, ASP and CSV webservices.