admin管理员组

文章数量:1026989

I would like to collect all info which can be fetched from user without ask any permissions. I don't want to use any of non-free ip info services and Geolocation

What I have now:

timeZoneOffset = new Date().getTimezoneOffset();
userLang = navigator.language || navigator.userLanguage;

But I want more info about users location.

I would like to collect all info which can be fetched from user without ask any permissions. I don't want to use any of non-free ip info services and Geolocation

What I have now:

timeZoneOffset = new Date().getTimezoneOffset();
userLang = navigator.language || navigator.userLanguage;

But I want more info about users location.

Share Improve this question asked Sep 17, 2020 at 13:58 Aleksandr_AAleksandr_A 3506 silver badges14 bronze badges 1
  • 1 That is not possible You can try this one for more accurate timezone for free stackoverflow./a/63915192/295783 – mplungjan Commented Sep 17, 2020 at 14:02
Add a ment  | 

3 Answers 3

Reset to default 3

Solution 1: The HTML Geolocation API is used to get the geographical position of a user.

  • But it asked user for permission.

Solution 2: Free IP Location API

Check this: https://ipdata.co/

$.getJSON('https://geolocation-db./json/')
         .done (function(location) {
            $('#country').html(location.country_name);
            $('#state').html(location.state);
            $('#city').html(location.city);
            $('#latitude').html(location.latitude);
            $('#longitude').html(location.longitude);
            $('#ip').html(location.IPv4);
});

Solution 3: PAID IP based API

There is no other solution for this.

The other answers mention paid services (ipdata) or free services without the data you need - timezone, etc - (geolocation-db.)

I believe Abstract has a free plan for their IP geolocation API that includes timezone data among others: https://www.abstractapi./ip-geolocation-api

$.getJSON("https://ipgeolocation.abstractapi./v1/?api_key=****************", function(data) {
       console.log(data.ip_address);
       console.log(data.country);
       console.log(data.timezone);
   })

You can use BigDataCloud's IP Geolocation API to get maximum data from the IP address of your website visitor.

It provides 10K queries per month for free.

https://www.bigdatacloud./ip-geolocation-apis/ip-address-geolocation-api

Output data:

{
    "ip": "73.231.131.73",
    "localityLanguageRequested": "en",
    "isReachableGlobally": true,
    "country": {
        "isoAlpha2": "US",
        "isoAlpha3": "USA",
        "m49Code": 840,
        "name": "United States of America",
        "isoName": "United States of America (the)",
        "isoNameFull": "the United States of America",
        "isoAdminLanguages": [
            {
                "isoAlpha3": "eng",
                "isoAlpha2": "en",
                "isoName": "English",
                "nativeName": "English"
            }
        ],
        "unRegion": "Americas/Northern America",
        "currency": {
            "numericCode": 840,
            "code": "USD",
            "name": "US Dollar",
            "minorUnits": 2
        },
        "wbRegion": {
            "id": "NAC",
            "iso2Code": "XU",
            "value": "North America"
        },
        "wbIneLevel": {
            "id": "HIC",
            "iso2Code": "XD",
            "value": "High ine"
        },
        "callingCode": "1",
        "countryFlagEmoji": "

I would like to collect all info which can be fetched from user without ask any permissions. I don't want to use any of non-free ip info services and Geolocation

What I have now:

timeZoneOffset = new Date().getTimezoneOffset();
userLang = navigator.language || navigator.userLanguage;

But I want more info about users location.

I would like to collect all info which can be fetched from user without ask any permissions. I don't want to use any of non-free ip info services and Geolocation

What I have now:

timeZoneOffset = new Date().getTimezoneOffset();
userLang = navigator.language || navigator.userLanguage;

But I want more info about users location.

Share Improve this question asked Sep 17, 2020 at 13:58 Aleksandr_AAleksandr_A 3506 silver badges14 bronze badges 1
  • 1 That is not possible You can try this one for more accurate timezone for free stackoverflow./a/63915192/295783 – mplungjan Commented Sep 17, 2020 at 14:02
Add a ment  | 

3 Answers 3

Reset to default 3

Solution 1: The HTML Geolocation API is used to get the geographical position of a user.

  • But it asked user for permission.

Solution 2: Free IP Location API

Check this: https://ipdata.co/

$.getJSON('https://geolocation-db./json/')
         .done (function(location) {
            $('#country').html(location.country_name);
            $('#state').html(location.state);
            $('#city').html(location.city);
            $('#latitude').html(location.latitude);
            $('#longitude').html(location.longitude);
            $('#ip').html(location.IPv4);
});

Solution 3: PAID IP based API

There is no other solution for this.

The other answers mention paid services (ipdata) or free services without the data you need - timezone, etc - (geolocation-db.)

I believe Abstract has a free plan for their IP geolocation API that includes timezone data among others: https://www.abstractapi./ip-geolocation-api

$.getJSON("https://ipgeolocation.abstractapi./v1/?api_key=****************", function(data) {
       console.log(data.ip_address);
       console.log(data.country);
       console.log(data.timezone);
   })

You can use BigDataCloud's IP Geolocation API to get maximum data from the IP address of your website visitor.

It provides 10K queries per month for free.

https://www.bigdatacloud./ip-geolocation-apis/ip-address-geolocation-api

Output data:

{
    "ip": "73.231.131.73",
    "localityLanguageRequested": "en",
    "isReachableGlobally": true,
    "country": {
        "isoAlpha2": "US",
        "isoAlpha3": "USA",
        "m49Code": 840,
        "name": "United States of America",
        "isoName": "United States of America (the)",
        "isoNameFull": "the United States of America",
        "isoAdminLanguages": [
            {
                "isoAlpha3": "eng",
                "isoAlpha2": "en",
                "isoName": "English",
                "nativeName": "English"
            }
        ],
        "unRegion": "Americas/Northern America",
        "currency": {
            "numericCode": 840,
            "code": "USD",
            "name": "US Dollar",
            "minorUnits": 2
        },
        "wbRegion": {
            "id": "NAC",
            "iso2Code": "XU",
            "value": "North America"
        },
        "wbIneLevel": {
            "id": "HIC",
            "iso2Code": "XD",
            "value": "High ine"
        },
        "callingCode": "1",
        "countryFlagEmoji": "

本文标签: Javascript get users location(countrylangtimezone)Stack Overflow