geoPlugin Home

JSON Web Service

The JSON web service 1) allows you to directly program your back-end JSON scripts to deliver dynamic geo-localized pages using the JSON variables provided by geoPlugin.

To access this service, add the following url to a remote include call

Of course, substitute the xx's with your visitor's IP number.

Example output of a JSON query for your IP address ( is:

  "geoplugin_credit":"Some of the returned data includes GeoLite data created by MaxMind, available from http:\/\/<\/a>.",
  "geoplugin_countryName":"United States",


JSON Currency Converter

The variable “geoplugin_currencyConverter” is the conversion rate for the currency converter base currency.
Like all calls to any of geoPlugin's web services, the default base_currency is USD ($US).
Thus, if your base currency is NOT $US, then you must add the variable base_currency=XXX to the call to

Now geoplugin_currencyConverter will output the exchange rate of one Euro for your visitor.

The base_currency value must be a valid ISO 4217 3-letter code.

AJAX and Error: Invalid label

If you are using jQuery for example to do AJAX calls to the JSON webservice, you will probably be seeing the Javascript error Error: Invalid label

This is due to data requests from a server (geoPlugin) in a different domain (your web server). To eliminate this problem, JSONP or “JSON with padding” is required.
To return the JSON results as JSONP, tag jsoncallback=? onto the url when making the jQuery Ajax call to any JSON webservice

function (data) {
	for (var i in data) {
		document.write('data["i"] = ' + i + '<br/>');

An AJAX self-contained currency converter

Here is a working, extremely simple example of how to use the JSON service.
Here, we create a live AJAX currency converter, with little more than a few lines of HTML.

<script src=""></script>
<script src="" type="text/javascript"></script>
<script src=""></script>
<input type='text' id='gp_amount' size='4' /> 
<select id="gp_from"></select> 
<select id="gp_to"></select>
<p><input type='button' onClick='gp_convertIt()' value = 'Convert It' /></p>
<div id="gp_converted"></div>

which will output:

Convert to

See also

1) This product includes GeoLite data created by MaxMind, available from
Bookmark with:    Digg    StumbleUpon    Technorati

Acceptable Use Policy    Contact geoPlugin