bagisto-api-admin
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBuild an admin app on the Bagisto Admin API
基于Bagisto Admin API构建管理应用
Implement any admin/back-office interface on the Bagisto Admin API ( REST + ). The API mirrors the Bagisto admin panel menu-for-menu, so any admin screen can be rebuilt from it. This skill is a router: it gives the flow and points you at the per-menu reference page; the reference pages carry the endpoints, UI/UX, and checklists.
/api/admin/*POST /api/admin/graphql在Bagisto Admin API( REST + )上实现任意管理/后台界面。该API与Bagisto管理面板的菜单完全对应,因此任何管理界面都可以通过它重新构建。此技能是一个路由工具:它提供流程指引,并指向对应菜单的参考页面;参考页面包含端点、UI/UX和检查清单。
/api/admin/*POST /api/admin/graphql⚠️ Load these FIRST (before any code)
⚠️ 请先加载这些内容(编写代码前)
- — admin auth (the Integration Bearer token), the
reference/connecting-to-the-api.mdlisting envelope, the list→detail→action pattern, permissions, errors, and the verify-before-coding protocol.{data,meta} - — if the client picked GraphQL: the admin endpoint, the result-field/
reference/graphql.mdrule, camelCase inputs + filter args, cursor pagination.id
The api-docs are the source of truth for exact shapes — (Admin API section) + its index. The reference pages name the endpoints and flow; open the linked docs page for the precise body/response before writing the call. Never invent a payload from memory.
https://api-docs.bagisto.com/llms.txt- —— 管理端认证(Integration Bearer令牌)、
reference/connecting-to-the-api.md列表包、列表→详情→操作模式、权限、错误处理,以及编码前的验证协议。{data,meta} - —— 如果客户选择GraphQL:管理端端点、结果字段/
reference/graphql.md规则、驼峰式输入+过滤参数、游标分页。id
API文档是精确数据结构的唯一依据 —— 访问(Admin API板块)及其索引。参考页面会列出端点和流程;在编写调用代码前,请打开链接的文档页面查看精确的请求体/响应内容。切勿凭记忆编造请求负载。
https://api-docs.bagisto.com/llms.txtStep 1 — ask the client (CRITICAL, before building)
步骤1 —— 询问客户(至关重要,开始构建前)
- Platform — web, mobile (native/cross-platform), desktop?
- Framework/stack — React/Next, Vue/Nuxt, Flutter, React Native, plain JS?
- Which admin menus — Sales, Catalog, Customers, Marketing, CMS, Settings, Configuration, Dashboard/Reporting — or one first?
- Transport — REST or GraphQL? (REST for list/detail/action screens; GraphQL when a screen needs many related fields in one round-trip. Both fully supported.)
- First screen/flow — order list + actions, product management, Create-Order, a dashboard, …?
Confirm, then tailor everything to the answers. Don't assume a stack.
- 平台 —— Web、移动端(原生/跨平台)、桌面端?
- 框架/技术栈 —— React/Next、Vue/Nuxt、Flutter、React Native、纯JS?
- 涉及哪些管理菜单 —— 销售、商品目录、客户、营销、CMS、设置、配置、仪表板/报表 —— 还是先做其中一个?
- 传输方式 —— REST还是GraphQL?(REST适用于列表/详情/操作界面;当界面需要一次请求获取多个关联字段时使用GraphQL。两者均完全支持。)
- 首个界面/流程 —— 订单列表+操作、商品管理、创建订单、仪表板……?
确认以上信息后,根据答案定制所有内容。请勿假设技术栈。
The core admin pattern: list → detail → action
核心管理模式:列表 → 详情 → 操作
Almost every admin screen is the same shape (detailed in ):
connecting-to-the-api.md- List — →
GET /api/admin/<resource>envelope; drive tables with{ data, meta }+?page=+ the screen's filters.?per_page= - Detail — → full record, relations embedded (no follow-up calls).
GET /api/admin/<resource>/{id} - Action — for create/update/delete + per-record actions (cancel order, create invoice, mass-update, …), each with its own eligibility rules.
POST/PUT/DELETE
几乎所有管理界面都遵循相同的结构(中有详细说明):
connecting-to-the-api.md- 列表 —— → 返回
GET /api/admin/<resource>包;通过{ data, meta }+?page=+ 界面专属过滤器来驱动表格展示。?per_page= - 详情 —— → 返回完整记录,包含嵌入的关联数据(无需后续调用)。
GET /api/admin/<resource>/{id} - 操作 —— 使用进行创建/更新/删除操作,以及每条记录的专属操作(取消订单、创建发票、批量更新等),每个操作都有自己的适用规则。
POST/PUT/DELETE
Step 2 — open the reference for the menu
步骤2 —— 打开对应菜单的参考文档
Flagship flow
核心流程
| Page | Build this |
|---|---|
| The admin Create-Order flow (place an order for a customer via a draft cart) |
| 页面 | 构建内容 |
|---|---|
| 管理端创建订单流程(通过草稿购物车为客户下单) |
Menus (mirror the admin sidebar)
菜单(与管理侧边栏完全对应)
| Page | Covers |
|---|---|
| Orders (list/detail + cancel/comment/invoice/shipment/refund), Invoices, Shipments, Refunds, Transactions, Bookings, CSV exports |
| Products (datagrid + CRUD + images/inventory/customer-group-prices + mass actions), Categories (+tree), Attributes (+options), Attribute Families |
| Customers (CRUD + addresses/notes/impersonate), Groups, Reviews, GDPR |
| Cart Rules (+coupons), Catalog Rules, Email Templates, Events, Campaigns, Subscribers, Search Terms/Synonyms, URL Rewrites, Sitemaps |
| CMS Pages |
| Currencies, Channels, Locales, Exchange Rates, Inventory Sources, Tax Rates/Categories, Roles, Users, Themes, Data-Transfer Imports |
| Store configuration (schema / values / update) |
| Dashboard stats + Reporting (sales/customers/products + export) |
| 页面 | 涵盖内容 |
|---|---|
| 订单(列表/详情 + 取消/备注/开票/发货/退款)、发票、发货单、退款单、交易记录、预订、CSV导出 |
| 商品(数据网格 + CRUD + 图片/库存/客户组价格 + 批量操作)、分类(树形结构)、属性(含选项)、属性组 |
| 客户(CRUD + 地址/备注/模拟登录)、客户组、评论、GDPR合规 |
| 购物车规则(含优惠券)、商品目录规则、邮件模板、活动、营销活动、订阅者、搜索词/同义词、URL重写、站点地图 |
| CMS页面 |
| 货币、渠道、区域设置、汇率、库存来源、税率/税分类、角色、用户、主题、数据传输导入 |
| 店铺配置(Schema / 配置值 / 更新) |
| 仪表板统计 + 报表(销售/客户/商品 + 导出) |
Discovery — don't hardcode the nav or permissions
发现环节 —— 不要硬编码导航或权限
Two read-only endpoints (REST + GraphQL) tell you what the current token can do — drive navigation and action-gating from them instead of hardcoding:
- (
GET /api/admin/menu) — the admin sidebar as a permission-filtered tree; each node maps to its API endpoint (getAdminMenu, orapiResource: { rest, graphql }for group headers / panel-only screens).null - (
GET /api/admin/permissions) — the token's effectivegetAdminPermissions({ permissionType, permissions }= full access).["*"]
Details in .
reference/connecting-to-the-api.md有两个只读端点(REST + GraphQL)可以告诉你当前令牌的权限范围——请根据这些端点的返回结果来驱动导航和操作权限控制,而非硬编码:
- (
GET /api/admin/menu)—— 返回经过权限过滤的树形管理侧边栏;每个节点都映射到对应的API端点(getAdminMenu,对于分组标题/仅面板界面则为apiResource: { rest, graphql })。null - (
GET /api/admin/permissions)—— 返回令牌的有效权限getAdminPermissions({ permissionType, permissions }表示完全访问)。["*"]
详细内容见。
reference/connecting-to-the-api.mdConsolidated critical rules
关键规则汇总
- Verify before coding. PAUSE → open the endpoint's docs page (or query the MCP) → confirm method/fields → implement → check types.
- Auth: every call sends (a pre-issued admin Integration token). There's no login endpoint — the token is made in the store's admin panel. The admin GraphQL endpoint is
Authorization: Bearer <id>|<token>(admin token only; not the shop endpoint, no storefront key).POST /api/admin/graphql - Permissions: a token is capped by its admin's role — an endpoint the role can't reach returns 403. Build for that.
- Listings are (+
{ data, meta }headers); page withX-Total-*/?page=(default 10, cap 50) + the per-screen filters.?per_page= - GraphQL action mutations (cancel/invoice/shipment/refund/place-order/cart writes/mass-actions) return result fields, not a generic ; inputs are camelCase; custom filter args are documented per page. See
id.reference/graphql.md - Don't hardcode dynamic data (shipping/payment methods in Create-Order, config options) — fetch it.
- 编码前验证:暂停→打开端点的文档页面(或查询MCP)→确认请求方法/字段→实现→检查类型。
- 认证:每次调用都需携带(预先颁发的管理端Integration令牌)。没有登录端点——令牌需在店铺管理面板中生成。管理端GraphQL端点为
Authorization: Bearer <id>|<token>(仅支持管理端令牌;不是店铺前端端点,无需店铺密钥)。POST /api/admin/graphql - 权限:令牌的权限受所属管理员角色限制——角色无权访问的端点会返回403。请针对这种情况进行开发。
- 列表返回(+
{ data, meta }响应头);使用X-Total-*/?page=进行分页(默认10条,上限50条)+ 界面专属过滤器。?per_page= - GraphQL操作突变(取消/开票/发货/退款/下单/购物车写入/批量操作)返回结果字段,而非通用;输入参数为驼峰式;自定义过滤参数在对应页面中有文档说明。详见
id。reference/graphql.md - 不要硬编码动态数据(创建订单中的配送/支付方式、配置选项)——请通过API获取。