KMDB에서 발급받은 Open API 구조 확인
https://www.kmdb.or.kr/info/api/apiDetail/6
// KMDB 영화자료 API
해당하는 사이트 접근을 위해서는 ServiceKey (인증키)가 필요하다. 발급받은 인증키를, 아래 코드에 맞게 url 을 구성하여 해당 Openapi를 탐색했다.
기본 요청 URL : http://api.koreafilm.or.kr/openapi-data2/wisenut/search_api/search_xml2(또는 search_json2).jsp?collection=kmdb_new2
예시) http://api.koreafilm.or.kr/openapi-data2/wisenut/search_api/search_xml2.jsp?collection=kmdb_new2&detail=N&director=%EB%B0%95%EC%B0%AC%EC%9A%B1&ServiceKey=인증키값
(요청인자①)
(요청인자②)
(요청인자③)
http://api.koreafilm.or.kr/openapi-data2/wisenut/search_api/search_json2.jsp?collection=kmdb_new2&genre=뮤지컬&ServiceKey=06E1CQ572154KRS78LD5
// 발급받은 ServiceKey를 통해서 접근 (장르=뮤지컬)
Data: [
{
CollName: "kmdb_new2",
TotalCount: 740,
Count: 10,
Result: [
{
DOCID: "F01764",
movieId: "F",
movieSeq: "01764",
title: " 사랑은 영원히",
titleEng: "",
titleOrg: "The Great Waltz",
titleEtc: "사랑은영원히^사랑은 영원히^The Great Waltz^사랑은영원히(1974)^The Great Waltz",
prodYear: "1972",
directors: {
director: [
{
directorNm: "앤드류 L. 스톤",
directorEnNm: "Andrew L. Stone",
directorId: "00054954"
}
]
},
actors: {
actor: [
{
actorNm: "호스트 부흐홀즈",
actorEnNm: "Horst Buchholz",
actorId: "00077153"
},
{
actorNm: "메리 코스타",
actorEnNm: "Mary Costa",
actorId: "00100742"
},
{
actorNm: "나이젤 패트릭",
actorEnNm: "Nigel Patrick",
actorId: "00105801"
}
]
},
nation: "미국",
company: "Metro-Goldwyn-Mayer (MGM)",
plots: {
plot: [
{
plotLang: "",
plotText: ""
}
]
},
runtime: "135",
rating: "미성년자관람가",
genre: "드라마,뮤지컬,전기",
kmdbUrl: "https://www.kmdb.or.kr/db/kor/detail/movie/F/01764",
type: "극영화",
use: "극장용",
episodes: "",
ratedYn: "Y",
repRatDate: "19770930",
repRlsDate: "",
ratings: {
rating: [
{
ratingMain: "Y",
ratingDate: "19770930",
ratingNo: "외제1344호",
ratingGrade: "미성년자관람가",
releaseDate: "",
runtime: "135"
}
]
},
keywords: "작곡가,클래식,요한스트라우스",
posters: "",
stlls: "",
staffs: {
staff: [
{
staffNm: "앤드류 L. 스톤",
staffEnNm: "Andrew L. Stone",
staffRoleGroup: "감독",
staffRole: "",
staffEtc: "",
staffId: "00054954"
},
{
staffNm: "앤드류 L. 스톤",
staffEnNm: "Andrew L. Stone",
staffRoleGroup: "각본",
staffRole: "",
staffEtc: "",
staffId: "00054954"
},
{
staffNm: "호스트 부흐홀즈",
staffEnNm: "Horst Buchholz",
staffRoleGroup: "출연",
staffRole: "",
staffEtc: "",
staffId: "00077153"
},
{
staffNm: "메리 코스타",
staffEnNm: "Mary Costa",
staffRoleGroup: "출연",
staffRole: "",
staffEtc: "",
staffId: "00100742"
},
{
staffNm: "나이젤 패트릭",
staffEnNm: "Nigel Patrick",
staffRoleGroup: "출연",
staffRole: "",
staffEtc: "",
staffId: "00105801"
}
]
},
vods: {
vod: [
{
vodClass: "",
vodUrl: ""
}
]
},
openThtr: "",
stat: [
{
screenArea: "",
screenCnt: "",
salesAcc: "",
audiAcc: "",
statSouce: "",
statDate: ""
}
],
screenArea: "",
screenCnt: "",
salesAcc: "",
audiAcc: "",
statSouce: "",
statDate: "",
themeSong: "",
soundtrack: "",
fLocation: "",
Awards1: "",
Awards2: "",
regDate: "19000101",
modDate: "20171211",
Codes: {
Code: [
{
CodeNm: "",
CodeNo: ""
}
]
},
CommCodes: {
CommCode: [
{
CodeNm: "",
CodeNo: ""
}
]
},
ALIAS: "srcKmdb2"
}
이 출력내용에서 중요하게 볼 요소들은, "영화제목 / 영화제목(영어) / 감독명 / 감독(영어명) / 배우진 / 스태프 / 줄거리 / URL / 포스터" 등이 있다.
그렇다면, 어떻게 이러한 값들을 가져올 수 있을까? DB에 저장하는 것은 쉬울 거 같은데, 형식에 맞게 가져오고 API를 사용한다는 것이 오래 전에 배운 개념이라서 조금 개념을 읽어보고 접근해야할 것 같다.
(개발자 도구창에 띄우는 예시 _미세먼지 API 활용_SCC)
$.ajax({
type: "GET",
url: "http://openapi.seoul.go.kr:8088/6d4d776b466c656533356a4b4b5872/json/RealtimeCityAir/1/99",
data: {},
success: function(response){
// 값 중 도봉구의 미세먼지 값만 가져와보기
let dobong = response["RealtimeCityAir"]["row"][11];
let gu_name = dobong['MSRSTE_NM'];
let gu_mise = dobong['IDEX_MVL'];
console.log(gu_name, gu_mise);
}
})
(모든 구의 미세먼지 값을 찍어보기_SCC)
$.ajax({
type: "GET",
url: "http://openapi.seoul.go.kr:8088/6d4d776b466c656533356a4b4b5872/json/RealtimeCityAir/1/99",
data: {},
success: function(response){
let mise = response["RealtimeCityAir"]["row"];
for (let i = 0 ; i < mise.length; i++) {
let gu_name = mise[i]['MSRSTE_NM'];
let gu_mise = mise[i]['IDEX_MVL'];
console.log(gu_name, gu_mise);
}
}
})