Files
twenty/packages/twenty-docs/l/zh/developers/api-and-webhooks/api.mdx
T
e02c24bd3a i18n - docs translations (#15904)
Created by Github action

---------

Co-authored-by: Abdul Rahman <ar5438376@gmail.com>
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: github-actions <github-actions@twenty.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
2025-11-18 17:21:48 +01:00

57 lines
3.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: API
image: /images/docs/getting-started/api.png
info: 發現如何使用我們的API。
---
<Frame>
<img src="/images/docs/getting-started/api.png" alt="Header" />
</Frame>
## 概覽
Twenty API 讓開發者可以以程式化方式與 Twenty CRM 平台互動。 使用 API,您可以將 Twenty 與其他系統整合,自動化數據同步,並圍繞您的客戶數據構建自定義解決方案。 該 API 提供了端點,用於**建立、讀取、更新和刪除**核心 CRM 對象(如人員和公司),以及訪問元數據配置。 使用 API,您可以將 Twenty 與其他系統整合,自動化數據同步,並圍繞您的客戶數據構建自定義解決方案。 該 API 提供了端點,用於**建立、讀取、更新和刪除**核心 CRM 對象(如人員和公司),以及訪問元數據配置。
**API 游樂場:** 現在您可以在應用的設置中訪問 API 游樂場。 **API 游樂場:** 現在您可以在應用的設置中訪問 API 游樂場。 To try out API calls in real-time, log in to your Twenty workspace and navigate to **Settings → APIs & Webhooks**. This opens the in-app API Playground and the settings for API keys.
**[Go to API Settings](https://app.twenty.com/settings)**
## 身份驗證
Twenty 的 API 使用 API 金鑰進行身份驗證。 每個請求到受保護的端點必須在標頭中包含一個 API 金鑰。 每個請求到受保護的端點必須在標頭中包含一個 API 金鑰。
- **API 金鑰:** 您可以在 Twenty 應用的 **API 設置** 頁面生成新 API 金鑰。 **API 金鑰:** 您可以在 Twenty 應用的 **API 設置** 頁面生成新 API 金鑰。 每個 API 金鑰都是授予您 CRM 數據訪問權的祕密令牌,因此請將其保存好。 如果金鑰被洩露,請從設置中撤銷並生成新的金鑰。 如果金鑰被洩露,請從設置中撤銷並生成新的金鑰。
- **身份驗證標頭:** 一旦您擁有 API 金鑰,請在 HTTP 請求的 `Authorization` 標頭中包含它。 使用承載令牌方案。 例如: 使用承載令牌方案。 例如:
```
Authorization: Bearer YOUR_API_KEY
```
用您獲得的金鑰替換 `YOUR_API_KEY`。 此標頭必須存在於**所有 API 請求**上。 如果令牌丟失或無效,API 將回應身份驗證錯誤(HTTP 401 未經授權)。
## API 端點
所有資源都可以通過 REST 或 GraphQL 訪問。
- **雲:** `https://api.twenty.com/` 或您的自定義域名 / 子域名
- **Self-Hosted Instances:** If you are running Twenty on your own server, use your own domain in place of `api.twenty.com` (for example, `https://{your-domain}/rest/`).
端點分為兩類:**核心 API** 和 **元數據 API**。 **核心 API** 處理主要的 CRM 數據(例如人員、公司、筆記、任務),而 **元數據 API** 涵蓋配置數據(例如自定義字段或對象定義)。 大多數的整合將主要使用核心 API。
### 核心 API
可通過 `/rest/` 或 `/graphql/` 訪問。
可通過 `/rest/` 或 `/graphql/` 訪問。
The **Core API** serves as a unified interface for managing core CRM entities (people, companies, notes, tasks) and their relationships, offering **both REST and GraphQL** interaction models.
### 元數據 API
可通過 `/rest/metadata/` 或 `/metadata/` 訪問。
元數據 API 端點允許您獲取關於您的模式和設置的信息。 例如,您可以獲取自定義字段、對象模式等的定義。
- **示例端點:**
- `GET /rest/metadata/objects` – 列出所有對象類型及其元數據(字段、關係)。
- `GET /rest/metadata/objects/{objectName}` 獲取特定對象的元數據(例如,`people``companies`)。
- `GET /rest/metadata/picklists` 獲取在 CRM 中定義的選擇列表(下拉)字段選項。
通常,元數據端點用於了解數據結構(用於動態集成或表單構建),而不是管理實際記錄。 在大多數情況下,它們是只讀的。 這些也需要身份驗證(使用您的 API 金鑰)。