文档
刀具路径
保存加工程序、绘图关联和经过验证的便携式制造文档。
从英文自动翻译。 查看英文原文
将这些请求发送到您自己正在运行的 sidecar。值保留在此浏览器中。
这是如何运作的
sidecar 侦听启动时选择的环回端口并将其打印在其中 ready 线;使用该 URL 和 CADCAMFUN_TOKEN 它是从开始的。请求直接从该页面发送到该地址。
sidecar 仅将 CORS 标头发送到 Tauri 源并发送到 http://localhost 或 http://127.0.0.1 在任何端口上。浏览器会阻止托管文档的响应,因此请在本地运行文档(bun run dev 中 packages/web) 使用游乐场,或将请求复制为curl。要在不接触真实数据的情况下进行实验,请使用以下命令启动 sidecar CADCAMFUN_DATA_DIR 指向一个一次性目录 - 请参阅 aPI 演练.
运营
9 个端点,位于 toolpaths 组,由 sidecar 自己生成 开放API文档。受保护的操作需要 Authorization: Bearer $CADCAMFUN_TOKEN;看 验证。行为和限制在 子系统指南.
| 得到 | /api/toolpaths | toolpaths.list |
| 邮政 | /api/toolpaths | toolpaths.create |
| 得到 | /api/toolpaths/{id} | toolpaths.get |
| 放 | /api/toolpaths/{id} | toolpaths.update |
| 删除 | /api/toolpaths/{id} | toolpaths.remove |
| 得到 | /api/toolpaths/{id}/setup-sheet | toolpaths.setupSheet |
| 邮政 | /api/toolpaths/post-check | toolpaths.postCheck |
| 得到 | /api/drawings/{id}/toolpaths | toolpaths.listForDrawing |
| 邮政 | /api/drawings/{id}/toolpaths | toolpaths.createForDrawing |
/api/toolpaths
toolpaths.list 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| projectId | 询问 | 细绳 | null | 选修的 |
| 类型 | 询问 | 细绳 | null | 选修的 |
| operationType | 询问 | 细绳 | null | 选修的 |
| 搜索 | 询问 | 细绳 | null | 选修的 |
| 民众 | 询问 | 细绳 | null | 选修的 |
200 数组<对象> application/json
Array<{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null }>
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
响应示例 捕获·200
[] SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsListInput
const result = await client.toolpaths.list({}) curl
curl --request GET "${CADCAMFUN_URL}/api/toolpaths" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
toolpaths.create 需要 Authorization: Bearer <token>.
{ name?: string | null description?: string | null data?: unknown | null gcode?: string | null projectId?: string | null type?: string | null operationType?: string | null isPublic?: boolean | null thumbnail?: string | null materialId?: string | null machineConfigId?: string | null toolId?: string | null simulation?: unknown | null baseUpdatedAt?: string | null }
201 目的 application/json
{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsCreateInput
const result = await client.toolpaths.create({
name: "",
description: "",
data: null,
gcode: "",
projectId: "",
type: "",
operationType: "",
isPublic: false,
thumbnail: "",
materialId: "",
machineConfigId: "",
toolId: "",
simulation: null,
baseUpdatedAt: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/toolpaths" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
toolpaths.get 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
200 目的 application/json
{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null project: { id: string name: string ownerId: string } }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsGetInput
const result = await client.toolpaths.get({
id: "<id>"
}) curl
curl --request GET "${CADCAMFUN_URL}/api/toolpaths/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
toolpaths.update 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
{ name?: string | null description?: string | null data?: unknown | null gcode?: string | null projectId?: string | null type?: string | null operationType?: string | null isPublic?: boolean | null thumbnail?: string | null materialId?: string | null machineConfigId?: string | null toolId?: string | null simulation?: unknown | null baseUpdatedAt?: string | null }
200 目的 application/json
{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null message: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
409 ConflictEncoded application/json
ConflictEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsUpdateInput
const result = await client.toolpaths.update({
id: "<id>",
name: "",
description: "",
data: null,
gcode: "",
projectId: "",
type: "",
operationType: "",
isPublic: false,
thumbnail: "",
materialId: "",
machineConfigId: "",
toolId: "",
simulation: null,
baseUpdatedAt: ""
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/toolpaths/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
toolpaths.remove 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
200 目的 application/json
{ message: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsRemoveInput
const result = await client.toolpaths.remove({
id: "<id>"
}) curl
curl --request DELETE "${CADCAMFUN_URL}/api/toolpaths/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
toolpaths.setupSheet 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
200 目的 application/json
{ data: { title: string jobId: string release: "blocked" | "preview" | "verified-program" material: { name: string iso: string } machine: { name: string post: string } setup: { orientation: string workOffset: string origin: { x: number y: number z: number } stock: { x: number y: number z: number } } tools: Array<{ number: number id: string name: string kind: string diameter: number flutes: number fluteLength: number shankDiameter: number stickout: number holder?: string operations: string[] seconds: number }> operations: Array<{ index: number id: string name: string strategy: string status: "ok" | "failed" tool?: number seconds: number cutLength: number removedVolume: number rpm?: number feed?: number ap?: number ae?: number warnings: string[] }> totals: { tools: number operations: number cycleSeconds: number cuttingSeconds: number removedVolume: number } claims: Array<{ id: string status: string detail: string }> notes: string[] issues: Array<{ severity: string message: string }> identity: { job: string part: string nc: string algorithm: string } titleBlock?: { [key: string]: string | number } } html: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
获取示例
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/toolpaths/${id}/setup-sheet`, {
method: "GET",
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
}) curl
curl --request GET "${CADCAMFUN_URL}/api/toolpaths/<id>/setup-sheet" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
/api/toolpaths/post-check
toolpaths.postCheck 需要 Authorization: Bearer <token>.
{ definition: unknown sample?: boolean }
200 目的 application/json
{ valid: boolean issues: Array<{ path: string message: string }> sample?: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
获取示例
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/toolpaths/post-check`, {
method: "POST",
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
}) curl
curl --request POST "${CADCAMFUN_URL}/api/toolpaths/post-check" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
/api/drawings
toolpaths.listForDrawing 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
200 数组<对象> application/json
Array<{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null Material: { id: string name: string } | null MachineConfig: { id: string name: string type: string } | null Tool: { id: string name: string type: string diameter: number | "Infinity" | "-Infinity" | "NaN" } | null }>
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsListForDrawingInput
const result = await client.toolpaths.listForDrawing({
id: "<id>"
}) curl
curl --request GET "${CADCAMFUN_URL}/api/drawings/<id>/toolpaths" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" 尝试一下
toolpaths.createForDrawing 需要 Authorization: Bearer <token>.
| 姓名 | 在 | 类型 | 必需的 |
|---|---|---|---|
| iD | 小路 | 细绳 | 必需的 |
{ name?: string | null description?: string | null data?: unknown | null gcode?: string | null projectId?: string | null type?: string | null operationType?: string | null isPublic?: boolean | null thumbnail?: string | null materialId?: string | null machineConfigId?: string | null toolId?: string | null simulation?: unknown | null baseUpdatedAt?: string | null }
201 目的 application/json
{ id: string name: string description: string | null data: unknown type: string | null operationType: string | null gcode: string | null thumbnail: string | null isPublic: boolean projectId: string createdAt: string updatedAt: string createdBy: string drawingId: string | null materialId: string | null toolId: string | null machineConfigId: string | null }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
SDK示例
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// ToolpathsCreateForDrawingInput
const result = await client.toolpaths.createForDrawing({
id: "<id>",
name: "",
description: "",
data: null,
gcode: "",
projectId: "",
type: "",
operationType: "",
isPublic: false,
thumbnail: "",
materialId: "",
machineConfigId: "",
toolId: "",
simulation: null,
baseUpdatedAt: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/drawings/<id>/toolpaths" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json 尝试一下
模式
可从该组的参数、主体和响应访问命名模式。一个 ? 标记可选字段; | null 标记可能存在空值的字段。
BadRequestEncoded{ _tag: "BadRequest" message: string }
ConflictEncoded{ _tag: "Conflict" message: string }
ForbiddenEncoded{ _tag: "Forbidden" message: string }
InternalErrorEncoded{ _tag: "InternalError" message: string }
NotFoundEncoded{ _tag: "NotFound" message: string }
呼叫该群组
操作 ID 的形式为 toolpaths.<name>。生成的Promise SDK(@cadcamfun/api/sdk)将其中大部分暴露为 client.<namespace>.<method>(input), 在哪里 input 是路径参数和主体字段的一个平面对象;每张卡的 SDK 示例显示了确切的访问器和输入类型。不会生成分段上传、二进制或 JavaScript 响应以及原始 Webhook;这些卡片显示 fetch 改为。
import { CadCam, ClientError } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
try {
await client.projects.list()
} catch (error) {
if (error instanceof ClientError) {
// Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
} else {
// a declared error body: switch on error._tag
}
} 故障排除
| 症状 | 可能的原因 | 使固定 |
|---|---|---|
| 每次调用 401 | 上次启动的令牌或丢失 Bearer 前缀 | 发送 Authorization: Bearer <token> 使用边车启动时的令牌。 |
| 在任何事情发生之前的 400 | 主体或参数与架构不匹配 | 将有效负载与卡上的请求架构进行比较。 |
| 在别处可见的记录上出现 403 或 404 | 代理账户不同 | 发送正确的 x-session-token,或使用拥有该记录的本地配置文件。 |
| 409 | 状态冲突,例如重复的名称或过时的分支头 | 重新读取资源并使用当前数据重试。 |
| 尝试显示“被 CORS 阻止” | 这些文档是从非环回源提供的 | 在本地运行文档或将请求复制为curl。 |
| 连接被拒绝 | Sidecar 在新端口上重新启动 | 从新读取端口 ready 行。 |