The official JQuery Library/SDK for IPGeolocation.io's set of APIs, provides a quick, developer friendly, way to access IP Location, threat intelligence, Timezone, Astronomy, ASN, Abuse Contact, and user-agent data. Lookup your own IP or provide any IPv4, IPv6 or domain name to get structured results in jquery, without the need for manual HTTP handling.
- IP Location API: Get all-in-one unified solution for location (city, locality, state, country, etc.), currency, network (AS number, ASN name, organization, asn type, date of allocation, company/ISP name, company type, company domain), timezone , useragent string parsing, security (threat score, is_tor, is_bot, proxy_provider, cloud_provider), and abuse contact (route/CIDR network, country, address, email, phone numbers) information.
- IP Security API: Get security, network, location, hostname, timezone and useragent parsing.
- ASN API: Get ASN details along with peers, upstreams, downstreams, routes, and raw WHOIS.
- Abuse Contact API: Get abuse emails, phone numbers, kind, organization, route/CIDR network and country.
- Astronomy API: Get sunrise, sunset, moonrise, moonset, moon phases with precise twilight period times in combination with location information.
- Timezone API: Get timezone name, multiple time formats, daylight saving status and its details along with location information.
- Timezone Convert API: Convert time between timezone names, geo coordinates, location addresses, IATA codes, ICAO codes, or UN/LOCODE.
- User Agent API: Get browser, Operating System, and device info from single or multiple Useragent string parsing.
This library aims to empower developers to integrate threat intelligence, personalization, fraud prevention, compliance, and analytics features directly into web based applications. Whether you're enriching signup forms with ip geolocation data, localizing content, embedding threat intelligence in back-end systems, or converting time zones and currencies, the library ensures seamless, scalable integration with IPGeolocation.io's global API infrastructure.
Based on:
- API version: 1.0
Important
We recommend using our Javascript SDK instead. That is based upon API v2.0.
Official Release:
- Available on
- Source Code: GitHub Repository
- Requirements
- Installation
- API Plan Tiers and Documentation
- Authentication Setup
- IP Geolocation Lookup Examples
- Time Zone API Lookup Examples
- User Agent API Lookup Examples
- Practical use case
- Supported Languages
- NPM or Yarm Package manager
- API Key from IPGeolocation.io
Add the following script in your HTML page:
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.4/ipgeolocation.min.js"></script>Note
This SDK is compatible with Vanilla JS and doesn't require JQuery as we have dropped the JQuery dependencies from v1.1.2 in this SDK.
The documentation below corresponds to the four available API tier plans:
- Developer Plan (Free): Full Documentation
- Standard Plan: Full Documentation
- Advance Plan: Full Documentation
- Security Plan: Full Documentation
For a detailed comparison of what each plan offers, visit the Pricing Page.
To authenticate API requests, you'll need an API key from ipgeolocation.io.
- Sign up here: https://app.ipgeolocation.io/signup
- (optional) Verify your email, if you signed up using email.
- Log in to your account: https://app.ipgeolocation.io/login
- After logging in, navigate to your Dashboard to find your API key: https://app.ipgeolocation.io/dashboard
Once you have the key, you can use it as follows:
function handleResponse(response) {
console.log(response);
}
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");You can use this SDK without an API key if you're using the Request Origin feaure on IP Geolocation API.
Here are a few different ways of querying Geolocation for an IP address from IP Geolocation API.
// Function to handle the response from IP Geolocation API.
// "response" is a JSON object returned from IP Geolocation API.
function handleResponse(response) {
console.log(response);
}
// Get geolocation for the calling machine's IP address with an API key (optional, if you're using "Request Origin" feature at IP Geolocation API)
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Don't pass the API key if you're using the "Request Origin" feature at IP Geolocation API
_ipgeolocation.getGeolocation(handleResponse);
// Toggle sessionStorage usage to store API response on client-side. (This is very handy as it will help users to avoid making duplicate API calls for a single visitor.)
_ipgeolocation.enableSessionStorage(true);
// Toggle API calls' async behavior. By default, async is true.
_ipgeolocation.makeAsyncCallsToAPI(false);
// Get geolocation for an IP address "1.1.1.1"
_ipgeolocation.setIPAddress("1.1.1.1");
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Get geolocation for an IP address "1.1.1.1" in Russian language **
_ipgeolocation.setLanguage("ru");
_ipgeolocation.setIPAddress("1.1.1.1");
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Get the specific geolocation fields "country_code2,time_zone,currency" for the calling machine's IP address
_ipgeolocation.setFields("geo,time_zone,currency");
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Get the specified geolocaiton fields like "country_code2,time_zone,currency" for an IP address "1.1.1.1" and skip the "ip" field in the response
_ipgeolocation.setFields("geo,time_zone,currency");
_ipgeolocation.setIPAddress("1.1.1.1");
_ipgeolocation.setExcludes("country_code2");
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
// Get geolocation along with hostname, security detail and user-agent detail.
_ipgeolocation.includeHostname(true);
_ipgeolocation.includeSecurity(true);
_ipgeolocation.includeUserAgent(true);
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");Here are a few examples to query Time Zone information from Timezone API.
// Function to handle the response from IP Geolocation API.
// "response" is a JSON object returned from IP Geolocation API.
function handleResponse(response) {
console.log(response);
}
// Get time zone information for the calling machine's IP address with an API key (optional, if you're using "Request Origin" feature at IP Geolocation API)
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
// Don't pass the API key if you're using the "Request Origin" feature at IP Geolocation API
_ipgeolocation.getTimezone(handleResponse);
// Toggle sessionStorage usage to store API response on client-side. (This is very handy as it will help users to avoid making duplicate API calls for a single visitor.)
_ipgeolocation.enableSessionStorage(true);
// Toggle API calls' async behavior. By default, async is true.
_ipgeolocation.makeAsyncCallsToAPI(false);
// Get time zone information for an IP address "1.1.1.1" and geolocation information in Italian language **
_ipgeolocation.setIPAddress("1.1.1.1");
_ipgeolocation.setLanguage("it");
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
// Get time zone infomration for a time zone "America/New_York"
_ipgeolocation.setTimeZone("America/Los_Angeles");
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
// Get time zone information by coordinates of the location
_ipgeolocation.setCoordinates("31.4816", "74.3551");
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");
// Get time zone information by location
_ipgeolocation.setLocation("Amman, Jordan");
_ipgeolocation.getTimezone(handleResponse, "YOUR_API_KEY");Here are a few examples to parse the user-agent information from User Agent API.
// Function to handle the response from IP Geolocation API.
// "response" is a JSON object returned from IP Geolocation API.
function handleResponse(response) {
console.log(response);
}
// Toggle sessionStorage usage to store API response on client-side. (This is very handy as it will help users to avoid making duplicate API calls for a single visitor.)
_ipgeolocation.enableSessionStorage(true);
// Toggle API calls' async behavior. By default, async is true.
_ipgeolocation.makeAsyncCallsToAPI(false);
// Get User Agent detail.
_ipgeolocation.getUserAgent(handleResponse, "YOUR_API_KEY");Here is a sample code to use IP Geolocation API using JQuery SDK:
<script src="https://cdn.jsdelivr.net/npm/ip-geolocation-api-jquery-sdk@1.1.4/ipgeolocation.min.js"></script>
<script>
// On call to IPGeolocation API on each page during a user's visit, API response will be served from sessionStorage after the first page.
_ipgeolocation.enableSessionStorage(true);
let ip = sessionStorage.getItem("ip");
let country_name = sessionStorage.getItem("country_name");
let country_code2 = sessionStorage.getItem("country_code2");
if (!ip || !country_name || !country_code2) {
_ipgeolocation.makeAsyncCallsToAPI(false);
_ipgeolocation.setFields("country_name,country_code2");
_ipgeolocation.getGeolocation(handleResponse, "YOUR_API_KEY");
}
function handleResponse(json) {
ip = json.ip;
country_name = json.country_name;
country_code2 = json.country_code2;
}
$(document).ready(function() {
alert("Hello " + country_name + "!");
});
</script>IPGeolocation provides geolocation information in the following languages:
- English (en)
- German (de)
- Russian (ru)
- Japanese (ja)
- French (fr)
- Chinese Simplified (cn)
- Spanish (es)
- Czech (cs)
- Italian (it)
By default, geolocation information is returned into English. Response in a language other than English is available to paid users only.