api.tools

fetch · type design

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

تحوّل صفحة منشورة إلى طبقات قابلة للتعديل — إطارات ونصوص وصور ورسوم متجهية، مع auto layout حيث تستخدم الصفحة flexbox. رصيد واحد، مثل لقطة الشاشة. SDK 0.4.9+.

1 creditcached one hour6,000 layers at most
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

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 }
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"}

طبقة

{ 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 نسبيّان إلى العنصر الأب.

ما يُحتفظ به، وإلامَ يتحول كل شيء

  • تتحول حاوية flex إلى auto layout: الاتجاه والتباعد والحشو والمحاذاة والالتفاف.
  • الصندوق الذي لا يحوي إلا نصًا هو ذلك النص بأسلوبه.
  • يبقى SVG ملف SVG، ويُعرض كصورة — ولا يُنفَّذ أبدًا.
  • تُستبعد العناصر المخفية والنصوص البرمجية والأنماط.
  • بعد 6000 طبقة يتوقف الاستيراد ويعلن ذلك بـ truncated: true.

القواعد نفسها التي تحكم لقطة الشاشة

مرشّح العناوين نفسه — يُرفض العنوان الخاص قبل احتساب أي رسوم —، وذاكرة التخزين المؤقت نفسها لمدة ساعة، فلا يكلّف الاستيراد نفسه شيئًا في المرة الثانية، والقيم نفسها لـ viewport وwait.