geoLocation

Prev Next

요청

API URL

GET https://geolocation.apigw.gov-ntruss.com/geolocation/v2/geoLocation

요청 헤더

헤더명 설명
x-ncp-apigw-timestamp 1970년 1월 1일 00:00:00 협정 세계시(UTC)부터의 경과 시간을 밀리초(millisecond)로 나타내며 APIGW 서버와 시간차가 5분 이상 나는 경우 유효하지 않은 요청으로 간주
x-ncp-apigw-timestamp:{Timestamp}
x-ncp-iam-access-key 네이버 클라우드 플랫폼 포털에서 발급받은 Access Key ID 값
x-ncp-iam-access-key:{Sub Account Access Key}
x-ncp-apigw-signature-v2 Access Key ID 값 과 Secret Key 로 암호화한 서명
x-ncp-apigw-signature-v2:{API Gateway Signature}

요청 파라미터

파라미터명 필수 여부 타입 제약사항 설명
ip Y String IPv4 주소 - 위키백과 지역 정보를 알고자 하는 사용자 IP
enc N String utf8(기본값) 또는 euckr 응답 결과 인코딩 타입
ext N String t 또는 f(기본값) 추가 정보 포함 여부
t : 포함
f : 비포함
responseFormatType N String xml(기본값) 또는 json 응답 결과의 포맷 타입

응답

항목 타입 설명
requestId String API 요청 ID
returnCode String 정상 Code는 0, 이외 에러코드
contry String 국가코드로서 https://en.wikipedia.org/wiki/ISO_3166
외에 EU(유럽), AP(아시아, 호주), A1(Anonymous Proxy), A2(Satellite provider), O1(Other Country)를 포함
code String 한국의 경우에 행정자치부에서 정하는 행정구역 코드를 나타냄
r1 String 도, 광역시, 주
r2 String 시, 군, 구
r3 String 동, 면, 읍
lat Number 위도
long Number 경도
net String 통신사 이름

예시

응답 예시

  • 국내, ext=f, xml
<getLocationResponse>
     <requestId>c4e52003-7879-4216-8eb5-66c93acfd0d2</requestId>
     <returnCode>0</returnCode>
     <geoLocation>
       <country>KR</country>
       <code>4113558000</code>
       <r1>경기도</r1>
       <r2>성남시 분당구</r2>
     </geoLocation>
</getLocationResponse>
  • 국내, ext=f, json
{
	"returnCode": 0,
	"requestId": "c4e52003-7879-4216-8eb5-66c93acfd0d2",
	"geoLocation": {
		"country": "KR",
		"code": "4113558000",
		"r1": "경기도",
		"r2": "성남시 분당구"
	}
}
  • 해외, ext=f, xml
<getLocationResponse>
     <requestId>c4e52003-7879-4216-8eb5-66c93acfd0d2</requestId>
     <returnCode>0</returnCode>
     <geoLocation>
       <country>US</country>
       <code/>
       <r1>California</r1>
       <r2>San Francisco</r2>
     </geoLocation>
</getLocationResponse>
  • 해외, ext=f, json
{
	"returnCode": 0,
	"requestId": "c4e52003-7879-4216-8eb5-66c93acfd0d2",
	"geoLocation": {
		"country": "US",
		"code": "",
		"r1": "California",
		"r2": "San Francisco"
	}
}
  • 국내, ext=t, xml
<getLocationResponse>
     <requestId>c4e52003-7879-4216-8eb5-66c93acfd0d2</requestId>
     <returnCode>0</returnCode>
     <geoLocation>
       <country>KR</country>
       <code>4113558000</code>
       <r1>경기도</r1>
       <r2>성남시 분당구</r2>
       <r3>서현1동</r3>
       <lat>37.3829030</lat>
       <long>127.126290</long>
       <net>Korea Net</net>
     </geoLocation>
</getLocationResponse>
  • 국내, ext=t, json
{
	"returnCode": 0,
	"requestId": "c4e52003-7879-4216-8eb5-66c93acfd0d2",
	"geoLocation": {
		"country": "KR",
		"code": "4113558000",
		"r1": "경기도",
		"r2": "성남시 분당구",
        "r3": "서현1동",
        "lat": 37.3829030,
        "long": 127.126290,
        "net": "Korea Net"
	}
}
  • 해외, ext=t, xml
<getLocationResponse>
     <requestId>c4e52003-7879-4216-8eb5-66c93acfd0d2</requestId>
     <returnCode>0</returnCode>
     <geoLocation>
       <country>US</country>
       <code/>
       <r1>California</r1>
       <r2>San Francisco</r2>
       <r3></r3>
       <lat>37.769700</lat>
       <long>-122.393300</long>
       <net>Fastly</net>
     </geoLocation>
</getLocationResponse>
  • 해외, ext=t, json
{
	"returnCode": 0,
	"requestId": "c4e52003-7879-4216-8eb5-66c93acfd0d2",
	"geoLocation": {
		"country": "US",
		"code": "",
		"r1": "California",
		"r2": "San Francisco",
        "r3": "",
        "lat": 37.769700,
        "long": -122.393300,
        "net": "Fastly"
	}
}

오류 코드

오류 코드 응답 메세지 설명
131000 No Entry 지역정보를 찾을 수 없는 경우에 발생합니다. 다른 IP를 이용해서 조회하세요.
131001 Invalid IP 공인 IP가 아닌 경우거나 IP 주소 형식이 잘못된 경우에 발생합니다. 정상적인 IP 주소 형식은 IPv4 - 위키백과를 참고하세요.
131002 Internal Server Error GeoLocation 서버의 오류로 발생합니다. 일시적이 아닌 경우에는 고객지원 > 문의하기를 통해 문의하세요.
131003 Quota Limit Reached 설정한 Quota 한도만큼 API가 사용되었습니다. 네이버 클라우드 플랫폼 콘솔 > Application Services > GeoLocation > Quota Setting 메뉴에서 Quota를 변경할 수 있습니다.
131004 Subscription Required 네이버 클라우드 플랫폼 콘솔 > Application Services > GeoLocation > Subscription 메뉴에서 이용신청한 후에 사용하세요.

이 외의 코드값에 대해서는 NAVER Cloud Platform API 사용 가이드 > 오류 처리하기를 참조하세요.

예제 파일