본문 바로가기
프로젝트 개발 일지/웹개발_백엔드

[Open API] OpenTripMap API 사용법

by ballbig 2024. 9. 25.
728x90

 

 

OpenTripMap

https://dev.opentripmap.org/docs

 

OpenTripMap API

OpenTripMap API Product Price Docs Map tiles Example Sign in Register English Your experience on this site will be improved by allowing cookies. Allow cookies

dev.opentripmap.org

 

 

도시 이름을 입력하여 도시의 위도,경도, 인구수 데이터 받아오기

 

https://api.opentripmap.com/0.1/en/places/geoname?name=seoul&country=kr&apikey=YOUR_API_KEY
  • 언어 코드 (lang): 두 글자의 언어 코드. en(미국) 또는 ru(러시아)만 지원된다....
  • 지명 (name): 도시/마을 명 ex) seoul
  • 국가 코드 (country): 두 글자의 ISO-3166 국가 코드
    • KRW (원) - 한국 : kr
    • USD (달러) - 미국 : us
    • EUR (유로)
      - 독일: de
      - 프랑스: fr
      - 이탈리아: it
      - 스페인: es
      - 포르투갈: pt
      - 네덜란드: nl
      - 벨기에: be
      - 오스트리아: at
      - 핀란드: fi
      - 그리스: gr
      - 아일랜드: ie
      - 룩셈부르크: lu
    • JPY (엔화) - 일본: JP
    • CNY (위안) - 중국: CN
    • GBP (파운드) - 영국: GB
    • CHF (스위스 프랑) - 스위스: CH
    • CAD (캐나다 달러) - 캐나다: CA
  • API 키 (apikey): 사이트에서 발급받은 API 키

응답 상세
{
    "name": "seoul",
    "country": "KR",
    "lat": 37.566, //위도
    "lon": 126.9784, //경도
    "population": 10349312, //인구수
    "timezone": "Asia/Seoul",
    "status": "OK"
}

 

 

bounding box내의 장소 조회하기

 

https://api.opentripmap.com/0.1/{lang}/places/bbox?lon_min={lon_min}&lon_max={lon_max}&lat_min={lat_min}&lat_max={lat_max}&apikey={API_KEY}

 

  • 필수 파라미터
    • lang:[string] 요청할 데이터의 언어. (en 또는 ru 사용 가능)
    • lon_min:[number] 조회할 지역의 최소 경도
    • lon_max:[number] 조회할 지역의 최대 경도
    • lat_min:[number] 조회할 지역의 최소 위도
    • lat_max:[number]  조회할 지역의 최대 위도
    • apikey:[string] OpenTripMap에서 발급받은 API 키

 

  • 선택적 파라미터:
    • src_geom: [string] 특정 소스의 geom 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
    • src_attr: [string] 특정 소스의 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
      *src는 default가 전체이다.
    • kinds: [string] 조회하려는 장소의 카테고리. 여러 카테고리는 쉼표로 구분할 수 있다. (default = interesting_places)
      *카테고리 참고 : https://dev.opentripmap.org/catalog
    • name: [string] 해당 이름으로 시작하는 객체들을 필터링하여 반환. 최소 3글자 이상. 해당 파라미터를 전달하지 않으면 이름과 상관없이 모든 객체가 반환된다.
    • rate: [string] 필터링할 최소 평점. 1~3. (* 문화유산의 경우 1h~3h)
    • format: [string] 응답 형식. (예: json, geojson, count)
    • limit: [int] 반환할 객체의 최대 개수 (default = 500개)

 

예제
더보기

[request]

특정 경계 상자 내의 관광지들 중 이름이 "Seoul"로 시작하는 장소들을 필터링하여 검색하기

https://api.opentripmap.com/0.1/en/places/bbox?lon_min=126.76&lon_max=127.18&lat_min=37.40&lat_max=37.65&name=seoul&src_geom=osm&kinds=historic,architecture&rate=2h&format=geojson&limit=10&apikey=5ae2e3f221c38a28845f05b685798510628f511af2b185d8b28ebcc1
  • 필수 파라미터
    • lang: en (응답 데이터를 영어로 받기 위해 경로에 지정).
    • lon_min: 126.76 (검색할 지역의 최소 경도).
    • lon_max: 127.18 (검색할 지역의 최대 경도).
    • lat_min: 37.40 (검색할 지역의 최소 위도).
    • lat_max: 37.65 (검색할 지역의 최대 위도).
    • apikey: YOUR_API_KEY (OpenTripMap에서 발급받은 API 키).
  • 선택 파라미터
    • name: seoul (이름이 "Seoul"로 시작하는 객체를 필터링).
    • src_geom: osm (객체의 지리 정보를 osm 데이터 소스에서만 가져옴).
    • kinds: historic,architecture (역사적 및 건축물 카테고리로 필터링).
    • rate: 2h (인기 평가가 2 이상이며 문화유산으로 지정된 객체를 필터링).
    • format: geojson (응답을 GeoJSON 형식으로 받음).
    • limit: 10 (최대 10개의 객체만 반환).

 

 

[response]

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "11284573",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9827576,
                    37.5948524
                ]
            },
            "properties": {
                "xid": "W54264684",
                "name": "Fortress Wall of Seoul",
                "rate": 7,
                "osm": "way/54264684",
                "wikidata": "Q5472741",
                "kinds": "fortifications,defensive_walls,historic,interesting_places"
            }
        },
        {
            "type": "Feature",
            "id": "11571108",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.968071,
                    37.5683594
                ]
            },
            "properties": {
                "xid": "W463189325",
                "name": "Seoul Gyeonggyojang House",
                "rate": 7,
                "osm": "way/463189325",
                "wikidata": "Q12583523",
                "kinds": "historic,archaeology,interesting_places,other_archaeological_sites"
            }
        },
        {
            "type": "Feature",
            "id": "11742570",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9907074,
                    37.5771904
                ]
            },
            "properties": {
                "xid": "N7276420192",
                "name": "SEOUL DONHWAMUN TRADITIONAL THEATER",
                "rate": 7,
                "osm": "node/7276420192",
                "wikidata": "Q16092829",
                "kinds": "fortifications,historic,interesting_places,other_fortifications"
            }
        }
    ]
}

 

 

특정 지점에서 가장 가까운 장소를 조회하기

 

https://api.opentripmap.com/0.1/{lang}/places/radius?radius={radius}&lon={lon}&lat={lat}&apikey={API_KEY}
  • 필수 파라미터
    • lang:[string] 요청할 데이터의 언어. (en 또는 ru 사용 가능)
    • radius:[number] 중심점으로부터 검색할 최대 거리 (미터 단위)
    • lon:[number] 조회할 중심점의 경도
    • lat:[number] 조회할 중심점의 위도
    • apikey:[string] OpenTripMap에서 발급받은 API 키

 

  • 선택적 파라미터 (앞선 API와 동일):
    • src_geom: [string] 특정 소스의 geom 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
    • src_attr: [string] 특정 소스의 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
      *src는 default가 전체이다.
    • kinds: [string] 조회하려는 장소의 카테고리. 여러 카테고리는 쉼표로 구분할 수 있다. (default = interesting_places)
      *카테고리 참고 : https://dev.opentripmap.org/catalog
    • name: [string] 해당 이름으로 시작하는 객체들을 필터링하여 반환. 최소 3글자 이상. 해당 파라미터를 전달하지 않으면 이름과 상관없이 모든 객체가 반환된다.
    • rate: [string] 필터링할 최소 평점. 1~3. (* 문화유산의 경우 1h~3h)
    • format: [string] 응답 형식. (예: json, geojson, count)
    • limit: [int] 반환할 객체의 최대 개수 (default = 500개)

 

예제
더보기

[request]

서울의 경도와 위도를 중심으로 반경 1000미터 내에서 관광지를 반환하는 예시:

https://api.opentripmap.com/0.1/en/places/radius?radius=1000&lon=126.9780&lat=37.5665&kinds=historic,architecture&rate=2h&limit=3&apikey=YOUR_API_KEY

 

  • radius=1000: 서울 중심에서 1000미터 반경 내의 객체를 검색.
  • lon=126.9780: 서울의 경도.
  • lat=37.5665: 서울의 위도.
  • kinds=historic,architecture: 역사적 건물 및 건축물 카테고리로 필터링.
  • rate=2h: 인기 등급 2 이상, 문화유산에 포함되는 객체만 검색.
  • limit=3: 최대 10개의 결과만 반환.

 

 

[response]

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "15370806",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9778214,
                    37.5664063
                ]
            },
            "properties": {
                "xid": "Q623908",
                "name": "Seoul City Hall",
                "dist": 18.88268149,
                "rate": 7,
                "wikidata": "Q623908",
                "kinds": "historic_architecture,architecture,interesting_places,other_buildings_and_structures"
            }
        },
        {
            "type": "Feature",
            "id": "14934103",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9755554,
                    37.5669441
                ]
            },
            "properties": {
                "xid": "Q12583799",
                "name": "경운궁 양이재",
                "dist": 221.52061994,
                "rate": 7,
                "wikidata": "Q12583799",
                "kinds": "palaces,architecture,historic_architecture,interesting_places"
            }
        },
        {
            "type": "Feature",
            "id": "15463894",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9755554,
                    37.5669441
                ]
            },
            "properties": {
                "xid": "Q28699481",
                "name": "대한성공회 서울주교좌성당 모자이크 제단화",
                "dist": 221.52061994,
                "rate": 7,
                "wikidata": "Q28699481",
                "kinds": "religion,other_temples,historic,cultural,urban_environment,monuments_and_memorials,interesting_places,sculptures,monuments"
            }
        }
    ]
}

 

 

 

주어진 검색어와 지정된 좌표를 중심으로 가까운 객체 자동 검색

 

https://api.opentripmap.com/0.1/{lang}/places/autosuggest?name={name}&radius={radius}&lon={lon}&lat={lat}&apikey={API_KEY}
  • 필수 파라미터
    • lang:[string] 요청할 데이터의 언어. (en 또는 ru 사용 가능)
    • name: [string] 검색할 최소 3자 이상의 검색어
    • radius:[number] 중심점으로부터 검색할 최대 거리 (미터 단위)
    • lon:[number] 조회할 중심점의 경도
    • lat:[number] 조회할 중심점의 위도
    • apikey:[string] OpenTripMap에서 발급받은 API 키

 

  • 선택적 파라미터 (앞선 API와 동일):
    • src_geom: [string] 특정 소스의 geom 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
    • src_attr: [string] 특정 소스의 객체만 필터링하려면 사용할 수 있다. (예: osm, wikidata, snow, cultura.ru, rosnedra)
      *src는 default가 전체이다.
    • kinds: [string] 조회하려는 장소의 카테고리. 여러 카테고리는 쉼표로 구분할 수 있다. (default = interesting_places)
      *카테고리 참고 : https://dev.opentripmap.org/catalog
    • rate: [string] 필터링할 최소 평점. 1~3. (* 문화유산의 경우 1h~3h)
    • format: [string] 응답 형식. (예: json, geojson, count)
    • props:[string] 개체 제목에서만 검색하려면 "base"를 지정하고(default) 개체 제목 및 주소에서도 검색하려면 "address"를 입력

 

예제
더보기

[request]

https://api.opentripmap.com/0.1/en/places/autosuggest?name=palace&radius=500&lon=126.9780&lat=37.5665&apikey=YOUR_API_KEY
  • name: 검색어와 일치하는 이름을 가진 객체가 반환됩니다.
  • radius: 지정된 반경 내에서 검색 결과가 반환됩니다.
  • kinds: 특정 카테고리(예: 역사적, 건축물 등)를 지정하여 필터링할 수 있습니다.
  • limit: 검색 결과의 최대 개수를 설정합니다.

 

 

 

[response]

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "id": "11334568",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.975174,
                    37.5661659
                ]
            },
            "properties": {
                "xid": "W26658458",
                "name": "Deoksugung Palace",
                "highlighted_name": "Deoksugung <b>Palace</b>",
                "dist": 252.71960179,
                "rate": 7,
                "osm": "way/26658458",
                "wikidata": "Q482631",
                "kinds": "palaces,architecture,historic_architecture,urban_environment,gardens_and_parks,cultural,interesting_places"
            }
        },
        {
            "type": "Feature",
            "id": "11338545",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9749756,
                    37.5661354
                ]
            },
            "properties": {
                "xid": "R10738081",
                "name": "Deoksugung (Palace)",
                "highlighted_name": "Deoksugung (<b>Palace</b>)",
                "dist": 270.45058632,
                "rate": 7,
                "osm": "relation/10738081",
                "wikidata": "Q482631",
                "kinds": "palaces,architecture,historic_architecture,interesting_places"
            }
        },
        {
            "type": "Feature",
            "id": "4604394",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    126.9747925,
                    37.5656128
                ]
            },
            "properties": {
                "xid": "N5018677421",
                "name": "Deoksugung Palace",
                "highlighted_name": "Deoksugung <b>Palace</b>",
                "dist": 299.94217578,
                "rate": 1,
                "osm": "node/5018677421",
                "kinds": "historic,monuments_and_memorials,interesting_places,monuments"
            }
        }
    ]
}

 

 

개체(장소)에 대한 자세한 정보 검색

 

https://api.opentripmap.com/0.1/en/places/xid/{xid}?apikey={API_KEY}
  • xid:[string] OpenTripMap에 있는 객체의 고유 식별자 (앞선 API로 조회할 수 있음)

 

예제
더보기

[request]

https://api.opentripmap.com/0.1/en/places/xid/W26658458?apikey=API_KEY

 

 

[response]

{
    "xid": "W26658458",
    "name": "Deoksugung Palace",
    "address": {
        "city": "서울",
        "road": "세종대로",
        "house": "덕수궁",
        "county": "중구",
        "country": "대한민국",
        "village": "소공동",
        "postcode": "100-101",
        "country_code": "kr",
        "house_number": "99"
    },
    "rate": "3h",
    "osm": "way/26658458",
    "bbox": {
        "lon_min": 126.973283,
        "lon_max": 126.976824,
        "lat_min": 37.564812,
        "lat_max": 37.567455
    },
    "wikidata": "Q482631",
    "kinds": "palaces,architecture,historic_architecture,urban_environment,gardens_and_parks,cultural,interesting_places",
    "url": "http://www.deoksugung.go.kr",
    "sources": {
        "geometry": "osm",
        "attributes": [
            "osm",
            "wikidata"
        ]
    },
    "otm": "https://opentripmap.com/en/card/W26658458",
    "wikipedia": "https://en.wikipedia.org/wiki/Deoksugung",
    "image": "https://commons.wikimedia.org/wiki/File:Deoksugungpalacefromthebuilding.jpg",
    "preview": {
        "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/Deoksugungpalacefromthebuilding.jpg/400px-Deoksugungpalacefromthebuilding.jpg",
        "height": 266,
        "width": 400
    },
    "wikipedia_extracts": {
        "title": "en:Deoksugung",
        "text": "Deoksugung, also known as Gyeongun-gung, Deoksugung Palace, or Deoksu Palace, is a walled compound of palaces in Seoul that was inhabited by members of Korea's royal family during the Joseon monarchy until the annexation of Korea by Japan in 1910. It is one of the \"Five Grand Palaces\" built by the kings of the Joseon Dynasty. The buildings are of varying styles, including some of natural cryptomeria wood), painted wood, and stucco. Some buildings were built of stone to replicate western palatial structures.",
        "html": "<p><b>Deoksugung</b>, also known as <b>Gyeongun-gung</b>, <b>Deoksugung Palace</b>, or <b>Deoksu Palace</b>, is a walled compound of palaces in Seoul that was inhabited by members of Korea's royal family during the Joseon monarchy until the annexation of Korea by Japan in 1910. It is one of the \"Five Grand Palaces\" built by the kings of the Joseon Dynasty. The buildings are of varying styles, including some of natural cryptomeria wood), painted wood, and stucco. Some buildings were built of stone to replicate western palatial structures.</p>"
    },
    "point": {
        "lon": 126.97517395019531,
        "lat": 37.566165924072266
    }
}

'프로젝트 개발 일지 > 웹개발_백엔드' 카테고리의 다른 글

[FastAPI] Fast API 시작  (1) 2024.09.24