---
name: metafs-indexer
description: 基于 Meta 文件索引服务查询用户信息与文件内容。当需要根据 address、metaid 或 globalMetaID 查询用户信息并展示头像，或根据 pinId 查询文件元数据与内容时使用。Base URL 固定为 https://file.metaid.io/metafile-indexer。
title: metafs-indexer
canonical_url: https://skilld.dev/gh/metaid-developers/metaapp-skills/metafs-indexer
last_updated: 2026-10-05T01:28:40.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/api.md](https://skilld.dev/api/skills-raw/metaid-developers/metaapp-skills/metafs-indexer/references/api.md), [scripts/query_indexer.py](https://skilld.dev/api/skills-raw/metaid-developers/metaapp-skills/metafs-indexer/scripts/query_indexer.py).
>
> If the user asked to install this Skill, run `npx skilld install metaid-developers/metaapp-skills/metafs-indexer`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/metafs-indexer`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/metaid-developers/metaapp-skills/metafs-indexer) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/metafs-indexer`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/metafs-indexer --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/metafs-indexer --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# metafs-indexer

## Base URL

所有请求的基础路径为：**`https://file.metaid.io/metafile-indexer`**（不要使用其他 domain）。

## 查询用户信息

根据 **address**、**metaid** 或 **globalMetaID** 任选一种方式查询，使用 `/api/info/*` 路径（MetaID 兼容格式）：

| 查询依据      | 路径 |
|---------------|------|
| address       | `GET /api/info/address/:address` |
| metaid        | `GET /api/info/metaid/:metaidOrGlobalMetaId`（同时支持 metaid 或 globalMetaId） |
| globalMetaID  | `GET /api/info/globalmetaid/:globalMetaID` |

- 成功响应：`{ "code": 1, "data": MetaIDUserInfo }`。
- 展示用字段：`globalMetaId`, `metaid`, `name`, `address`, `avatar`, `avatarId`。其中 `avatar` 为相对路径如 `/content/{avatarPinId}`，`avatarId` 即头像的 pinId。

也可使用 v1 路径：`/api/v1/users/address/:address`、`/api/v1/users/metaid/:metaId`（v1 的 metaid 不支持 globalMetaId，需单独用 `/api/info/globalmetaid/:globalMetaID`）。v1 响应为 `{ "code": 0, "data": IndexerUserInfo }`，头像字段为 `avatarPinId`。

## 头像展示

- **判断是否有头像**：用户信息中 `avatarId`（MetaID 格式）或 `avatarPinId`（v1）非空即有头像。
- **头像图片 URL**（任选其一）：
  - `{BASE}/content/{avatarPinId}`（推荐，根路径）
  - `{BASE}/api/v1/users/avatar/content/{pinId}`
- 示例：`https://file.metaid.io/metafile-indexer/content/abc123...`
- 在 Markdown 中展示：`![avatar](https://file.metaid.io/metafile-indexer/content/{avatarPinId})`

## 根据 pinId 查询文件

1. **文件元数据**：`GET /api/v1/files/:pinId` → 返回 IndexerFileResponse（pinId、name、size、contentType 等）。
2. **文件内容**：
   - 直接内容：`GET /api/v1/files/content/:pinId` → 二进制流，按 Content-Type/文件名处理。
   - 加速（重定向 OSS）：`GET /api/v1/files/accelerate/content/:pinId` → 307 重定向，适合前端或下载链接。

流程：先用 `/api/v1/files/:pinId` 取元数据，再按需调用 content 或 accelerate 获取内容或下载链接。

## 使用请求脚本

技能提供可执行脚本 `scripts/query_indexer.py`，对上述 Base URL 发起 GET 请求，无需手写 HTTP 调用。

- **查用户**（三选一）：
  - `python3 scripts/query_indexer.py user --address <address>`
  - `python3 scripts/query_indexer.py user --metaid <metaid>`
  - `python3 scripts/query_indexer.py user --globalmetaid <globalMetaID>`
- **查文件**：
  - `python3 scripts/query_indexer.py file --pinid <pinId>`

脚本内 Base URL 固定为 `https://file.metaid.io/metafile-indexer`；可通过环境变量 `METAFS_INDEXER_BASE_URL` 覆盖（如本地或测试环境）。

- **输出**：stdout 为完整 JSON（便于管道处理，如 `| jq`）；摘要行打印到 stderr：有头像时输出 `AVATAR_URL=<完整头像图片 URL>`，查文件时输出 `CONTENT_URL=` 与 `ACCELERATE_URL=`。从摘要行即可得到头像展示链接或文件内容/加速下载链接。

## 参考资料

完整 API 路径与响应字段见 [references/api.md](https://skilld.dev/api/skills-raw/metaid-developers/metaapp-skills/metafs-indexer/references/api.md)。
