Filtering collections
Use the Prepr REST API to fetch a collection of content items when you need to get content for a bulk process. For example, to get content from linked content items as part of a project to migrate content from a legacy system to Prepr CMS.
Use GraphQL API for content delivery
If you simply want to fetch content items for content delivery then we strongly recommend using the GraphQL API instead.
Before calling a REST API endpoint to fetch a collection of content items, go to Settings → Access tokens to create an access token with the REST API scope content_items
.
To fetch content items, send a GET
request to the https://cdn.prepr.io/content_items
endpoint. Filter content items by the criteria listed below.
Search
Prepr content items can be searched on their title or text fields.
Title search
Filter content items by searching in the title field with fuzzy search.
GET: /content_items?title[0][fz]=hello world
Full text search
Filter content items by searching in all text fields with fuzzy search.
GET: /content_items?q[0][fz]=hello world
Workflow stage
Prepr content items can be filtered on their workflow stage. You can query the workflow stage field by using the workflow stage as an argument.
GET: /content_items?workflow_stage[0][eq]=Published&locales[0][eq]=en-EN
Locales
Prepr content items can be filtered on their locale. You can query the locale field by using the locales as an argument.
GET: /content_items?locales[0][eq]=en-EN
Model
With Prepr you can have multiple models, like Article, Hero, Banner, Menu, Blog etc. All those different pieces can be defined as a Model.
GET: /content_items?model[eq]=93fb1b38-9a85-4d6e-9639-8c4a8a88454a
Dates
Prepr content items can be filtered on a different type of dates.
You can query the dates fields by using publish_on
,created_on
, changed_on
, expire_on
as an argument.
The examples below all use publish_on
.
Note: all timestamps are UTC.
{
// This example fetches content items between certain timestamps
// using "greater than" (gt) and "less than" (lt).
// You need to specify both gt and lt values.
"publish_on" : [
{
"gt" : 1601510400,
"lt" : 1604188799,
}
]
}
Subscribed, Liked & Bookmarked
If a customer can subscribe, like or bookmark content items in your app. This filter allows you to request the bookmarked content items of the specified customer.
GET: /content_items?bookmarked[0][eq]=bcc9eea7-7307-f45b-5aaf-27eca7d329f9
Location
Prepr content items can be filtered by coordinates.
GET: /content_items?model[id]=cc9eea7&items[en-US][api_id][0][latitude]=52.3727222
GET: /content_items?model[id]=cc9eea7&items[en-US][api_id][0][longitude]=4.9689481
GET: /content_items?model[id]=cc9eea7&items[en-US][api_id][0][radius]=2000 // In Meters
Tags
Content items collections can be filtered on their tags.
You can query the tag fields by using the tags
argument.
In this example we will query all the content items with the tag
`222b7528-9e3a-294f-21bf-7ec623d1ac74` **or** `bcc9eea7-7307-f45b-5aaf-27eca7d329f9`.
GET: /content_items?tags[0][in][0]=222b7528-9e3a-294f-21bf-7ec623d1ac74&tags[0][in][1]=bcc9eea7-7307-f45b-5aaf-27eca7d329f9
Content Fields
Prepr content items collections can be filtered on a specific content model field value.
It's possible to apply advanced filters for the following field types: Boolean
, ContentIntegration
,
Coordinates
, DateTimeRange
, Integer
, Publication
, Text
.
The filter options per type are different. It's also possible to combine multiple filters.
Boolean
Get content items with boolean false:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": 0
}
]
}
}
}
Get content items with boolean true:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": 1
}
]
}
}
}
ContentIntegration
Get content items that doesn't contain a content integration item:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"has": 0
}
]
}
}
}
Get content items that does contain a content integration item:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"has": 1
}
]
}
}
}
Location
Get content items that within the radius of the coordinates:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"latitude": 52.3727222,
"longitude": 4.9689481,
"radius": 2000 // Radius in meters (this example is two kilometers)
}
]
}
}
}
DateTimeRange
Get content items that within or outside the given timestamp(s):
Note: You can only use this filter if field type is Daterange
, not Date and time
!
Options:
It's possible to combine the options below.
argument | description |
---|---|
lt | Less than from date. |
lte | Less than or equals from date. |
gt | Greater than from date. |
gte | Greater than or equals from date. |
Greater than the from date
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"gt": 1600000000
}
]
}
}
}
Less than the from date
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"lt": 1600000000
}
]
}
}
}
In between than the from date
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"gt": 1600000000,
"lt": 1700000000
}
]
}
}
}
Integer
Get content items with an integer with exact given value:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": 10
}
]
}
}
}
Content reference
Get content items that contains the given content item.
For example, if a customer is viewing content item 10c503b4-e86b-422d-89d3-502b3faee34e
, you may want to display suggestions
that are related to this publication.
This is not a recommendation, but linked to each other by you/editor.
This filter will result in linked content items.
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": "10c503b4-e86b-422d-89d3-502b3faee34e"
}
]
}
}
}
Type Text
Get content items with a text field with exact given value:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": "Hello world!"
}
]
}
}
}
Get content items with a text field with match/search given value:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"fz": "world"
}
]
}
}
}
Type List
Get content items with a list field with exact given value:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"eq": "Hello world!"
}
]
}
}
}
Get content items with a list field with match/search given value:
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"{{field id}}": [
{
"fz": "world"
}
]
}
}
}
Combining multiple filters
It is possible to filter on multiple fields at the same time.
In this example we are going to filter on boolean (id: premium
) and integer (id: category_id
).
{
"model": {
"id": "edc503b4-e86b-422d-89d3-502b3faee34e"
},
"items": {
"{{locale}}": {
"premium": [
{
"eq": 1
}
],
"category_id": [
{
"eq": 10
}
]
}
}
}
This will result in content items that are marked as premium and have an integer/category with value 10.
Channels (deprecated)
With Prepr you can publish to all your digital channels. Publish to your website, app, live blog, social wall, social media and on location screens. All those different front ends can be defined as a Channel.
GET: /content_items?channels[0][eq]=bcc9eea7-7307-f45b-5aaf-27eca7d329f9
Was this article helpful?
We’d love to learn from your feedback