> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getAssetsByGroup

> 在 OrbitFlare 上使用 DAS getAssetsByGroup，列出某个 Solana 合集中的所有 NFT 和压缩 NFT。

## 概述

`getAssetsByGroup` 列出某个分组中的资产。实际上，这个分组就是合集：传入 `groupKey: "collection"`，并将合集地址作为 `groupValue`。除非设置了 `showUnverifiedCollections`，否则只返回已验证的合集成员。

## 参数

<ResponseField name="groupKey" type="string" required>
  分组类型。请使用 `collection`。
</ResponseField>

<ResponseField name="groupValue" type="string" required>
  合集地址（base-58）。
</ResponseField>

<ResponseField name="page" type="number">
  页码，从 1 开始。请参阅[分页](/cn/das-api/pagination)。
</ResponseField>

<ResponseField name="limit" type="number">
  每页结果数。最大值和默认值均为 1,000。
</ResponseField>

<ResponseField name="cursor" type="string">
  来自上一次响应的游标。
</ResponseField>

<ResponseField name="before" type="string">
  返回 ID 在此 ID 之前的资产。
</ResponseField>

<ResponseField name="after" type="string">
  返回 ID 在此 ID 之后的资产。
</ResponseField>

<ResponseField name="sortBy" type="object">
  `{ "sortBy": "id" | "created" | "updated" | "recent_action" | "none", "sortDirection": "asc" | "desc" }`
</ResponseField>

<ResponseField name="options" type="object">
  [显示选项](/cn/das-api/display-options)：`showFungible`、`showUnverifiedCollections`、`showCollectionMetadata`、`showInscription`。也可以作为 `displayOptions` 传入。
</ResponseField>

## 响应

一个列表，包含 `last_indexed_slot`、`total`、`limit`、`page` 或 `cursor`，以及 `items`（[资产对象](/cn/das-api/asset-object)）。

## 代码示例

### 请求

```bash theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getAssetsByGroup",
  "params": {
    "groupKey": "collection",
    "groupValue": "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w",
    "page": 1,
    "limit": 1
  }
}'
```

### 响应

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": {
    "last_indexed_slot": 457714577,
    "total": 1,
    "limit": 1,
    "page": 1,
    "items": [
      {
        "interface": "ProgrammableNFT",
        "id": "JEGruwYE13mhX2wi2MGrPmeLiVyZtbBptmVy9vG3pXRC",
        "content": {
          "json_uri": "https://madlads.s3.us-west-2.amazonaws.com/json/6867.json",
          "metadata": { "name": "Mad Lads #6867", "symbol": "MAD" }
        },
        "grouping": [
          { "group_key": "collection", "group_value": "J1S9H3QjnRtBbbuD4HjPV6RpRhwuk4zKbxsnCHuTgh9w" }
        ],
        "ownership": {
          "frozen": true,
          "delegated": true,
          "delegate": "FARqKAafAbgT25QcgiX5d1g6xpadgG7xymu5N6gSmp4x",
          "ownership_model": "single",
          "owner": "CxBhuJwhVgNMc7yjnRx3XFAsTnnbYDc2bhAGSaLBjNqZ"
        }
      }
    ]
  },
  "id": 1
}
```

此处的资产对象已做精简。完整示例请参阅[资产对象](/cn/das-api/asset-object)。

### TypeScript

收集某个合集的持有者：

```typescript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
const RPC_URL = 'https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY';

async function getCollectionHolders(collection: string) {
  const holders = new Map<string, number>();
  let cursor: string | undefined;

  while (true) {
    const response = await fetch(RPC_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getAssetsByGroup',
        params: { groupKey: 'collection', groupValue: collection, limit: 1000, cursor },
      }),
    });
    const { result, error } = await response.json();
    if (error) throw new Error(error.message);

    for (const asset of result.items) {
      const owner = asset.ownership.owner;
      holders.set(owner, (holders.get(owner) ?? 0) + 1);
    }
    if (result.items.length < 1000) break;
    cursor = result.cursor;
  }

  return holders;
}
```

## 常见错误

| 错误码 | 消息 | 解决方案 |
| - | - | - |
| -32602 | missing field `groupValue` | 同时发送 `groupKey` 和 `groupValue` |
| -32602 | Pagination Error. Limit should not be greater than 1000. | 使用不超过 1,000 的 `limit` |
| -32602 | Pagination Sorting Error | 游标和范围需要 `sortBy: "id"`；其他排序方式请使用 `page` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.