Export ONLY published content

Hello,

Currently we are running a javascript script which uses a dangerousGetAll to pull all content from Prismic.

I want to do this, but pull only published content -- is there a way to do this? I was thinking a getAllByType and pass a param as status == published, but I cannot find anywhere where it is storing the status of the content. Any help would be welcome, thanks in advance!

Hello @jennifer.martelle,

Prismic documents do not explicitly store a status field like "published" or "draft" in their API responses. We automatically excludes drafts from API queries—only published documents are retrievable using the standard API methods.

Instead of using dangerousGetAll, you can use getAllByType, which only returns published documents by default. There is no need to filter by status.

Let me know if you need further clarification! :slight_smile:

Thank you @Ezekiel !

1 Like

@Ezekiel - do you know if the dangerouslyGetAll also pulls in drafts and archived items? Or does that also only pull in published?

@jennifer.martelle, it only pulls in published. Prismic’s API does not expose drafts unless you are previewing content with a preview ref specifically :slight_smile:

@Ezekiel and that is also true of archived items?

Thank you!

1 Like

@jennifer.martelle It is! Archived items cannot be retrieved in the API at all as they are essentially unpublished.

Amazing, thank you for your quick response! @Ezekiel

1 Like