๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘ฉ‍๐Ÿ’ป Learn programming

[๋‚˜๋งŒ์˜ ๋‹จ์–ด์žฅ] 3. OWLBOT API (์‚ฌ์ „ API) ์‚ฌ์šฉ

by ๋ฐ๊ตฅ์ž‰ 2022. 5. 4.
๋ฐ˜์‘ํ˜•

โœ… ์˜์–ด ์‚ฌ์ „ API - OWLBOT API๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋‹จ์–ด, ๋œป, ์˜ˆ๋ฌธ ๊ฐ€์ ธ์™€์•ผํ•จ.

โœ… ์˜์–ด ์‚ฌ์ „ Open API

Owlbot English Dictionary API

 

Owlbot English Dictionary API

 

owlbot.info

 

โœ… get a token ํด๋ฆญํ•ด์„œ ์ด๋ฉ”์ผ ์ž‘์„ฑ ํ›„, ์ด๋ฉ”์ผ๋กœ API ํ‚ค ๋ฐ›๊ธฐ

 

โœ… ํŒŒ์ด์ฌ์œผ๋กœ API์— ์š”์ฒญ ๋ณด๋‚ด๊ธฐ

r = requests.get("<https://owlbot.info/api/v4/dictionary/owl>", headers={"Authorization": "Token [ํ† ํฐ]"})
result = r.json()
print(result)

 

โœ… Ajax๋กœ ์š”์ฒญ ๋ณด๋‚ด๊ธฐ

$.ajax({
    type: "GET",
    url: "<https://owlbot.info/api/v4/dictionary/owl>",
    beforeSend: function (xhr) {
        xhr.setRequestHeader("Authorization", "Token [๋‚ดํ† ํฐ]");
    },
    data: {},b
    error: function (xhr, status, error) {
        alert("์—๋Ÿฌ ๋ฐœ์ƒ!");
    },
    success: function (response) {
        console.log(response)
    }
})
๋ฐ˜์‘ํ˜•