Get a list of entries
Log in to add to favouritesCall the entries.search() method in our delivery client to get a paged list of entries for a given search criteria
Call signatures
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
Name | Type | Description |
---|---|---|
query | Query | A query object containing the search criteria for returning entries |
zenql | string | A ZenQL statement containing the search criteria for returning entries |
zenqlQuery | ZenqlQuery | A zenql query object containing the search criteria for returning entries |
linkDepth | number | Resolve 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
// 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
// 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
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
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);
}