기능요금제소개기사문서
개발자

API, SDK, MCP 및 웹훅.

개발자 플랫폼빠른 시작인증API 레퍼런스SDKMCP웹훅오류페이지네이션속도 제한멱등성변경 로그마이그레이션 및 버전 관리 정책
원본 API 문서OpenAPI YAMLAsyncAPI YAML
  1. 홈
  2. /
  3. 개발자
  4. /
  5. SDK

SDK

공식 TypeScript SDK(@fabhub/sdk)는 공개 OpenAPI 계약에 대해 생성되고 테스트되므로, 그 메서드가 공개 경로에서 절대 벗어나지 않습니다.

설치

npm install @fabhub/sdk

Node.js 22+가 필요합니다.


인증

API 키로 클라이언트를 구성합니다. OAuth로 발급된 액세스 토큰 자체가 pk_* 키이므로, 동일한 apiKey 옵션으로 전달하세요.

import { FabHubClient } from '@fabhub/sdk';

export const fabhub = new FabHubClient({
  apiKey: process.env.FABHUB_API_KEY,
});

메서드

Client methodEndpointRequired scope
getCapabilitiesGET /v1authenticated
getAuthContextGET /v1/auth/contextauthenticated
listItemsGET /v1/itemsitems:read
createItemPOST /v1/itemsitems:write
getItemGET /v1/items/{item_id}items:read
listItemIngredientsGET /v1/items/{item_id}/ingredientsitems:read
listItemSuppliersGET /v1/items/{item_id}/suppliersitems:read
createItemIngredientPOST /v1/items/{item_id}/ingredientsitems:write
updateItemIngredientPATCH /v1/items/{item_id}/ingredients/{ingredient_id}items:write
createItemSupplierPOST /v1/items/{item_id}/suppliersitems:write
updateItemSupplierPATCH /v1/items/{item_id}/suppliers/{supplier_id}items:write
deleteItemIngredientDELETE /v1/items/{item_id}/ingredients/{ingredient_id}items:write
deleteItemSupplierDELETE /v1/items/{item_id}/suppliers/{supplier_id}items:write
getOrderGET /v1/orders/{order_id}orders:read
listOrderLinesGET /v1/orders/{order_id}/linesorders:read
createOrderPOST /v1/ordersorders:write
updateOrderPATCH /v1/orders/{order_id}orders:write
updateItemPATCH /v1/items/{item_id}items:write
deleteItemDELETE /v1/items/{item_id}items:write
listOrdersGET /v1/ordersorders:read
listContactsGET /v1/contactscontacts:read
getContactGET /v1/contacts/{contact_id}contacts:read
createContactPOST /v1/contactscontacts:write
updateContactPATCH /v1/contacts/{contact_id}contacts:write
deleteContactDELETE /v1/contacts/{contact_id}contacts:write
getOrganizationGET /v1/organizationorganization:read
getUsageSummaryGET /v1/usageusage:read
listStockLevelsGET /v1/stock-levelsinventory:read
listStockDocumentsGET /v1/stock-documentsinventory:read
getStockDocumentGET /v1/stock-documents/{document_id}inventory:read
createStockDocumentPOST /v1/stock-documentsinventory:write
listStockDocumentLinesGET /v1/stock-documents/{document_id}/linesinventory:read
createStockDocumentLinePOST /v1/stock-documents/{document_id}/linesinventory:write
updateStockDocumentLinePATCH /v1/stock-documents/{document_id}/lines/{line_id}inventory:write
submitStockDocumentPOST /v1/stock-documents/{document_id}/submitinventory:write
cancelStockDocumentPOST /v1/stock-documents/{document_id}/cancelinventory:write
approveStockDocumentPOST /v1/stock-documents/{document_id}/approveinventory:write
deleteStockDocumentDELETE /v1/stock-documents/{document_id}inventory:write
deleteStockDocumentLineDELETE /v1/stock-documents/{document_id}/lines/{line_id}inventory:write
updateStockDocumentPATCH /v1/stock-documents/{document_id}inventory:write
listWebhooksGET /v1/webhookswebhooks:read
createWebhookPOST /v1/webhookswebhooks:write
getWebhookGET /v1/webhooks/{webhook_id}webhooks:read
updateWebhookPATCH /v1/webhooks/{webhook_id}webhooks:write
deleteWebhookDELETE /v1/webhooks/{webhook_id}webhooks:delete
listWebhookDeliveriesGET /v1/webhooks/{webhook_id}/deliverieswebhooks:deliveries:read
listAuditEventsGET /v1/audit/eventsaudit:read

페이지네이션

let page = 1;
let totalPages = 1;
do {
  const result = await fabhub.listItems({ page, pageSize: 100 });
  // handle result.data
  totalPages = result.pagination.totalPages;
  page += 1;
} while (page <= totalPages);

멱등성 쓰기

const { data: item } = await fabhub.createItem(
  { name: 'Widget', itemType: 'product' },
  { idempotencyKey: crypto.randomUUID() },
);

타입이 지정된 오류

import { FabHubApiError } from '@fabhub/sdk';

try {
  await fabhub.getItem('does-not-exist');
} catch (err) {
  if (err instanceof FabHubApiError) {
    console.error(err.status, err.code, err.message); // e.g. 404 NOT_FOUND ...
  }
}

웹훅 서명 검증

import { verifyFabHubWebhookSignature } from '@fabhub/sdk';

const result = verifyFabHubWebhookSignature({
  signingSecret: process.env.FABHUB_WEBHOOK_SECRET,
  rawBody, // the exact raw request body string/bytes, before JSON parsing
  timestamp: req.headers['x-fabhub-timestamp'],
  signature: req.headers['x-fabhub-signature'],
});

if (!result.ok) {
  // reject: result.reason explains why (e.g. 'invalid_signature')
}

드리프트 보호

SDK 작업 매핑은 CI에서 OpenAPI와 대조 검사되므로, 공개 SDK 메서드는 공개 경로에서 조용히 벗어나거나 내부 표면을 가리킬 수 없습니다.

홈기능요금제소개기사문서개발자
© FabHub개인정보 및 쿠키이용약관접근성