Skip to main content

Quick start

You need: the site code (siteSlug) issued by the i-Catholic team (see Overview). No API key or sign-in is required. The examples below use giao-xu-cua-ban; replace it with your own code.

1. Try a request​

curl -s "https://api.i-catholic.org/v2/public/cms/giao-xu-cua-ban/site?locale=vi"

The response looks like { "data": { ... } } (shortened):

{
"data": {
"slug": "giao-xu-cua-ban",
"primaryLocale": "vi",
"locales": ["vi", "en"],
"locale": "vi",
"info": { "name": "Giáo xứ Của Bạn", "address": "...", "phones": ["..."], "...": "..." },
"categories": [{ "slug": "tin-tuc", "parent": null, "name": "Tin tức", "position": 0 }],
"tags": [{ "slug": "gioi-tre", "name": "Giới trẻ" }],
"menus": { "primary": [], "footer": [] }
}
}

If you get 404 with "message": "Not found": the site code is wrong, the site is not enabled yet, or the language you asked for is not enabled for this site. These three cases deliberately return exactly the same response.

2. A list of posts and one post​

The code below runs both in the browser and in Node 18+ (both have fetch):

const API = 'https://api.i-catholic.org/v2/public/cms/giao-xu-cua-ban'

async function getJson<T>(url: string): Promise<T> {
// No headers, no credentials: a CORS "simple request" (see the performance page).
const res = await fetch(url, { credentials: 'omit' })
if (!res.ok) throw new Error(`CMS ${res.status}: ${url}`)
return res.json() as Promise<T>
}

// 12 newest posts in Vietnamese (featured ones first). Keep the key order: locale, …, page, limit.
const list = await getJson<{ data: Array<{ slug: string; title: string; excerpt: string }>; meta: { pageCount: number } }>(
`${API}/entries?locale=vi&page=1&limit=12`,
)
for (const post of list.data) console.log(post.slug, post.title)

// One post (or page) by slug.
const { data: entry } = await getJson<{ data: { slug: string; title: string; bodyHtml: string } }>(
`${API}/entries/${encodeURIComponent(list.data[0].slug)}?locale=vi`,
)
console.log(entry.title)

Three things to remember from the start:

  1. locale, page and limit are required for lists, and limit only accepts 3, 6, 12, 24 or 100. Any other value is rejected with 400.
  2. Keep the parameter order: locale, category, tag, q, sort, page, limit. The cache is keyed on the exact URL string; with a different order, your site may show the old version for up to 60 more seconds after staff edit a post.
  3. bodyHtml is HTML. The server has already filtered it against a list of safe tags, but filter it once more on your side before inserting it into the page (see API reference).

3. Next​

Was this page helpful?