> For the complete documentation index, see [llms.txt](https://relationlabs.gitbook.io/relation-one-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://relationlabs.gitbook.io/relation-one-api/api-zh/guide/quick-start.md).

# 快速开始

### 环境安装

开始本教程之前，您的计算机上必须安装[Node.js](https://nodejs.org/en/)。

### 申请 ApiKey

可使用下面的 ApiKey 进行体验：581c6c4fa0b54912b00088aa563342a4。 如有生产需要，请填写表格：[Relation API Access Request](https://docs.google.com/forms/u/0/d/1LIFaJCtLMF6GiJHC3Y0RpD8wuQ-XKJrijFT9aqTGbT4/viewform?edit_requested=true)。

通过下面 demo 介绍如何接入 Relation One。

### Demo

Repository: <https://github.com/relationlabs/relation-im-demo>

在线 Demo: <https://app.relationlabs.ai/demo/im/>

视频引导：

{% embed url="<https://youtu.be/zKw6ii9PfAw>" %}

运行 demo：

```shell
git clone https://github.com/relationlabs/relation-im-demo.git
cd relation-im-demo
npm install
npm run dev
```

### 功能介绍

#### 获取addressAuthToken

```js
import { authByMetamask } from '@relationlabs/auth';

const { authResult } = await authByMetamask();
```

#### 获取unifiedAuthToken

```js
const { token, error } = await RelationIM.getRelationToken(
  authResult.token,
  APIKEY
)
```

#### 获取个人信息

```js
const userInfoRes = await im.getUserInfo()
```

#### 已关注用户的列表

```js
const res = await im.getFollowing({
  address: relationId,
  limit,
  cursor
})
```

#### follow/unfollow

```js
const res = await im.follow(relationId)
const res = await im.unfollow(relationId)
```

#### 初始化 IM 实例

```js
const im = RelationIM.init({ token, apiKey: APIKEY, connect: true })
```

#### 会话列表

```js
const res = await im.userChannelsList({
  cursor,
  limit
})
```

#### 接收消息

```js
im.bind(Im.RECEIVE_MSG_OK,(event) => {...})
```

#### 单个会话的消息列表

```js
const res = await im.messageList({
  channelUuid,
  maxCreateAt: new Date().getTime(),
  limit
})
```

#### 发送消息

```js
const res = await im.sendMessage({
  channelUuid,
  content
})
```

#### 深入了解

更多Api请参考：

{% content-ref url="/pages/OnA2LZ1LQBlQsOPP3dUA" %}
[介绍](/relation-one-api/api-zh/api/introduction.md)
{% endcontent-ref %}


---

# 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://relationlabs.gitbook.io/relation-one-api/api-zh/guide/quick-start.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.
