メインコンテンツまでスキップ

REST API: status

REST API では、ドキュメントの状態(下書きまたは公開)に応じて結果を絞り込めます。

Prerequisites

下書きと公開 機能が有効になっている必要があります。

クエリでは status パラメータで次のように取得できます。

  • published: 公開版のドキュメントのみ(既定)
  • draft: 下書き版のドキュメントのみ
Tip

レスポンスの data では、下書きの publishedAtnull です。

Note

公開版が既定で返るため、status を省略するのは status=published と同じ扱いです。



レストランの下書き版を取得

GET /api/articles?status=draft

JavaScript のクエリ(qs ライブラリで組み立て):

The query URL above was built using the `qs` library. qs can be run locally on your machine, as shown in the following code example, or you can use our interactive query builder online tool.

const qs = require('qs');
const query = qs.stringify({
status: 'draft',
}, {
encodeValuesOnly: true, // prettify URL
});

await request(`/api/articles?${query}`);
レスポンス例
{
"data": [
// …
{
"id": 5,
"documentId": "znrlzntu9ei5onjvwfaalu2v",
"Name": "Biscotte Restaurant",
"Description": [
{
"type": "paragraph",
"children": [
{
"type": "text",
"text": "This is the draft version."
}
]
}
],
"createdAt": "2024-03-06T13:43:30.172Z",
"updatedAt": "2024-03-06T21:38:46.353Z",
"publishedAt": null,
"locale": "en"
},
// …
],
"meta": {
"pagination": {
"page": 1,
"pageSize": 25,
"pageCount": 1,
"total": 4
}
}
}