# 关系图谱

## <mark style="color:blue;">GET</mark> /api/v1/relationshipGraph

* 说明： 通过这个 API，你将可以查询到用户授权的 1 度关系图谱数据（用户）列表。1 度关系指与该用户存在直接关联的其他用户。该数据需用 [Lit Protocol 解密](https://relationlabs.gitbook.io/relation-graph/g-zh/guide/use-litprotocol-to-decrypt)。
* Header

| Field  | Type   | Required | Remarks                                                                                      |
| ------ | ------ | -------- | -------------------------------------------------------------------------------------------- |
| ApiKey | String | true     | 从管理员获取的 [ApiKey](https://relationlabs.gitbook.io/relation-graph/g-zh/api/relationship-graph) |

* Request Parameters

| Field           | Type   | Required | Remarks                                                                                                                                                                    |
| --------------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| address         | String | fasle    | EOA Address                                                                                                                                                                |
| twitterUsername | String | fasle    | twitter username                                                                                                                                                           |
| steamId         | String | fasle    | steamId                                                                                                                                                                    |
| sig             | String | true     | 用户授权信息签名（签名可参考[SIWE](https://docs.login.xyz/),带有授权信息时，开发者可[使用 Lit Protocol 对返回结果解密](https://relationlabs.gitbook.io/relation-graph/g-zh/guide/use-litprotocol-to-decrypt)） |
| message         | String | true     | 用户授权信息签名原文（签名原文拼接可参考[SIWE](https://docs.login.xyz/),其中statement字段需要为:**Access to Relationship Graph.**)）                                                                   |
| limit           | int    | true     | 每次查询数量，上限100                                                                                                                                                               |
| cursor          | string | true     | 上一页返回的 cursor数据，cursor为空表示查询第一页                                                                                                                                            |

* Request Example

```shell
curl  GET 'https://api.relationlabs.ai/api/v1/relationshipGraph?address=0x9bd286ef4e3d9ec1af6c6ae9da2f0b3617deab13&sig=0x00111&message=example.com%20wants%20you%20to%20sign%20in%20with...&limit=10&cursor=a1228c5910a04c94b70e18694d72cbb0' \
--header 'ApiKey: <ApiKey>'
```

* Response Parameters

| Field | Type          | Remarks            |
| ----- | ------------- | ------------------ |
| code  | String        | 返回码                |
| desc  | String        | 返回信息               |
| data  | EncryptedData | 数据（Lit Protocol密文） |

EncryptedData解密后字段如下:

| Field       | Type     | Remarks      |
| ----------- | -------- | ------------ |
| relation    | Relation | Relation用户信息 |
| address     | List     | 地址列表         |
| twitter     | Twitter  | 推特信息         |
| steam       | Steam    | steam信息      |
| description | String   | 关系描述         |

EncryptedData 解密后数据结构如下：

```json
[
  {
    "relation": {
      "relationId": "d4swz-zaaaa-aaaaj-at5fa-cai",
      "name": "test_user",
      "avatar": "https://3fypb-gqaaa-aaaag-aaedq-cai.ic1.io/nft/eth/relation-test-club/16.png",
      "address": []
    },
    "twitter": {
      "username": "VitalikButerin",
      "name": "vitalik.eth",
      "avatar": "https://pbs.twimg.com/profile_images/977496875887558661/L86xyLF4_400x400.jpg"
    },
    "steam": {
      "steamId": "178691028912",
      "name": "vitalik",
      "avatar": "https://pbs.twimg.com/profile_images/977496875887558661/L86xyLF4_400x400.jpg"
    },
    "description": ""
  }
]

```

* Response Body

```json

{
  "code": "0",
  "desc": "success",
  "data": {
    "encryptedString": "xxx",
    "encryptedSymmetricKey": "xxx"
  }
}
```

* Return Code

| code | desc    | Remarks                           |
| ---- | ------- | --------------------------------- |
| 0    | success | the flag for a successful request |


---

# Agent Instructions: 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:

```
GET https://relationlabs.gitbook.io/relation-graph/g-zh/api/relationship-graph.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
