> ## 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.

# getAssetBatch

> 在 OrbitFlare 上使用 getAssetBatch，通过单个 DAS 请求按 ID 获取最多 1,000 个 Solana 资产。

## 概述

`getAssetBatch` 在一个请求中返回多个资产。结果的顺序与你发送的 ID 顺序相同，任何不是已索引资产的 ID 都会对应 `null`。

该方法也可以通过 `getAssets` 调用。

## 参数

<ResponseField name="ids" type="string[]" required>
  资产 ID（base-58）。最多 1,000 个。
</ResponseField>

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

## 响应

<ResponseField name="result" type="array">
  每个请求的 ID 对应一个条目，按请求顺序排列。每个条目是一个[资产对象](/cn/das-api/asset-object)或 `null`。
</ResponseField>

## 代码示例

### 请求

```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": "getAssetBatch",
  "params": {
    "ids": [
      "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk",
      "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU"
    ]
  }
}'
```

### 响应

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "jsonrpc": "2.0",
  "result": [
    {
      "interface": "ProgrammableNFT",
      "id": "F9Lw3ki3hJ7PF9HQXsBzoY8GyE6sPoEZZdXJBsTTD2rk",
      "content": {
        "json_uri": "https://madlads.s3.us-west-2.amazonaws.com/json/8420.json",
        "metadata": { "name": "Mad Lads #8420", "symbol": "MAD" }
      },
      "ownership": { "owner": "BUCoKqFVfxRTJJFH37r7StaxoA2pdu3rA5cPfXYTnMUw", "ownership_model": "single" }
    },
    {
      "interface": "V1_NFT",
      "id": "JEKNNLZK6uQaQUEUz9GRoYZ7buHQ4rTN6k3qhX9NG8qU",
      "content": {
        "json_uri": "https://arweave.net/ymSDHwAqb3hnNKBid03WBUqY1Svj5Hzr0fdAYGvZBKA",
        "metadata": { "name": "Aurora borealis", "symbol": "" }
      },
      "ownership": { "owner": "5MRNQW3NxNes1EDnxUhqyXwffseQBLpdu6QJF8G4MdN9", "ownership_model": "single" }
    }
  ],
  "id": 1
}
```

此处的资产对象已做精简。完整响应请参阅 [getAsset](/cn/das-api/methods/getAsset)。

### 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 getAssetBatch(ids: string[]) {
  const results = [];

  // The API accepts at most 1,000 IDs per request.
  for (let i = 0; i < ids.length; i += 1000) {
    const response = await fetch(RPC_URL, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({
        jsonrpc: '2.0',
        id: 1,
        method: 'getAssetBatch',
        params: { ids: ids.slice(i, i + 1000) },
      }),
    });
    const { result, error } = await response.json();
    if (error) throw new Error(error.message);
    results.push(...result);
  }

  return results;
}
```

## 常见错误

| 错误码 | 消息 | 解决方案 |
| - | - | - |
| -32602 | Batch Size Error. Batch size should not be greater than 1000. | 将 ID 拆分为每批 1,000 个 |
| -32602 | Pubkey Validation Err: ... is invalid | 每个 ID 都必须是有效的 base-58 |


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