페이지 이동경로
  • Docs>
  • Kakao Talk Social>
  • JavaScript

Kakao Talk Social

JavaScript

This document describes how to integrate Kakao Talk Social APIs into your service with the Kakao SDK for JavaScript (hereinafter referred to as 'JavaScript SDK').

IMPORTANT

To use the JavaScript SDK, you must register the Web platform in advance. Go to [My Application] > [Platform] and register your site domains.

Tag used in this document

Tag Description
Login required The API marked with this tag requires Kakao Login. You must implement the Kakao Login function first, and then call the corresponding API by using the access token issued when a user logs in.
Consent required To use the API marked with this tag, you must enable a specific scope required for the corresponding API.
In addition, a user must also consent to the scope. Otherwise, an error occurs or empty value is returned. To check which scopes a user has consented to, you can call the Retrieving consent details API.

Retrieve Kakao Talk profile Login required Consent required

This API enables you to get the Kakao Talk profile of the user currently logged in. To see the difference of profile information between Kakao Talk and Kakao Account, refer to Understand Concepts.

To use this API,

  • You must enable the 'Profile' scope in [My Application] > [Kakao Login] > [Consent items].
  • A user must consent to the scope. Otherwise, an empty value is returned.

Call the Kakao.API.request() function, and set url to /v1/api/talk/profile to request Kakao Talk profile. You do not need to set the HTTP request header and other parameters because the JavaScript SDK proceeds automatically and sends a request instead.

Parameter
Name Type Description Required
url String Fixed as '/v1/api/talk/friends'. O
success Function(Object) Callback function that gets invoked when the API request is successful. X
fail Function(Object) Callback function that gets invoked if the API request is failed. X
always Function(Object) Callback function that gets invoked regardless of the API request results. X
Sample
Kakao.API.request({
  url: '/v1/api/talk/profile',
  success: function(response) {
    console.log(response);
  },
  fail: function(error) {
    console.log(error);
  }
});
Response

If the request is successful, the Kakao Talk profile information is returned in JSON format. To see more about the response, refer to REST API.

Retrieve list of friends Login required Consent required

You can get the list of Kakao Talk friends of the user currently logged in. You can also add optional parameters for sort order, the number of friends to be retrieved on a page, and so on.

To use this API,

  1. Get permission. Before permission is granted to your app, you can call this API only for the team members.
  2. Enable the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' scope in [My Application] > [Kakao Login] > [Consent items]. A user must also consent to the scope. To see more about the conditions for providing friend information, refer to Usage policy.

Call the Kakao.API.request() function, and set url to /v1/api/talk/friends to request Kakao Talk friends information. You do not need to set the HTTP request header and other parameters because the JavaScript SDK proceeds automatically and sends a request instead.

Parameter
Name Type Description Required
url String Fixed as '/v1/api/talk/friends'. O
success Function(Object) Callback function that gets invoked when the API request is successful. X
fail Function(Object) Callback function that gets invoked if the API request is failed. X
always Function(Object) Callback function that gets invoked regardless of API request results. X
data Object Object that contains the parameters to be passed when requesting the API.
Refer to data: Retrieving list of friends.
X
data: Retrieving list of friends
Name Type Description Required
offset Number Offset value that the list of friends starts from.
(Default: 0)
X
limit Number Maximum number of friends to be retrieved per page.
(Maximum: 100, Default: 10)
X
order String Sort order of friends list.
asc or desc.
- asc: sort in ascending order.
- desc: sort in descending order.
(Default: asc)
X
friend_order String You can sort friends in the list by nickname (Kakao Talk nickname) or favorite (favorite friends).
(Default: favorite)
X
Sample
Kakao.API.request({
  url: '/v1/api/talk/friends',
  success: function(response) {
    console.log(response);
  },
  fail: function(error) {
    console.log(error);
  }
});
Response

If the request is successful, a list of friends is returned in JSON format. To see more about the response, refer to REST API.

If the request fails because the user has not agreed to provide the Friends List in Kakao Service(Including profile image, nickname, and favorites) scope, proceed the followings:

  • Check if 'Friends List in Kakao Service(Including profile image, nickname, and favorites)' is set to 'Consent during use' in Consent items.
  • Request additional consent to the 'Friends List in Kakao Service(Including profile image, nickname, and favorites)'.

See more