> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/contributor/contributor-ko/social-service/overview.md).

# 개요

Decentraland 플랫폼에서 우정, 요청 및 상호 친구를 가져오기 위해 Social Service API를 사용하는 방법에 대한 세부 정보입니다. 이 API를 통해 개발자는 Social Service와 상호작용하여 우정 관련 정보를 가져올 수 있습니다.

#### REST API

우정을 가져오기 위해 Social Service는 다음을 제공합니다 [REST API](https://social-service-api-specs.pages.dev/):

* `GET /friendships/me` - 현재 사용자의 우정을 가져옵니다. Authorization 헤더에 액세스 토큰이 필요합니다.
* `GET /friendships/{other-address}/mutuals` - 다른 사용자와의 상호 친구를 가져옵니다. Authorization 헤더에 액세스 토큰이 필요합니다.

#### WebSocket RPC 서버

Social Service WebSocket API는 우정과 상호 친구를 가져오기 위한 두 가지 메시지 유형을 제공합니다. 먼저 WebSocket 연결을 설정한 다음 해당 메서드를 사용하여 사용자 관련 정보를 스트리밍해야 합니다.

* `GetFriends` - 사용자의 친구를 가져옵니다. 사용자 응답 스트림을 반환합니다.
* `GetMutualFriends` - 다른 사용자와의 상호 친구를 가져옵니다. 사용자 응답 스트림을 반환합니다.

다음을 참조하세요 [friendships.proto 파일](https://github.com/decentraland/protocol/blob/main/proto/decentraland/social/friendships/friendships.proto#L7) 이 메시지 유형에 대한 자세한 내용은

### JavaScript 코드 예시

JavaScript를 사용하여 Social Service WebSocket API와 상호작용하려면 앞서 설명한 제공된 RPC 클라이언트를 사용할 수 있습니다. 하지만 직접 구현해야 한다면, 아래에 친구와 상호 친구를 가져오는 방법을 보여주는 코드 예시가 있습니다:

#### 모든 친구 가져오기

```javascript
import { createRpcClient, createWebSocketsTransport } from '@dcl/rpc/dist/client';
import { FriendshipsServiceDefinition } from './protobuff-types/decentraland/social/friendships/friendships.gen';

const socialClientRpcUrl = 'wss://social.decentraland.org'; // 실제 URL로 바꾸세요
const webSocketsTransport = createWebSocketsTransport(socialClientRpcUrl);
const service = loadService(FriendshipsServiceDefinition, webSocketsTransport);

const response = service.getFriends(Payload.create({ synapseToken }));
for await (const friends of response) {
  processErrors(friends);
  const userList = friends.users?.users ?? [];
  // 친구 목록을 처리합니다
}
```

#### 상호 친구 가져오기

```javascript
const response = service.getMutualFriends(
  MutualFriendsPayload.create({
    user: { address }, 
    authToken: { synapseToken }
  })
);
for await (const mutualFriend of response) {
  processErrors(mutualFriend);
  const mutualFriendList = mutualFriend.users?.users ?? [];
  // 상호 친구 목록을 처리합니다
}
```

더 많은 코드 예시와 자세한 내용은 다음을 방문하세요 [social-rpc-client-js GitHub 저장소](https://github.com/decentraland/social-rpc-client-js)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/contributor/contributor-ko/social-service/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
