geoLocation
    • PDF

    geoLocation

    • PDF

    Article summary

    Available in Classic and VPC

    Specify an IP address to retrieve geolocation information.

    Request

    The following describes the request format for the endpoint. The request format is as follows:

    MethodURI
    GET/geoLocation

    Request headers

    For headers common to GeoLocation APIs, see GeoLocation request headers.

    Request query parameters

    The following describes the parameters.

    FieldTypeRequiredDescription
    ipStringRequiredIP of the user whose geolocation you want to know
    extStringOptionalWhether to include additional information
    • t | f (default)
      • t: include
      • f: not include
    encStringOptionalEncoding type of the response result
    • utf8 (default) | euckr
    responseFormatTypeStringOptionalFormat of the response result
    • xml (default) | json

    Request example

    The following is a sample request.

    curl --location --request GET 'https://geolocation.apigw.ntruss.com/geolocation/v2/geoLocation
    ?ip=**.**.**.**
    &ext=t
    &enc=utf8
    &responseFormatType=json'
    --header 'x-ncp-apigw-timestamp: {Timestamp}'
    --header 'x-ncp-iam-access-key: {Access Key}'
    --header 'x-ncp-apigw-signature-v2: {API Gateway Signature}'
    

    Response

    The following describes the response format.

    Response body

    The following describes the response body.

    FieldTypeRequiredDescription
    requestIdStringRequiredAPI request ID
    returnCodeStringRequiredNormal code is 0, and the others are error codes
    countryStringRequiredCountry code corresponding to the IP address
    • Compliant with ISO 3166 standards
    • It includes EU (Europe), AP (Asia, Australia), A1 (Anonymous Proxy), A2 (Satellite provider), and O1 (other countries)
    codeStringRequiredAdministrative region codes defined by the Ministry of the Interior and Safety of the Republic of Korea
    r1StringRequiredDo, metropolitan city, state
    r2StringRequiredSi, gun, gu
    r3StringOptionalDong, myeon, eup
    latNumberOptionalLatitude
    longNumberOptionalLongitude
    netStringOptionalNetwork provider name

    Response status codes

    The following describes the response status codes. For response status codes common to NAVER Cloud Platform, see Ncloud API response status codes.

    HTTP status codeCodeMessageDescription
    400131000No EntryUnable to find geolocation information for the requested IP address
    • Solution: query using another IP
    400131001Invalid IPNon-public IP or invalid IP address format
    400131002Internal Server ErrorGeoLocation server error
    • Solution: Try again after a while, or contact Support if the issue persists
    400131003Quota Limit ReachedExceeded the API call limit set by the user
    • Solution: Change the limit by increasing the quota in the Services > Application Services > GeoLocation > Quota Setting menu of the NAVER Cloud Platform console
    400131004Subscription RequiredGeoLocation service subscription required
    • Solution: Subscribe to the GeoLocation service from the Services > Application Services > GeoLocation > Subscription menu of the NAVER Cloud Platform console

    Response example

    The following is a sample response.

    • If domestic, ext=f, responseFormatType=xml
    <?xml version="1.0" encoding="utf-8"?>
    <getLocationResponse>
        <returnCode>0</returnCode>
        <requestId>c4e52003-****-****-****-66c93acfd0d2</requestId>
        <geoLocation>
            <country>KR</country>
            <code>41135*****</code>
            <r1>Gyeonggi-do</r1>
            <r2>Bundang-gu, Seongnam-si</r2>
        </geoLocation>
    </getLocationResponse>
    
    • If domestic, ext=f, responseFormatType=json
    {
        "returnCode": 0,
        "requestId": "c4e52003-****-****-****-66c93acfd0d2",
        "geoLocation": {
            "country": "KR",
            "code": "41135*****",
            "r1": "Gyeonggi-do",
            "r2": "Bundang-gu, Seongnam-si",
        }
    }
    
    • If overseas, ext=f, responseFormatType=xml
    <?xml version="1.0" encoding="utf-8"?>
    <getLocationResponse>
        <returnCode>0</returnCode>
        <requestId>c4e52003-****-****-****-66c93acfd0d2</requestId>
        <geoLocation>
            <country>US</country>
            <code></code>
            <r1>California</r1>
            <r2>San Francisco</r2>
        </geoLocation>
    </getLocationResponse>
    
    • If overseas, ext=f, responseFormatType=json
    {
        "returnCode": 0,
        "requestId": "c4e52003-****-****-****-66c93acfd0d2",
        "geoLocation": {
            "country": "US",
            "code": "",
            "r1": "California",
            "r2": "San Francisco",
        }
    }
    
    • If domestic, ext=t, responseFormatType=xml
    <?xml version="1.0" encoding="utf-8"?>
    <getLocationResponse>
        <returnCode>0</returnCode>
        <requestId>c4e52003-****-****-****-66c93acfd0d2</requestId>
        <geoLocation>
            <country>KR</country>
            <code>41135*****</code>
            <r1>Gyeonggi-do</r1>
            <r2>Bundang-gu, Seongnam-si</r2>
            <r3>Jeongja-dong</r3>
            <lat>**.268***</lat>
            <long>**.030***</long>
            <net>Korea Telecom</net>
        </geoLocation>
    </getLocationResponse>
    
    • If domestic, ext=t, responseFormatType=json
    {
        "returnCode": 0,
        "requestId": "c4e52003-****-****-****-66c93acfd0d2",
        "geoLocation": {
            "country": "KR",
            "code": "41135*****",
            "r1": "Gyeonggi-do",
            "r2": "Bundang-gu, Seongnam-si",
            "r3": "Jeongja-dong",
            "lat": **.268***,
            "long": **.030***,
            "net": "Korea Telecom"
        }
    }
    
    • If overseas, ext=t, responseFormatType=xml
    <?xml version="1.0" encoding="utf-8"?>
    <getLocationResponse>
        <returnCode>0</returnCode>
        <requestId>c4e52003-****-****-****-66c93acfd0d2</requestId>    
        <geoLocation>
            <country>US</country>
            <code></code>
            <r1>California</r1>
            <r2>San Francisco</r2>
            <r3></r3>
            <lat>**.769***</lat>
            <long>-***.393***</long>
            <net>Fastly</net>
        </geoLocation>
    </getLocationResponse>
    
    • If overseas, ext=t, responseFormatType=xml
    {
        "returnCode": 0,
        "requestId": "c4e52003-****-****-****-66c93acfd0d2",
        "geoLocation": {
            "country": "US",
            "code": "",
            "r1": "California",
            "r2": "San Francisco",
            "r3": "",
            "lat": **.769***,
            "long": -***.393***,
            "net": "Fastly"
        }
    }
    

    Example

    You can download the GeoLocation example file to test the GeoLocation API or use it as an example.


    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.