# JSON API

{% hint style="info" %}
第一个版本的 MAN 已上线并已开源，后续的部署和接口文档请以 Github 上文档为准：\
<https://github.com/metaid-developers/man-indexer>
{% endhint %}

## 基础API

| 地址                                           | method | parameter                                    | 描述                               |
| -------------------------------------------- | ------ | -------------------------------------------- | -------------------------------- |
| /api/pin/{numberOrId}                        | GET    | PIN number 或 PIN id                          | 根据PIN number或PIN id获取PIN详情       |
| /api/address/pin/list/{addressType/{address} | GET    | address addressType ：creator（创建者），owner(拥有者) | 根据address获取该地址创建或拥有的PIN列表        |
| /api/address/pin/root/{address}              | GET    | address                                      | 根据address获取PIN root              |
| /api/node/child/{pinId}                      | GET    | pinId                                        | 根据PIN id 获取child node            |
| /api/node/parent/{pinId}                     | GET    | pinId                                        | 根据PIN id 获取parent node           |
| /api/info/address/{address}                  | GET    | address                                      | 获取adress的MetaID info             |
| /api/info/rootId/{rootId}                    | GET    | rootId                                       | 根据rootId获取MetaID info            |
| /api/pin/content/{numberOrId}                | GET    | PIN number 或 PIN id                          | 根据PIN number或PIN id获取PIN的content |
| /api/getAllPinByParentPath                   | GET    | page,limit,parentPath                        | 根据parentPath获取所有pin              |

## generalQuery

protocols 数据通用查询，支持get,count,sum方式获取数据。

地址: /api/generalQuery

**method:** POST

```json
{
    "collection": "pins", // 查询的集合名称，必填
    "action": "sum", // 查询操作，支持 get, count, sum
    "filterRelation": "or", // 查询条件关系，支持 or, and，目前不支持混用
    "field": [
        "number" // 查询的返回的字段，sum 时必填
    ],
    // 查询条件
    "filter": [
        {
            "operator": "=", // 条件操作符号，支持 =, >, >=, <, <=
            "key": "number", // 条件字段
            "value": 1 // 查询值
        },
        {
            "operator": "=",
            "key": "number",
            "value": 2
        }
    ],
    "cursor": 0, // 返回数据起始
    "limit": 1, // 返回数据条数
    "sort": [
        "number", // 排序字段
        "desc" // 顺序，支持 asc, desc
    ]
}
```

**成功返回示例**

```json
{
    "code": 1, //成功1
    "message": "ok", //返回消息
    "data": [ //数据内容
        {
            "_id": "65e96a276bff93b007c02b16",
            "isLike": "1",
            "likeTo": "32c6d91b6fb3f6746258d83f1fe8fb32f19c2a3e0071847b6046f01c938ca20bi0",
            "pinAddress": "tb1pss8ce6tgupnhmfj8u9h4saue48upucu04c7549tzal6n67v8njyst7e0fx",
            "pinId": "3943f7fa4c8496ced9ff722ae5bbdd57ad7b84a383304890b41f21e12f11086bi0",
            "pinNumber": 69
        }
    ]
}
```

**失败返回实例**

```json
{
    "code": -1, //失败
    "message": "Data not found", //失败原因
    "data": null
}
```


---

# 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://docs.metaid.io/zh/metaid-app-node/json-api.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.
