public-api
预览截图
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "public-api":https://skillpi.com/zh/skills/deepskill-b002e4e8eeca21066c2830d21665e29975cc439d09f934de92fa23d7525c542a。安装前核对上游来源和版本:https://github.com/n8n-io/n8n。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
公共 API(public-api)技能。用于添加、迁移或更新带有 @PublicApiController 的 n8n 公共 API v1 端点,包括公共 DTO、API 密钥与 RBAC 范围、游标分页、与 OpenAPI 和覆盖率集成,以及相关测试。适用于在 packages/cli/src/public-api/v1/ 目录下工作,或在通过 /api/v1 暴露现有服务时使用。
介绍来源: third_party · n8n-io · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 来源文档未说明。
- 适合谁
- 来源文档未说明。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: n8n:public-api
description: >-
Adds, migrates, or updates n8n Public API v1 endpoints with @PublicApiController
— public DTOs, API-key and RBAC scopes, cursor pagination, OpenAPI + coverage
wiring, and tests. Use when working under packages/cli/src/public-api/v1/ or
when exposing an existing service through /api/v1.Public API v1
Public API v1 lives in packages/cli/src/public-api/v1/, mounted at /api/v1
with API-key auth and public error formatting via PublicApiControllerRegistry
(packages/cli/src/public-api/public-api-controller.registry.ts).
Two rule tiers: invariants (never break) and team defaults (follow unless an existing public contract forces otherwise). When this skill and the code disagree on a detail, the code wins — so open the files below. That is a reason to check the code, not license to drop a team default.
Non-negotiable rules
- New endpoints are
@PublicApiControllerclasses underv1/controllers/, one*.public.controller.tsper feature. A controller is a class — neverexport =(the legacy tuple style;require-public-api-controllerflags it). - Public API and internal REST are separate HTTP surfaces. A public controller never calls an internal controller/endpoint; both reuse the same service.
- Controllers and handlers delegate to a service — never import a repository or
Container.get(…Repository)(no-repository-in-public-api-handler). - Input/output go through DTOs from
@n8n/api-types; every JSON route declares@ApiResponse(Dto). - Register each controller via a side-effect import in
v1/controllers/index.ts(public-api-controllers.test.tsfails otherwise). - Don't add business logic to legacy
express-openapi-validator(EOV) handlers. - Migrating a legacy endpoint must not change its public contract.
These are n8n-local-rules ESLint rules (see packages/cli/eslint.config.mjs)
and can't be silenced inline (no-public-api-guardrail-disable). The off
allowlist there covers pre-existing legacy files only — it's shrink-only, don't
add to it.
Team defaults
- List endpoints: cursor-based pagination (internal API uses both cursor- and page-based — don't copy an internal endpoint's model).
- Updates: full-object
PUT, notPATCH. A successfulGETbody should be acceptable as aPUTbody for the same resource (round-trip), aside from server-managed/immutable fields. - Strict input DTOs; output DTOs are an allowlist of public fields.
- Never return real secrets/tokens in responses or error details — mask with the
resource's sentinel/placeholder (or omit). Echoing that sentinel on
PUTmeans keep; any other value replaces. Detail: Updates and write-only secrets. - "Test connection/config" endpoints validate the request body (test-before-save).
Architecture
Public and internal are sibling routes over one shared, HTTP-agnostic service; neither calls the other.
GET /rest/tags → TagsController ┐ JWT auth, internal shape
├─→ TagService
GET /api/v1/tags → TagsPublicController ┘ API-key auth, public DTO
Reuse the service behavior. Reuse a DTO only when public and internal contracts are intentionally identical; otherwise make a public-specific DTO that doesn't depend on a UI-oriented internal shape.
Before editing
Open these — they are the source of truth, not this skill:
v1/controllers/— copy structure fromtags.public.controller.ts(list + cursor) orworkflows.public.controller.ts(@Param+@ProjectScope), andindex.tsfor the barrel.- Decorators in
packages/@n8n/decorators/src/controller/:public-api-controller.ts,api-key-scope.ts,api-response.ts,api-error-response.ts,api-summary.ts,api-description.ts,api-tags.ts,route.ts,scoped.ts,args.ts,licensed.ts. - The OpenAPI generator (reads the decorators above, no hand-written YAML
needed for a controller route):
v1/openapi-gen/generate.ts,v1/openapi-gen/decorator-routes.ts. - Pagination helpers:
v1/shared/services/pagination.service.ts(decodeCursor,encodeNextCursor). - DTOs:
packages/@n8n/api-types/src/dto/. - Gating tests:
v1/__tests__/public-api-controllers.test.ts,v1/__tests__/scope-parity.test.ts,v1/openapi-gen/__tests__/generated-spec-drift.test.ts. - The internal controller for this resource and its neighboring functional tests.
Declaring a controller
A controller is a class marked @PublicApiController('/base') that injects the
shared service via its constructor and delegates to it. Copy the shape from an
existing controller in v1/controllers/ with the same operation type and auth
model; reuse only what applies. Decorators, all from @n8n/decorators:
| Decorator | Use |
|---|---|
@PublicApiController('/base') |
Class marker; mounts routes at /api/v1/base. |
@Get/@Post/@Put/@Patch/@Delete('/path') |
Route method. |
@ApiKeyScope('res:action') |
API-key grant check. |
@ProjectScope/@GlobalScope('res:action') |
User RBAC check. |
@ApiResponse(status) / @ApiResponse(status, Dto) |
Success status + (optional) output DTO; registry .parse()s + strips the return value. Exactly one per route — a second @ApiResponse throws. 204 can't carry a DTO — throws. |
@ApiErrorResponse(status) |
Declares an additional documented non-2xx status (e.g. 404, 409). Stack multiple for more than one. 400/401/403 are added automatically (body/query present, always, and @ApiKeyScope present, respectively) — don't declare those yourself. |
@ApiSummary(text) / @ApiDescription(text) / @ApiTags([...]) |
OpenAPI summary/description/tags. @ApiTags sorts alphabetically regardless of the order you pass. All optional but expected on every real route. |
@Query / @Body / @Param('name') |
Bind + validate via a Z.class DTO / path param. |
@Licensed('feat') |
Gates the route on a single BooleanLicenseFeature; PublicApiControllerRegistry runs its own license middleware (after auth/@ApiKeyScope/@ProjectScope |
Authorization (easy to get wrong)
@ApiKeyScope(what the API key is granted) and@ProjectScope/@GlobalScope(what the user may do) are independent. Use both when the model needs both.@ProjectScopereadsreq.paramsas-is and does not remapid— name the path param what the resolver expects (workflowId,credentialId,projectId,dataTableId, …). A genericidoften fails.@ApiKeyScopetakes a string,{ anyOf: [...] }, or{ allOf: [...] }— never a bare array. The scope must exist in the permissions registry (API_KEY_RESOURCESin@n8n/permissions);scope-parity.test.tsfails on an orphan scope.
DTOs
- Build the public response shape explicitly; don't return an ORM entity and lean
on
@ApiResponsestripping to hide fields. - Treat the output DTO as an allowlist. Re-check nested relations, ownership fields, tokens, and encrypted values.
- Make input DTOs strict so unknown/partial fields aren't silently accepted.
- Secrets: never return a real secret; use the resource's sentinel/placeholder (or omit). See Updates and write-only secrets.
List endpoints (cursor pagination)
Copy the cursor flow from tags.public.controller.ts. Use publicApiPaginationSchema
plus decodeCursor / encodeNextCursor from the shared pagination service; the
cursor is opaque; return { data, nextCursor } (never a bare array) with
nextCursor: null on the last page; an invalid cursor is a 400. Preserve an
existing endpoint's pagination as-is. Detail:
List endpoints and cursor pagination.
Wiring checklist
v1/controllers/<feature>.public.controller.ts+ side-effect import inv1/controllers/index.ts.- Public DTO in
@n8n/api-types+ export from the barrel (src/dto/). @ApiKeyScopevalue exists in the permissions registry.- Don't hand-write the OpenAPI path or
x-required-scopefor a controller route — the generator (v1/openapi-gen/generate.ts) builds it from your decorators (@ApiSummary/@ApiDescription/@ApiTags/@ApiKeyScope/@ApiResponse/@ApiErrorResponse). Run the fullpnpm buildand commit the regeneratedhandlers/<feature>/spec/paths/*.generated.ymlfragment(s) andopenapi.decorator-routes.generated.yml—generated-spec-drift.test.tsfails CI if they're stale.pnpm run build:dataalone is not enough after touching a controller: it runs the generator against the already-compileddist/, so a new/changed controller silently doesn't show up unlesstscran first. - Add the route to
packages/nodes-base/nodes/N8n/n8n-api-coverage.json. - Tests.
Testing
Always cover: happy path, input-validation failure, missing API-key scope, RBAC
denial. Prefer covering the business path in
packages/cli/test/integration/public-api/ (real HTTP + DB); mocked-service unit
tests don't replace that. Add the cases that apply (cursor pages,
not-found/conflict, no sensitive fields, credential keep/replace, migration
contract) — see Testing matrix. Match the nearest
existing tests.
More detail (reference.md)
版本历史
-
[email protected]
GitHub ↗
原版更新说明
## [1.123.100](https://github.com/n8n-io/n8n/compare/[email protected]@1.123.100) (2026-11-20) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/n8n-io/n8n/pull/44590?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/n8n-io/n8n/44590?returnTo=https%3A%2F%2Fgithub.com%2Fn8n-io%2Fn8n%2Fpull%2F44590&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
-
stable
GitHub ↗
原版更新说明
## [2.48.7](https://github.com/n8n-io/n8n/compare/[email protected]@2.48.7) (2026-11-20) ### Bug Fixes * **core:** End memory guard hold when hold-limit stop frees no memory ([#44463](https://github.com/n8n-io/n8n/issues/44463)) ([22643e1](https://github.com/n8n-io/n8n/commit/22643e170e5ae7ddc86bb61b7d1d5d9e1aab1486)) * **core:** Store plain input data in the error output of scripting nodes ([#44530](https://github.com/n8n-io/n8n/issues/44530)) ([c26c923](https://github.com/n8n-io/n8n/commit/c26c923b248d33e80aad51a7abc80aa07eb6c595)) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/n8n-io/n8n/pull/44594?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/n8n-io/n8n/44594?returnTo=https%3A%2F%2Fgithub.com%2Fn8n-io%2Fn8n%2Fpull%2F44594&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
-
[email protected]
GitHub ↗
原版更新说明
## [2.48.7](https://github.com/n8n-io/n8n/compare/[email protected]@2.48.7) (2026-11-20) ### Bug Fixes * **core:** End memory guard hold when hold-limit stop frees no memory ([#44463](https://github.com/n8n-io/n8n/issues/44463)) ([22643e1](https://github.com/n8n-io/n8n/commit/22643e170e5ae7ddc86bb61b7d1d5d9e1aab1486)) * **core:** Store plain input data in the error output of scripting nodes ([#44530](https://github.com/n8n-io/n8n/issues/44530)) ([c26c923](https://github.com/n8n-io/n8n/commit/c26c923b248d33e80aad51a7abc80aa07eb6c595)) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/n8n-io/n8n/pull/44594?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/n8n-io/n8n/44594?returnTo=https%3A%2F%2Fgithub.com%2Fn8n-io%2Fn8n%2Fpull%2F44594&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
-
[email protected]
GitHub ↗
原版更新说明
## [1.123.99](https://github.com/n8n-io/n8n/compare/[email protected]@1.123.99) (2026-11-19) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/n8n-io/n8n/pull/44433?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/n8n-io/n8n/44433?returnTo=https%3A%2F%2Fgithub.com%2Fn8n-io%2Fn8n%2Fpull%2F44433&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
-
[email protected]
GitHub ↗
原版更新说明
## [2.48.6](https://github.com/n8n-io/n8n/compare/[email protected]@2.48.6) (2026-11-19) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/n8n-io/n8n/pull/44436?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/n8n-io/n8n/44436?returnTo=https%3A%2F%2Fgithub.com%2Fn8n-io%2Fn8n%2Fpull%2F44436&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
此处仅展示最近 5 个版本。 在原站查看完整版本历史 ↗
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供了 n8n 公共 API v1 端点的完整开发规范,覆盖控制器、DTO、授权、分页、OpenAPI 集成和测试
亮点
- 触发词精准完整,覆盖多种变体,边界清晰,明确指出了适用场景和使用路径
亮点
- Phase/步骤清晰,有出口条件,含端到端示例,frontmatter完整,单文件≤500行
亮点
- 工具来源明确,参数正确,覆盖主要异常,不可逆操作有确认机制
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 5, 13, 64, 79, 104 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。