# Get widget

<div class="cb-api" id="bkmrk-%E8%8E%B7%E5%8F%96%E5%B0%8F%E9%83%A8%E4%BB%B6-get-%2Fv1%2Fwidget"># 获取小部件

<div class="cb-api-endpoint"> <span class="cb-api-method cb-api-method--get">GET</span> <code>&#47;v1&#47;widgets&#47;&#60;var&#62;id&#60;&#47;var&#62;</code> </div>operationId: <code>getWidget</code> · 分组: Widgets · 鉴权: Bearer Token

按 ID 返回单个小部件。路径参数 `id` 为资源主键；响应体字段以本文示例为准（可替换为你的 OAS 示例）。

## Path 参数

<table class="cb-api-table"> <thead> <tr><th>名称</th><th>位置</th><th>类型</th><th>必填</th><th>说明</th></tr> </thead> <tbody> <tr> <td><code>id</code></td> <td>path</td> <td><span class="cb-api-type">string</span></td> <td><span class="cb-api-required">必填</span></td> <td>小部件 ID</td> </tr> </tbody> </table>

 <details class="cb-api-fold" open=""> <summary>Header 参数</summary>

<table class="cb-api-table"> <thead> <tr><th>名称</th><th>位置</th><th>类型</th><th>必填</th><th>说明</th></tr> </thead> <tbody> <tr> <td><code>Authorization</code></td> <td>header</td> <td><span class="cb-api-type">string</span></td> <td><span class="cb-api-required">必填</span></td> <td><code>Bearer &#60;token&#62;</code></td> </tr> </tbody> </table>

 </details> <details class="cb-api-fold"> <summary>请求示例</summary>

<div class="cb-api-example"> <span class="cb-api-example__label">curl（静态示例；本页无试调表单）</span>

```
curl -sS 'https://api.example.com/v1/widgets/wdg_42' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json'
```

 </div><div class="cb-api-example"> <span class="cb-api-example__label">fetch</span>

```
fetch('https://api.example.com/v1/widgets/wdg_42', {
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Accept': 'application/json'
  }
}).then(r => r.json())
```

 </div> </details>## 响应

### <span class="cb-api-status">200</span> 成功

<div class="cb-api-example"> <span class="cb-api-example__label">application/json</span>

```
{
  "id": "wdg_42",
  "name": "Demo Widget",
  "status": "active",
  "updated_at": "2026-11-02T08:00:00Z"
}
```

 </div>### <span class="cb-api-status cb-api-status--err">404</span> 未找到

ID 不存在或不在当前鉴权范围。

<div class="cb-api-example">

```
{
  "error": {
    "code": 404,
    "message": "Widget not found"
  }
}
```

 </div></div>