Geo location as a script.

Provide customized content to your users based on their geographic location, using a fast and globally distributed JavaScript file and API.

index.html
package.json
<script defer src="https://js.instantgeo.info"></script>
<script>
document.addEventListener('geojs-loaded', () => {
console.log(geojs.country) // US
});
</script>

Why InstantGeo?

InstantGeo is a performance first GeoIP service that comes at a reasonably low price and a high level of accuracy.

Lightweight

The amount of JS we ship is less than 1KB uncompressed, with gzip compression it's even smaller

Blazing Fast

InstantGeo is distributed across 275+ edge locations, your users will be served from the nearest edge server

Quick Setup

No configuration needed apart from adding the script to your pages

Reasonable Subscription

We offer the most competitive prices in the market. Our prices are as low as our latency is.

We Grow boundlessly to match your requirements.

19,235,130+

requests served in last 24 hours

Pricing

The right price for your business

Growth

$4.99/month

For small businesses and personal projects

  • Up to 500k requests per month
  • 1 site per subscription
  • Email support

Business

$60/month

For businesses and growing projects

  • Unlimited number of requests*
  • Unlimited sites
  • 12/7 Email support
  • Slack support (vis Slack Connect)
* Fair usage policy of 30M requests per month apply

Need more?

We offer custom plans for teams and enterprises. Get in touch with us to learn more.
support@instantgeo.info

Introduction

InstantGeo is a service that provides geolocation information about the current user using a lightweight javascript file. any page that has the script tag in the DOM will have access to a global geojs object containing at-least the following information

Loading JSON...

instantgeo is currently not available on NPM and doesn't support self hosting, it must be included on the page using the https://js.instantgeo.info URI.

Loading Synchronously

If you have any content above the fold that relies on geo location information to render, you can load the script synchronously, please bear in mind that it might have some negligible performance impact on your site.

<script src="https://js.instantgeo.info"></script>

After the placement of this script or in DOMContentLoaded event you can inspect the geojs globally available object to see the available information.

console.log(geojs)
{
    "longitude": "xxx",
    "latitude": "xxx",
    "continent": "XX",
    "country": "XX",
    "timezone": "Xxx/Xxx",
    "city": "xxx",
    "region": "xxx",
    "regionCode": "XX",
    "asOrganization": "xxx",
    "postalCode": "xxx"
}

If the geolocation information is not render critical to your app, you can load the script asynchronously that it will have little to no impact on your page load performance, and you can bind an event to the document to execute a function as soon as the geolocation information is available.

<!-- Load the script tag with either defer or async attribute -->
<script defer src="https://js.instantgeo.info"></script>

<!-- Wait for the `geojs-loaded` event before using the global `geojs` variable  -->
<script>
    document.addEventListener('geojs-loaded', function(){
        console.log(geojs);
    })
</script>

Using as JSON endpoint

If you don't need the geolocation information to be available globally and only want to fetch it on-demand, you can use the /json endpoint, see example below

async function getGeoLocatinInfo() {
    const response = await fetch('https://js.instantgeo.info/json');
    return await response.json();
}

The /json endpoint cannot be used on server-side as it will return the information about the server's IP address.