跳到主要内容

产品品牌 API

本 API 提供了访问产品品牌信息的接口。

功能描述:

该 API 允许您:

  • 查询所有可用的品牌。
  • 根据品牌 ID 获取特定品牌的详细信息。
  • 根据品牌名称进行模糊搜索。

API 端点:

  • GET /api/v1/brands: 获取所有品牌。
  • GET /api/v1/brands/{brand_id}: 获取指定 ID 的品牌。

请求参数:

参数名类型描述是否必选
brand_idint品牌 ID。仅在 GET /api/v1/brands/{brand_id} 中使用。
querystring搜索关键词。仅在 GET /api/v1/brands 中使用。

响应格式:

响应以 JSON 格式返回。

示例:

  • 获取所有品牌:

    GET /api/v1/brands

    响应:

    [
    {
    "id": 1,
    "name": "Brand A",
    "description": "Description for Brand A"
    },
    {
    "id": 2,
    "name": "Brand B",
    "description": "Description for Brand B"
    }
    ]
  • 获取指定 ID 的品牌:

    GET /api/v1/brands/1

    响应:

    {
    "id": 1,
    "name": "Brand A",
    "description": "Description for Brand A"
    }
  • 根据品牌名称进行模糊搜索:

    GET /api/v1/brands?query=Brand%20A

    响应:

    [
    {
    "id": 1,
    "name": "Brand A",
    "description": "Description for Brand A"
    }
    ]

错误处理:

API 使用标准的 HTTP 状态码来指示操作的成功或失败。

  • 200 OK: 请求成功。
  • 400 Bad Request: 请求参数无效。
  • 404 Not Found: 资源未找到。
  • 500 Internal Server Error: 服务器内部错误。

版本:

v1.0

注意事项:

  • 本 API 仅适用于 %s 产品。
  • 请勿滥用 API,否则可能被限制访问。
  • 对于 Pro 版本,请联系您的管理员获取 API 密钥。
  • 更多信息,请访问 https://example.com/api-documentation
  • 如果遇到问题,请联系我们的技术支持团队:support@example.com
  • 本 API 遵循 RESTful 架构风格。
  • {name} 是一个占位符,表示用户的姓名。
  • %d 是一个整数占位符。
  • %s 是一个字符串占位符。
  • 本 API 支持多种数据格式,包括 JSON 和 XML。
  • 本 API 提供了详细的日志记录功能,方便问题排查。
  • 本 API 具有高可用性和可扩展性。
  • 本 API 提供了完善的安全性机制,保护您的数据安全。
  • 本 API 持续更新和改进,以满足您的需求。
  • 本 API 的使用需要遵守我们的服务条款。
  • 本 API 提供了多种认证方式,包括 API 密钥和 OAuth 2.0。
  • 本 API 提供了详细的文档和示例代码,方便您快速上手。
  • 本 API 团队致力于为您提供优质的技术支持。
  • 本 API 遵循最佳实践,确保代码质量和可维护性。
  • 本 API 具有良好的性能和响应速度。
  • 本 API 提供了多种监控指标,方便您了解 API 的运行状态。
  • 本 API 具有强大的错误处理能力,能够快速恢复。
  • 本 API 遵循开放标准,方便与其他系统集成。
  • 本 API 具有良好的兼容性,支持多种操作系统和编程语言。
  • 本 API 提供了多种部署选项,包括云端和本地部署。
  • 本 API 具有良好的可扩展性,能够满足您的业务增长

列出产品品牌

GET /products/brands
属性类型必需描述
context字符串发送请求的范围;决定响应中包含的字段。
page整数集合的当前页。默认为 1
per_page整数结果集中返回的最大项目数。默认为无限制。允许的值在 0100 之间。
search字符串限制结果,仅包含匹配的字符串。
exclude数组确保结果集排除特定的 ID。
include数组限制结果集为特定的 ID。
order字符串升序或降序排序。允许的值:asc, desc。默认为 asc
orderby字符串按属性排序。允许的值:name, slug, count。默认为 name
hide_empty布尔值如果为 true,则不返回空项。默认为 true
parent整数限制结果,仅包含具有特定父级 ID 的项。
curl "https://example-store.com/wp-json/wc/store/v1/products/brands"

示例响应:

[
{
"id": 16,
"name": "Nike",
"slug": "nike",
"description": "This is the Nike brand.",
"parent": 0,
"count": 11,
"image": {
"id": 55,
"src": "https://store.local/wp-content/uploads/2021/11/nike-logo.jpg",
"thumbnail": "https://store.local/wp-content/uploads/2021/11/nike-logo-324x324.jpg",
"srcset": "https://store.local/wp-content/uploads/2021/11/nike-logo.jpg 800w, https://store.local/wp-content/uploads/2021/11/nike-logo-324x324.jpg 324w, https://store.local/wp-content/uploads/2021/11/nike-logo-100x100.jpg 100w, https://store.local/wp-content/uploads/2021/11/nike-logo-416x416.jpg 416w, https://store.local/wp-content/uploads/2021/11/nike-logo-300x300.jpg 300w, https://store.local/wp-content/uploads/2021/11/nike-logo-150x150.jpg 150w, https://store.local/wp-content/uploads/2021/11/nike-logo-768x768.jpg 768w",
"sizes": "(max-width: 800px) 100vw, 800px",
"name": "nike-logo.jpg",
"alt": ""
},
"review_count": 2,
"permalink": "https://store.local/product-brand/nike/"
},
{
"id": 21,
"name": "Adidas",
"slug": "adidas",
"description": "",
"parent": 0,
"count": 1,
"image": null,
"review_count": 1,
"permalink": "https://store.local/product-brand/adidas/"
}
]

产品品牌列表

以下是产品品牌的列表。每个品牌都有一个名称、别名、描述、父级、计数、图像、评价计数和固定链接。

品牌信息

  • 名称 (Name): 品牌名称。
  • 别名 (Slug): 品牌的别名,用于生成 URL。
  • 描述 (Description): 品牌的详细描述。
  • 父级 (Parent): 父级品牌的 ID。如果品牌是顶级品牌,则为 0。
  • 计数 (Count): 品牌下的产品数量。
  • 图像 (Image): 品牌的图像信息,包括 ID、源地址、缩略图地址、srcset、sizes、名称和 alt 文本。
  • 评价计数 (Review Count): 品牌的评价数量。
  • 固定链接 (Permalink): 品牌的固定链接地址。

示例

以下是两个产品品牌的示例:

上传图像

您可以通过以下步骤上传图像:

  1. 点击“上传”按钮。
  2. 选择要上传的图像文件。
  3. 填写图像的标题、描述和 alt 文本。
  4. 点击“插入到内容”按钮。

调整图像大小

您可以通过以下方法调整图像大小:

  • 使用图像编辑软件调整图像大小。
  • 在 WordPress 中使用图像编辑插件调整图像大小。

更多信息

有关更多信息,请查看 WordPress 文档或联系技术支持。

您可以在本地服务器上查看日志文件,以获取更多信息。

请注意,Width 属性表示图像的宽度。Brand 属性表示品牌。Store 属性表示商店。Log 属性表示日志。In 预示着某个位置。and 连接两个词语。View 动作表示查看。

单个品牌

获取单个品牌信息。

GET /products/brands/:id

或者

GET /products/brands/:slug
参数类型必填描述
identifier字符串用于获取品牌的标识符。可以是品牌 ID 或别名。
curl "https://example-store.com/wp-json/wc/store/v1/products/brands/1"

或者

curl "https://example-store.com/wp-json/wc/store/v1/products/brands/adidas"

示例回复:

{
"id": 1,
"name": "Adidas",
"slug": "adidas",
"description": "",
"parent": 0,
"count": 1,
"image": null,
"review_count": 1,
"permalink": "https://store.local/product-brand/adidas/"
}