Skip to content

Read entries (list, one entry, single)

Use the Content API to read published entries. From a collection content type, you can read a list and one entry. From a single content type, you can read its one entry.

  • An API key with the [読み取り](Read) permission. To issue one, see Create API keys and set permissions
  • The entries you read must be [公開中](Published). Drafts are not returned. To read drafts, see Read drafts (preview)
  • The content type ID. This is the value shown as [エンドポイント](Endpoint) on the content type screen (for example, “posts”)

In the examples below, replace these values:

  • <hostname>: the hostname of your environment. It is the part of the admin address https://<hostname>.hakocms.net
  • <API key>: your API key, which starts with hako_
What you read URL
A list from a collection /api/v1/content/<content type ID>
One entry from a collection /api/v1/content/<content type ID>/<entry ID>
A single /api/v1/content/<content type ID>

The space is determined by the API key. You do not need to put the space in the URL.

Read the published entries of the content type “posts” as a list.

ターミナルウィンドウ
curl https://<hostname>.hakocms.net/api/v1/content/posts \
-H "Authorization: Bearer <API key>"

You get a response like this:

{
"items": [
{
"sys": {
"id": "hello",
"contentType": "posts",
"createdAt": "2026-10-08T05:00:00.000Z",
"updatedAt": "2026-10-08T06:10:00.000Z",
"publishedAt": "2026-10-08T06:10:00.000Z",
"firstPublishedAt": "2026-10-08T05:00:00.000Z",
"version": 3
},
"title": "こんにちは",
"tags": ["news"]
}
],
"total": 1,
"limit": 20,
"offset": 0
}
Key Contents
items An array of entries. By default, newest published first
total The number of entries that match the conditions. This is the number before limit and offset divide it
limit offset The values used

By default, one response returns up to 20 entries. To get the rest, sort, or filter, see Filter, sort, and paginate.

Read the entry whose entry ID is “hello”. Add the entry ID to the end of the URL.

ターミナルウィンドウ
curl https://<hostname>.hakocms.net/api/v1/content/posts/hello \
-H "Authorization: Bearer <API key>"

You get one entry as is. It has the same shape as one item in the list’s items.

{
"sys": {
"id": "hello",
"contentType": "posts",
"createdAt": "2026-10-08T05:00:00.000Z",
"updatedAt": "2026-10-08T06:10:00.000Z",
"publishedAt": "2026-10-08T06:10:00.000Z",
"firstPublishedAt": "2026-10-08T05:00:00.000Z",
"version": 3
},
"title": "こんにちは",
"tags": ["news"]
}

If the entry does not exist or is not published, you get 404.

For a single content type (for example, “site-settings”, which holds the site settings), read it without an entry ID.

ターミナルウィンドウ
curl https://<hostname>.hakocms.net/api/v1/content/site-settings \
-H "Authorization: Bearer <API key>"

You get one entry as is. If it is not published yet, you get 404. If you add an entry ID to the URL of a single, you also get 404.

You can read entries the same way with fetch, in the browser or on the server. You can call the Content API from any origin.

const res = await fetch(
"https://<hostname>.hakocms.net/api/v1/content/posts",
{ headers: { Authorization: "Bearer <API key>" } },
);
if (!res.ok) {
const { error } = await res.json();
throw new Error(`${res.status} ${error.code}: ${error.message}`);
}
const { items, total } = await res.json();
console.log(total, items.map((entry) => entry.title));

Only a key with just [読み取り](Read) may be given to the browser. Use keys with other permissions only on the server.

An entry has sys first, followed by the fields of the content type in schema order.

sys key Contents
id The entry ID. Singles have one too
contentType The content type ID
createdAt When the entry was created
updatedAt When the entry was last saved
publishedAt When the published revision was published
firstPublishedAt When the entry was first published
version The revision number of the returned value. Used for checks when you write

All dates and times are ISO 8601 in UTC, with milliseconds (2026-10-08T06:10:00.000Z).

The shape of a field’s value depends on the field type.

Field type Value When there is no value
Text, text area A string. Line breaks are \n The key is absent
Rich text JSON (Hako Rich Text v1) The key is absent
Image { "url", "width", "height", "alt" } The key is absent
Multiple images An array of images []
File { "url", "fileSize" } The key is absent
Date and time ISO 8601 in UTC The key is absent
Boolean true or false false
Select An array of the selected values. An array even for one value []
Number A number The key is absent
Reference The referenced entry The key is absent
Multiple references An array of the referenced entries []
Custom An object with fieldId (the ID of the custom field) and the fields inside The key is absent
Repeater An array of custom values []

An image’s width, height, and alt may be missing. Types that are arrays, and booleans, are always returned even without a value. For other types, the key itself is not returned when there is no value.

For how references are handled, see Get referenced entries together. To change the size or format of images, see Transform images. For the detailed shape of each type, see Field types and value formats.

By default, a rich text field is returned as JSON.

"body": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [{ "type": "text", "text": "こんにちは。" }]
}
]
}

To get it as an HTML string, add richText=html.

ターミナルウィンドウ
curl -G https://<hostname>.hakocms.net/api/v1/content/posts/hello \
-H "Authorization: Bearer <API key>" \
-d richText=html

body is returned as an HTML string. The JSON format is described in Rich text format (Hako Rich Text v1).

Write the keys you want in select, separated by commas, and only those keys are returned. Use dots to go inside sys. This works for both lists and one entry.

ターミナルウィンドウ
curl -G https://<hostname>.hakocms.net/api/v1/content/posts/hello \
-H "Authorization: Bearer <API key>" \
--data-urlencode "select=sys.id,title"

You get a response like this:

{ "sys": { "id": "hello" }, "title": "こんにちは" }

You can also select fields of referenced entries with dots, such as author.name. The same goes for the inside of custom fields.

One response can be up to 5 MB. If it is larger, you get 400. If a list is large, reduce it with limit or select.

If total in the list is 1 or more, you are reading published entries. If you do not get what you expect, see the following table.

What you got Cause Fix
401 unauthorized The API key is missing, wrong, or revoked Check that you put the key starting with hako_ as is after Authorization: Bearer
403 forbidden The key does not have permission to read that content type On the [API キー](API keys) screen, check the key’s [読み取り](Read). For content types under [個別に設定](Set individually), only the individual permissions apply
404 not_found The content type or entry does not exist, or is not published Check that the content type ID in the URL matches [エンドポイント](Endpoint), and that the entry is [公開中](Published)
400 bad_request with unknown parameter An unknown parameter, or a list-only parameter added to one entry message shows the parameters you can use. Check the spelling

For other errors, see Errors.