Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
ip-geolocation-api-javascript-sdk
Advanced tools
[Javascript SDK for IP Geolocation API](https://ipgeolocation.io/documentation/ip-geolocation-api-javascript-sdk-201809051421). You can use this SDK to Geolocate an IP address and get time zone information based on geolocation coordinates, or an IP addres
IPGeolocation API is the solution to identify country code (ISO2 and ISO3 standard), country name, continent code, continent name, country capital, state/province, district, city, zip code, latitude and longitude of city, is country belongs to Europian Union, calling code, top level domain (TLD), languages, country flag, internet service provider (ISP), connection type, organization, geoname ID, currency code, currency name, time zone ID, time zone offset, current time in the time zone, is time zone in daylight saving time, and total daylight savings. This document provides important information to help you get up to speed with IPGeolocation API using IP Geolocation API Javascript SDK.
Developers can use this Javascript SDK for software and web projects related to, but not limited to:
You need a valid 'IPGeolocation API key' to use this SDK. Sign up here and get your free API key if you don't have one.
Note: Complete documentation to use this SDK is also available at IP Geolocation API JavaScript SDK Documentation.
Internet connection is required to run this component.
$ npm install ip-geolocation-api-javascript-sdk
Use the following URL to visit documentation https://ipgeolocation.io/documentation.html
var IPGeolocationAPI = require('ip-geolocation-api-javascript-sdk');
// Create IPGeolocationAPI object. Constructor takes two parameters.
// 1) API key (Optional: To authenticate your requests through "Request Origin", you can skip it.)
// 2) Async (Optional: It is used to toggle "async" mode in the requests. By default, it is true.)
var ipgeolocationApi = new IPGeolocationAPI("YOUR_API_KEY", false);
// Function to handle response from IP Geolocation API
function handleResponse(json) {
console.log(json);
}
var GeolocationParams = require('ip-geolocation-api-javascript-sdk/GeolocationParams.js');
// Get complete geolocation for the calling machine's IP address
ipgeolocationApi.getGeolocation(handleResponse);
// Get complete geolocation in Russian** for IP address (1.1.1.1)
var geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1');
geolocationParams.setLang('ru');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
// Get custom geolocation (only "geo, time_zone and currency" fields/objects) for an IP address (1.1.1.1)
var geolocationParams = new GeolocationParams();
geolocationParams.setIPAddress('1.1.1.1');
geolocationParams.setFields('geo,time_zone,currency');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
// Exclude fields/obejects from complete geolocation in Italian language
var geolocationParams = new GeolocationParams();
geolocationParams.setExcludes('continent_name,country_code3,time_zone');
geolocationParams.setLang('it');
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
// Query geolocation in German** for multiple IP addresses and all fields
var geolocationParams = new GeolocationParams();
geolocationParams.setLang('de');
geolocationParams.setIPAddresses(['1.1.1.1', '2.2.2.2', '3.3.3.3']);
ipgeolocationApi.getGeolocation(handleResponse, geolocationParams);
// Specify the required fields/objects for multiple IP addresses
var geolocationParams = new GeolocationParams();
geolocationParams.setIPAddresses(['1.1.1.1', '2.2.2.2', '3.3.3.3']);
geolocationParams.setFields('geo');
ipgeolocationApi.getGeolocation(geolocationParams, geoResponse);
var TimezoneParams = require('ip-geolocation-api-javascript-sdk/TimezoneParams.js');
// Get time zone information by time zone ID
var timezoneParams = new TimezoneParams();
timezoneParams.setTimezone('America/Los_Angeles');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
// Get time zone information by latitude and longitude of the location
var timezoneParams = new TimezoneParams();
timezoneParams.setCoordinates('37.1838139', '-123.8105225');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
// Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
var timezoneParams = new TimezoneParams();
timezoneParams.setIPAddress('1.1.1.1');
ipgeolocationApi.getTimezone(handleResponse, timezoneParams);
// Query time zone information for calling machine's IP address
ipgeolocationApi.getTimezone(handleResponse);
// Get user agent information for single user agent string
ipgeolocationApi.getUserAgent(handleResponse, "AppleTV6,2/11.1");
// Get user agents information in bulk by providing array of user agent strings
const uaStrings = ["AppleTV6,2/11.1", "Roku4640X/DVP-7.70 (297.70E04154A)", "Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU"];
ipgeolocationApi.getBulkUserAgent(handleResponse, uaStrings);
** IPGeolocation provides geolocation information in the following languages:
By default, geolocation information is returned in English. Response in a language other than English is available to paid users only.
FAQs
[Javascript SDK for IP Geolocation API](https://ipgeolocation.io/documentation/ip-geolocation-api-javascript-sdk-201809051421). You can use this SDK to Geolocate an IP address and get time zone information based on geolocation coordinates, or an IP addres
The npm package ip-geolocation-api-javascript-sdk receives a total of 334 weekly downloads. As such, ip-geolocation-api-javascript-sdk popularity was classified as not popular.
We found that ip-geolocation-api-javascript-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.