# fetch · type design

Canonical URL: https://developers.iagenify.com/zh/sdk/ref/tools/fetch-design/
Language: zh

`api.tools.fetch({ url, type: "design", viewport?, wait? }) → Promise<{ design, title, url, creditsUsed, cached }>`

将在线页面转换为可编辑的图层——框架、文本、图片和矢量，页面使用 flexbox 的地方会转为自动布局。1 个积分，与截图相同。SDK 0.4.9+。

Status: 1 credit · cached one hour · 6,000 layers at most

```javascript
const { design } = await api.tools.fetch({
  url: "https://example.com/",
  type: "design",
  viewport: { width: 1440, height: 900 },
});
// design: { width, height, document: { type: "frame", children: [...] }, assets, fonts, nodeCount, truncated }
```

## 一个图层 {#layer}

`{ type, id, name, x, y, width, height, opacity, rotation, visible, clip, fills, strokes, strokeWeight, radii, effects, layout, text, svg, children }`，其中 `type` 为 `frame`、`text`、`rectangle` 或 `vector`，x 和 y 相对于父元素。

## 保留什么，以及什么会变成什么 {#rules}

- flex 容器会变成自动布局：方向、间距、内边距、对齐和换行。
- 只包含一段文本的盒子就是这段文本本身，并保留其样式。
- SVG 仍然是 SVG，以图片形式显示——绝不会被执行。
- 隐藏元素、脚本和样式会被略去。
- 超过 6,000 个图层时，导入会停止，并通过 `truncated: true` 说明。

## 与截图相同的规则 {#billing}

相同的地址过滤——私有地址会在任何扣费之前被拒绝——相同的一小时缓存，因此同一次导入第二次不收费，以及相同的 `viewport` 和 `wait`。

- [fetch()](/zh/sdk/ref/tools/fetch): 以文本形式获取页面。
- [screenshot](/zh/sdk/ref/tools/screenshot): 以图片形式获取页面。

```python
result = api.tools.fetch({
    "url": "https://example.com/",
    "type": "design",
    "viewport": {"width": 1440, "height": 900},
})
design = result["design"]
# {"width", "height", "document": {"type": "frame", "children": [...]}, "assets", "fonts", "nodeCount", "truncated"}
```
