Skip to main content

Get a list of entries

Log in to add to favourites

Call the entries.search() method in our delivery client to get a paged list of entries for a given search criteria

Call signatures

TypeScript
search(query: Query, linkDepth?: number): Promise<PagedList<Entry>>

search(zenql: string, linkDepth?: number): Promise<PagedList<Entry>>

search(zenqlQuery: ZenqlQuery, linkDepth?: number): Promise<PagedList<Entry>>

Parameters

NameTypeDescription
queryQueryA query object containing the search criteria for returning entries
zenqlstringA ZenQL statement containing the search criteria for returning entries
zenqlQueryZenqlQueryA zenql query object containing the search criteria for returning entries
linkDepthnumberResolve all fields containing content links in returned entries to this depth

Returns

A Promise that will resolve with a Paged List of Entry

Example

Get a list of published entries of a given content type API ID using search

JavaScript
// Using TypeScript, or ES Module await syntax
import { Query, Op } from "contensis-delivery-api";

const query = new Query(
  Op.equalTo("sys.contentTypeId", "<content-type-id>"),
  Op.equalTo("sys.versionStatus", "published")
);

const entryList = await client.entries.search(query);

for (const entry of entryList.items) {
  console.log(entry.entryTitle);
}

Get a list of published entries of a given content type API ID using search

JavaScript
// Using Common JS promise callback syntax
const { Query, Op } = require("contensis-delivery-api");

const query = new Query(
  Op.equalTo("sys.contentTypeId", "<content-type-id>"),
  Op.equalTo("sys.versionStatus", "published")
);

client.entries
  .search(query)
  .then(function (entryList) {
    entryList.items.forEach(item => (
        console.log(item.entryTitle)
    ))
  });

Get a list of published entries of a given content type API ID using a ZenQL statement

TypeScript
const entryList = await client.entries.search(
  "sys.contentTypeId=<content-type-id> and sys.versionStatus=published"
);

for (const entry of entryList.items) {
  console.log(entry.entryTitle);
}

Get the third page of published entries of a given content type API ID using ZenQL

TypeScript
import { ZenqlQuery } from "contensis-delivery-api";

const query = new ZenqlQuery("sys.contentTypeId=<content-type-id> and sys.versionStatus=published");
query.pageIndex = 2;

const entryList = await client.entries.search(query);

for (const entry of entryList.items) {
  console.log(entry.entryTitle);
}

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request