Документация
Траектории инструмента
Сохраненные программы обработки, ассоциации чертежей и проверенная переносная производственная документация.
Автоматически переведено с английского. Смотреть оригинал на английском
Отправьте эти запросы на свою работающую сайдкар. Значения остаются в этом браузере.
Как это работает
Сайдкар прослушивает порт обратной связи, выбранный при запуске, и печатает его в своем ready линия; используйте этот URL-адрес и CADCAMFUN_TOKEN с этого началось. Запросы идут прямо с этой страницы на этот адрес.
Sidecar отправляет заголовки CORS только источникам Tauri и http://localhost или http://127.0.0.1 в любом порту. Из размещенных документов браузер блокирует ответ, поэтому запускайте документы локально (bun run dev в packages/web), чтобы использовать игровую площадку, или скопируйте запрос как завиток. Чтобы поэкспериментировать, не затрагивая реальные данные, запустите сайдкар с помощью CADCAMFUN_DATA_DIR указал на одноразовый каталог — см. пошаговое руководство по API.
Операции
9 endpoint в toolpaths группа, созданная на основе собственной сайдкара документ OpenAPI. Защищенные операции занимают 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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
{ 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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
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>.
| Имя | В | Тип | Необходимый |
|---|---|---|---|
| идентификатор | путь | нить | необходимый |
{ 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 }
Звонок в эту группу
Идентификаторы операций имеют вид toolpaths.<name>. Сгенерированный Promise SDK (@cadcamfun/api/sdk) выставляет большинство из них как client.<namespace>.<method>(input), где input представляет собой один плоский объект параметров пути и полей тела; В примере SDK каждой карты показаны точный метод доступа и тип ввода. Многочастные загрузки, двоичные ответы или ответы JavaScript, а также необработанные веб-перехватчики не генерируются; эти карты показывают 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. |
| В соединении отказано | Сайдкар перезапустилась в новом порту | Прочтите порт из нового ready строка. |