Identifying country by IP address

前端 未结 13 984
盖世英雄少女心
盖世英雄少女心 2020-12-01 05:24

Is there a way to figure out the country name just by looking at an IP address? I mean, do countries have specific ranges of IP addresses? For example, Australia can have IP

13条回答
  •  -上瘾入骨i
    2020-12-01 05:49

    You could use ipdata.co to perform the lookup

    This answer uses a 'test' API Key that is very limited and only meant for testing a few calls. Signup for your own Free API Key and get up to 1500 requests daily for development.

    curl https://api.ipdata.co/23.221.76.66?api-key=test
    

    Ipdata has 10 endpoints globally each able to handle >10,000 requests per second!

    Gives

    {
        "ip": "23.221.76.66",
        "city": "Cambridge",
        "region": "Massachusetts",
        "region_code": "MA",
        "country_name": "United States",
        "country_code": "US",
        "continent_name": "North America",
        "continent_code": "NA",
        "latitude": 42.3626,
        "longitude": -71.0843,
        "asn": "AS20940",
        "organisation": "Akamai International B.V.",
        "postal": "02142",
        "calling_code": "1",
        "flag": "https://ipdata.co/flags/us.png",
        "emoji_flag": "\ud83c\uddfa\ud83c\uddf8",
        "emoji_unicode": "U+1F1FA U+1F1F8",
        "is_eu": false,
        "languages": [
            {
                "name": "English",
                "native": "English"
            }
        ],
        "currency": {
            "name": "US Dollar",
            "code": "USD",
            "symbol": "$",
            "native": "$",
            "plural": "US dollars"
        },
        "time_zone": {
            "name": "America/New_York",
            "abbr": "EDT",
            "offset": "-0400",
            "is_dst": true,
            "current_time": "2018-04-19T06:32:30.690963-04:00"
        },
        "threat": {
            "is_tor": false,
            "is_proxy": false,
            "is_anonymous": false,
            "is_known_attacker": false,
            "is_known_abuser": false,
            "is_threat": false,
            "is_bogon": false
        }
    }⏎ 
    

提交回复
热议问题