Kakao API

Using JavaScript SDK, you can call Kakao Platform Service's REST APIs.

Example: Get KakaoTalk nickname

  • This is an example for getting user's KakaoTalk nickname.
  • You need to register your website's domain via Register App step.
  • Change 'YOUR APP KEY' to your registered app's JavaScript Key.
Get user's KakaoTalk nickname
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width"/>
<title>API Demo - Kakao JavaScript SDK</title>
<script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>
</head>
<body>
<a id="kakao-login-btn"></a>
<script type='text/javascript'>
//<![CDATA[
  // Set JavaScript Key of current app.
  Kakao.init('YOUR APP KEY');
  // Create Kakao Login button.
  Kakao.Auth.createLoginButton({
    container: '#kakao-login-btn',
    success: function(authObj) {
      // If login succeeds, call API.
      Kakao.API.request({
        url: '/v2/user/me',
        success: function(res) {
          alert(JSON.stringify(res));
        },
        fail: function(error) {
          alert(JSON.stringify(error));
        }
      });
    },
    fail: function(err) {
      alert(JSON.stringify(err));
    }
  });
//]]>
</script>
</body>
</html>

Check out the above example's live demo right now! Go to demo
* In order to request for KakaoTalk nickname, you must test with Kakao account linked to KakaoTalk.

Interested in more? Kakao.API Reference Each API's request parameter and response is identical to REST API. Refer to simple REST API reference

Example: Upload photo in KakaoStory

  • Upload photo in KakaoStory.
  • KakaoStory Button image can be downloaded from here
  • You need to register your website's domain via Register App step.
  • Change 'YOUR APP KEY' to your registered app's JavaScript Key.
Upload photo in KakaoStory.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width"/>
<title>API Demo: Post photo to KakaoStory  - Kakao JavaScript SDK</title>
<script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>

</head>
<body>
<style type='text/css'>
/* <![CDATA[ */
  #file-input-wrapper {
    display: none;
    margin-top: 50px;
  }
/* ]]> */
</style>
<a id="kakao-login-btn"></a>
<div id="file-input-wrapper">
<p>Post image to KakaoStory:</p>
<input id="file-input" type="file" multiple=""/>
</div>
<div>
<p id="post-result"></p>
<img id="post-image" src=""/>
</div>
<script type='text/javascript'>
//<![CDATA[
  // Set JavaScript Key of current app.
  Kakao.init('YOUR APP KEY');
  Kakao.Auth.createLoginButton({
    container: '#kakao-login-btn',
    success: function() {
      document.getElementById('file-input-wrapper').style.display = "block";
    },
    fail: function(err) {
      alert(JSON.stringify(err))
    }
  });
  document.getElementById('file-input').onchange = function (event) {
    Kakao.Auth.getStatus(function(statusObj) {
      if (statusObj.status == "not_connected") {
        alert('You should log in first.');
      } else {
        // Call API
        Kakao.API.request({
          url: '/v1/api/story/upload/multi',
          files: event.target.files
        }).then(function (res) {
          // If previous api call succeeded, call next API.
          return Kakao.API.request({
            url: '/v1/api/story/post/photo',
            data: {
              image_url_list: res
            }
          });
        }).then(function (res) {
          return Kakao.API.request({
            url: '/v1/api/story/mystory',
            data: { id: res.id }
          });
        }).then(function (res) {
          document.getElementById('post-result').innerHTML = JSON.stringify(res);
          document.getElementById('post-image').src = res.media[0].original;
        }, function(err) {
          alert(JSON.stringify(err));
        });
      }
    });
  };
//]]>
</script>

</body>
</html>

Check out the above example's live demo right now! Go to demo
Photo upload only works in browser that supports File API
In order to upload photo in KakaoStory you must test with Kakao acount linked to KakaoStory.

Interested in more? Kakao.API Reference Each API's request parameter and response is identical to REST API. Refer to simple REST API reference

Example: Write post in KakaoStory

  • This example scraps the given URL, then posts it in KakaoStory.
  • If you want to provide a button for users to share a post in KakaoStory, KakaoStory Share may better suit your needs.
  • KakaoStory Button image can be downloaded from here
  • You need to register your website's domain via Register App step.
  • Change 'YOUR APP KEY' to your registered app's JavaScript Key.
Write post in KakaoStory.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width"/>
<title>API Demo: Post link to KakaoStory  - Kakao JavaScript SDK</title>
<script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>
</head>
<body>
<a id="kakao-login-btn"></a>
<div>
<p id="post-result"></p>
</div>
<script type='text/javascript'>
//<![CDATA[
  // Set JavaScript Key of current app.
  Kakao.init('YOUR APP KEY');
  Kakao.Auth.createLoginButton({
    container: '#kakao-login-btn',
    success: function() {
      // If login succeeds, call API.
      Kakao.API.request({
        url : '/v1/api/story/linkinfo',
        data : {
          url : 'http://www.kakao.com'
        }
    }).then(function(res) {
        // If previous api call succeeded, call next API.
        return Kakao.API.request( {
          url : '/v1/api/story/post/link',
          data : {
            link_info : res
          }
        });
      }).then(function(res) {
        return Kakao.API.request( {
          url : '/v1/api/story/mystory',
          data : { id : res.id }
        });
      }).then(function(res) {
          document.getElementById('post-result').innerHTML = JSON.stringify(res);
        }, function (err) {
          alert(JSON.stringify(err));
      });
    },
    fail: function(err) {
      alert(JSON.stringify(err))
    }
  });
//]]>
</script>

</body>
</html>

Check out the above example's live demo right now! Go to demo
* In order to upload photo in KakaoStory you must test with Kakao acount linked to KakaoStory.

Interested in more? Kakao.API Reference Each API's request parameter and response is identical to REST API.
Refer to simple REST API reference

예제: 카카오스토리에 글 작성하기

  • 지정한 URL의 웹사이트를 스크랩한 후 카카오스토리에 글을 올립니다.
  • 사용자가 카카오스토리에 글을 직접 공유할 수 있도록 버튼을 제공하려면, 카카오스토리 공유를 참조해 주세요.
  • 카카오스토리 버튼 이미지는 여기에서 다운로드 할 수 있습니다.
  • 앱 등록 과정을 통해 도메인을 등록해야 합니다.
  • 'YOUR APP KEY'를 등록한 앱의 JavaScript 키로 변경해 주세요.

카카오스토리에 글을 작성합니다.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width"/>
<title>API Demo: Post link to KakaoStory  - Kakao JavaScript SDK</title>
<script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>

</head>
<body>
<a id="kakao-login-btn"></a>
<div>
<p id="post-result"></p>
</div>
<script type='text/javascript'>
  //<![CDATA[
    // 사용할 앱의 JavaScript 키를 설정해 주세요.
    Kakao.init('YOUR APP KEY');
    Kakao.Auth.createLoginButton({
      container: '#kakao-login-btn',
      success: function() {
        // 로그인 성공시, API를 호출합니다.
        Kakao.API.request({
          url : '/v1/api/story/linkinfo',
          data : {
            url : 'http://www.kakao.com'
          }
         }).then(function(res) {
          // 이전 API 호출이 성공한 경우 다음 API를 호출합니다.
          return Kakao.API.request( {
            url : '/v1/api/story/post/link',
            data : {
              link_info : res
            }
          });
        }).then(function(res) {
          return Kakao.API.request( {
            url : '/v1/api/story/mystory',
            data : { id : res.id }
          });
        }).then(function(res) {
            document.getElementById('post-result').innerHTML = JSON.stringify(res);
          }, function (err) {
            alert(JSON.stringify(err));
        });
      },
      fail: function(err) {
        alert(JSON.stringify(err))
      }
    });
  //]]>
</script>

</body>
</html>

위 예제의 데모를 바로 확인해 보세요! 데모 보러가기

  • 카카오스토리에 글을 작성하기 위해서는 카카오스토리와 연결된 카카오계정으로 테스트해야 합니다.

Kakao.API와 관련된 자세한 내용이 궁금하다면? Kakao.API 레퍼런스
각 API에 대한 요청 파라미터와 응답은 REST API와 동일합니다. REST API 간편한 참조

예제: 친구목록 조회

  • 친구목록을 불러오는 예제입니다.
  • 앱 등록 과정을 통해 도메인을 등록해야 합니다.
  • 'YOUR APP KEY'를 등록한 앱의 JavaScript 키로 변경해 주세요.

친구목록을 조회합니다.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width"/>
<title>API Demo: Request KakaoTalk friends list - Kakao JavaScript SDK</title>
<script src="//developers.kakao.com/sdk/js/kakao.min.js"></script>

</head>
<body>
<a id="kakao-login-btn"></a>
<script type='text/javascript'>
  //<![CDATA[
    // 사용할 앱의 JavaScript 키를 설정해 주세요.
    Kakao.init('YOUR APP KEY');
    // 카카오 로그인 버튼을 생성합니다.
    Kakao.Auth.createLoginButton({
      container: '#kakao-login-btn',
      success: function(authObj) {
        // 로그인 성공시, API를 호출합니다.
        Kakao.API.request({
          url: '/v1/friends',
          success: function(res) {
            alert(JSON.stringify(res));
          },
          fail: function(error) {
            alert(JSON.stringify(error));
          }
        });
      },
      fail: function(err) {
        alert(JSON.stringify(err));
      }
    });
  //]]>
</script>

</body>
</html>

친구 API를 서비스에 적용하려면 반드시 검수를 받아야 합니다. 친구 API 사용제약
Kakao.API와 관련된 자세한 내용이 궁금하다면? Kakao.API 레퍼런스
각 API에 대한 요청 파라미터와 응답은 REST API와 동일합니다. REST API 간편한 참조

Promise Support

Kakao.API.request function returns a Promise. When sequentially calling API, you can simplify your code by using Promise.

To learn more about Promise, please refer here.

Supported APIs

JavaScript SDK's request parameter and response is identical to REST API. Refer to simple REST API reference

Push alert and app log analytics are not supported.


Last Modified : 2018-08-23