開發者公開內容 API

單純的 REST 與 JSON。你開啟前,一律關閉。

依網站設定的公開 API,精確控制要公開什麼、對誰公開。在任何地方都以同樣可預期的 JSON 結構擷取已發布內容、sitemap 與重新導向——不必學 GraphQL 結構描述,也不必維護自動生成的用戶端。以下每個請求都是真實的:一個建構在 CMSHub 上的部落格,只用 curl 呼叫。

01 / 擷取已發布內容

一個 GET 請求,以 JSON 取得已發布記錄

網站一旦啟用並將某個集合列入允許清單,只要一個簡單的 GET 就能取得其已發布記錄——完全依 Host 標頭解析,公開資料不需要 API 金鑰。

  • 只會回傳「已發布」的記錄——草稿與未發布的修訂版本絕不會經由公開路徑外洩。
  • 預設拒絕:未知的主機、已停用的網站,或未列入允許清單的集合,一律回傳相同的 404。
  • ?locale=xx 會回傳該語系的已發布版本,若無則退回工作區預設語系。
GEThttps://the-signal.blog/api/posts
curl https://the-signal.blog/api/posts
RESPONSE
{
  "siteId": "the-signal-4f2a",
  "siteName": "The Signal",
  "baseUrl": "https://the-signal.blog",
  "collection": {
    "id": "3b0d6f2a-9c41-4e8a-8f2e-1d4c9a7b6e11",
    "slug": "posts",
    "name": "Posts"
  },
  "data": [
    {
      "id": "a91f2e3c-7d5b-4a10-9c3e-6f8a2b1d0e44",
      "locale": "en",
      "translationOfId": null,
      "data": {
        "title": "Shipping a public content API without a GraphQL schema",
        "slug": "shipping-a-public-content-api",
        "excerpt": "Plain REST beats a bespoke query language when a frontend just needs JSON.",
        "category": "Engineering",
        "author": "Dana Osei",
        "published_at": "2026-09-10"
      }
    },
    {
      "id": "d2c5b8a1-4e3f-4c9d-8b7a-2f1e6d5c4b33",
      "locale": "en",
      "translationOfId": null,
      "data": {
        "title": "What the quality gate actually checks before you publish",
        "slug": "the-quality-gate-explained",
        "excerpt": "Every generated page passes the same checks, whether it's post 1 or post 10,000.",
        "category": "Product",
        "author": "Dana Osei",
        "published_at": "2026-09-04"
      }
    }
  ],
  "meta": {
    "locale": "en",
    "pagination": { "start": 0, "limit": 20, "total": 2, "nextCursor": null }
  }
}
02 / 自動被發現

sitemap 永遠與實際發布內容一致

sitemap.xml 與 robots.txt 由內容 API 讀取的同一份頁面清單生成——沒有另外的設定需要同步,也沒有任何東西需要手動重新生成。

  • 每次請求都反映即時的頁面清單——頁面一發布,就出現在 sitemap 中。
  • 凡有翻譯版本的頁面,都會自動加入 hreflang 替代連結。
  • /robots.txt 會依網站將爬蟲導向同一個 sitemap。
GEThttps://the-signal.blog/sitemap.xml
curl https://the-signal.blog/sitemap.xml
RESPONSE
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
  <url><loc>https://the-signal.blog/posts/shipping-a-public-content-api</loc><lastmod>2026-09-10T14:22:00.000Z</lastmod></url>
  <url><loc>https://the-signal.blog/posts/the-quality-gate-explained</loc><lastmod>2026-09-04T09:15:00.000Z</lastmod></url>
</urlset>
03 / 預設關閉

網站公開什麼,由你決定

在你明確設定網站要公開哪些內容之前,公開內容 API 一律保持關閉——不存在預設開放、悄悄提供未發布或草稿內容的端點。

依網站設定

為工作區中的每個網站分別啟用並設定公開 API。

僅限已發布內容

公開 API 只提供通過品質關卡、確實已發布的內容——絕不提供草稿。

版本化、穩定

每個路由都位於版本化路徑下,今天打造的整合,在 CMSHub 演進後依然可用。

呼叫真實端點

為網站啟用公開 API。

為你的某個網站開啟公開內容 API,並擷取一個生成的頁面。