Classic/VPC 환경에서 이용 가능합니다.
IP 주소를 지정하여 지리적 위치 정보를 검색합니다.
요청
요청 형식을 설명합니다. 요청 형식은 다음과 같습니다.
| 메서드 | URI |
|---|---|
| GET | /geolocation/v2/geoLocation |
요청 헤더
GeoLocation API에서 공통으로 사용하는 헤더에 대한 정보는 GeoLocation 요청 헤더를 참조해 주십시오.
요청 쿼리 파라미터
요청 쿼리 파라미터에 대한 설명은 다음과 같습니다.
| 필드 | 타입 | 필수 여부 | 설명 |
|---|---|---|---|
ip |
String | Required | 지역 정보를 알고자 하는 사용자 IP
|
ext |
String | Optional | 추가 정보 포함 여부
|
enc |
String | Optional | 응답 결과의 인코딩 방식
|
responseFormatType |
String | Optional | 응답 결과의 형식
|
요청 예시
요청 예시는 다음과 같습니다.
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}'
응답
응답 형식을 설명합니다.
응답 바디
응답 바디에 대한 설명은 다음과 같습니다.
| 필드 | 타입 | 필수 여부 | 설명 |
|---|---|---|---|
returnCode |
String | - | 정상 코드는 0, 이외는 오류 코드 |
requestId |
String | - | API 요청 ID |
country |
String | - | IP 주소에 해당하는 국가 코드
|
code |
String | - | 대한민국 행정안전부에서 정의한 행정 구역 코드 |
r1 |
String | - | 도, 광역시, 주 |
r2 |
String | - | 시, 군, 구 |
r3 |
String | - | 동, 면, 읍 |
lat |
Number | - | 위도 |
long |
Number | - | 경도 |
net |
String | - | 통신사 이름 |
응답 상태 코드
GeoLocation API에서 공통으로 사용하는 응답 상태 코드에 대한 정보는 GeoLocation 응답 상태 코드를 참조해 주십시오.
응답 예시
응답 예시는 다음과 같습니다.
- 국내,
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>
- 국내,
ext=f,responseFormatType=json일 때
{
"returnCode": 0,
"requestId": "c4e52003-****-****-****-66c93acfd0d2",
"geoLocation": {
"country": "KR",
"code": "41135*****",
"r1": "경기도",
"r2": "성남시 분당구",
}
}
- 해외,
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>
- 해외,
ext=f,responseFormatType=json일 때
{
"returnCode": 0,
"requestId": "c4e52003-****-****-****-66c93acfd0d2",
"geoLocation": {
"country": "US",
"code": "",
"r1": "California",
"r2": "San Francisco",
}
}
- 국내,
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>
- 국내,
ext=t,responseFormatType=json일 때
{
"returnCode": 0,
"requestId": "c4e52003-****-****-****-66c93acfd0d2",
"geoLocation": {
"country": "KR",
"code": "41135*****",
"r1": "경기도",
"r2": "성남시 분당구",
"r3": "정자동",
"lat": **.268***,
"long": **.030***,
"net": "Korea Telecom"
}
}
- 해외,
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>
- 해외,
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"
}
}
예제
GeoLocation 예제 파일을 다운로드하여 GeoLocation API를 테스트하거나 예시로 활용할 수 있습니다.