MENU
      geoLocation

        geoLocation


        기사 요약

        Classic/VPC 환경에서 이용 가능합니다.

        IP 주소를 지정하여 지리적 위치 정보를 검색합니다.

        요청

        요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.

        메서드URI
        GET/geoLocation

        요청 헤더

        GeoLocation API에서 공통으로 사용하는 헤더에 대한 자세한 내용은 GeoLocation 요청 헤더를 참조해 주십시오.

        요청 쿼리 파라미터

        파라미터에 대한 설명은 다음과 같습니다.

        필드타입필수 여부설명
        ipStringRequired지역 정보를 알고자 하는 사용자 IP
        extStringOptional추가 정보 포함 여부
        • t | f (기본값)
          • t: 포함
          • f: 미포함
        encStringOptional응답 결과의 인코딩 방식
        • utf8 (기본값) | euckr
        responseFormatTypeStringOptional응답 결과의 형식
        • xml (기본값) | json

        요청 예시

        요청 예시는 다음과 같습니다.

        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}'
        Curl

        응답

        응답 형식을 설명합니다.

        응답 바디

        응답 바디에 대한 설명은 다음과 같습니다.

        필드타입필수 여부설명
        requestIdStringRequiredAPI 요청 ID
        returnCodeStringRequired정상 코드는 0, 이외는 오류 코드
        countryStringRequiredIP 주소에 해당하는 국가 코드
        • ISO 3166 표준 준수
        • EU (유럽), AP (아시아, 호주), A1 (Anonymous Proxy), A2 (Satellite Provider), O1 (Other Country) 포함
        codeStringRequired대한민국 행정안전부에서 정의한 행정 구역 코드
        r1StringRequired도, 광역시, 주
        r2StringRequired시, 군, 구
        r3StringOptional동, 면, 읍
        latNumberOptional위도
        longNumberOptional경도
        netStringOptional통신사 이름

        응답 상태 코드

        응답 상태 코드에 대한 설명은 다음과 같습니다. 네이버 클라우드 플랫폼에서 공통으로 사용하는 응답 상태 코드에 대한 자세한 내용은 Ncloud API 응답 상태 코드를 참조해 주십시오.

        HTTP 상태 코드코드메시지설명
        400131000No Entry요청한 IP 주소에 대한 지역 정보를 찾을 수 없음
        • 해결 방법: 다른 IP를 이용하여 조회
        400131001Invalid IP공인 IP가 아니거나 IP 주소 형식이 잘못됨
        400131002Internal Server ErrorGeoLocation 서버 오류
        • 해결 방법: 잠시 후 다시 시도하거나 문제가 지속될 경우에는 고객 지원으로 문의
        400131003Quota Limit Reached사용자가 설정한 API 호출 한도 초과
        • 해결 방법: 네이버 클라우드 플랫폼 콘솔의 Services > Application Services > GeoLocation > Quota Setting 메뉴에서 Quota를 늘려서 한도 변경
        400131004Subscription RequiredGeoLocation 서비스 이용 신청 필요
        • 해결 방법: 네이버 클라우드 플랫폼 콘솔의 Services > Application Services > GeoLocation > Subscription 메뉴에서 이용 신청

        응답 예시

        응답 예시는 다음과 같습니다.

        • 국내, 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>경기도</r1>
                <r2>성남시 분당구</r2>
            </geoLocation>
        </getLocationResponse>
        XML
        • 국내, ext=f, responseFormatType=json일 때
        {
            "returnCode": 0,
            "requestId": "c4e52003-****-****-****-66c93acfd0d2",
            "geoLocation": {
                "country": "KR",
                "code": "41135*****",
                "r1": "경기도",
                "r2": "성남시 분당구",
            }
        }
        JSON
        • 해외, 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>
        XML
        • 해외, ext=f, responseFormatType=json일 때
        {
            "returnCode": 0,
            "requestId": "c4e52003-****-****-****-66c93acfd0d2",
            "geoLocation": {
                "country": "US",
                "code": "",
                "r1": "California",
                "r2": "San Francisco",
            }
        }
        JSON
        • 국내, 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>경기도</r1>
                <r2>성남시 분당구</r2>
                <r3>정자동</r3>
                <lat>**.268***</lat>
                <long>**.030***</long>
                <net>Korea Telecom</net>
            </geoLocation>
        </getLocationResponse>
        XML
        • 국내, ext=t, responseFormatType=json일 때
        {
            "returnCode": 0,
            "requestId": "c4e52003-****-****-****-66c93acfd0d2",
            "geoLocation": {
                "country": "KR",
                "code": "41135*****",
                "r1": "경기도",
                "r2": "성남시 분당구",
                "r3": "정자동",
                "lat": **.268***,
                "long": **.030***,
                "net": "Korea Telecom"
            }
        }
        JSON
        • 해외, 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>
        XML
        • 해외, 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"
            }
        }
        JSON

        예제

        GeoLocation 예제 파일을 다운로드하여 GeoLocation API를 테스트하거나 예시로 활용할 수 있습니다.


        이 문서가 도움이 되었습니까?

        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.