Skip to Content
Mutation APIFetching multiple items

Fetching multiple items

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, create an access token with the REST API scope content_items. Check out the authorization guide for more details. Pass this access token in the Authorization header as a Bearer token when making the request.

To fetch content items, send a GET request to the https://cdn.prepr.io/content_items endpoint and include your filter criteria in the request payload. Filter content items by the criteria listed below.

Search content items

You can make search requests for content items by their title, slug or all text fields.

Search by title

Check out the field settings guide on how to set a title.

You can filter content items by searching the title field with fuzzy search using the fz argument.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "title": [ { "fz": "summer" } ] }

Search by slug

Request fuzzy search on content items by the slug field using the fz argument.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "slug": [ { "fz": "summer" } ] }

The example below searches content items with a slug that starts with blog by using the sw argument.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "slug": [ { "sw": "blog" } ] }

The example below searches content items with a slug that matches a regex pattern (no forward slashes) by using the regex argument.

Make sure the regex pattern is in Base64  format.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "slug": [ { "regex": "Xig/OlteXFwvXSspPyQ=" } ] }

Filter content items by searching in all text fields using the q and fz arguments.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "q": [ { "fz": "summer" } ] }

Filter content items

Use filter arguments to narrow down the content items returned by your request. We support the following arguments:

  • has: Returns content items where the field has at least one value.
  • hasn: Returns content items where the field has no value.
  • eq: Returns content items where the field exactly matches the given value.
  • in: Returns content items where the field matches any value in a given list.
  • fz: Returns content items where the field matches a fuzzy text search. See the search examples above.

Filter arguments

For content fields, add the filter inside the items object and specify the locale key, for example items.en-US.

HAS

Use has when you want to return content items where a field contains at least one value.

The example below fetches content items that have at least one asset in the cover_image field.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "items": { "en-US": { "cover_image": [ { "has": true } ] } } }

HASN

Use hasn when you want to return content items where a field is empty.

The example below fetches content items that do not have a value in the cover_image field.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "items": { "en-US": { "cover_image": [ { "hasn": true } ] } } }

EQ

Use eq when you want to return content items that exactly match a single value.

The example below fetches content items where the premium_content boolean field is true.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "items": { "en-US": { "premium_content": [ { "eq": 1 } ] } } }

IN

Use in when you want to return content items that match any value in a list.

The example below fetches content items that have the tag 222b7528-9e3a-294f-21bf-7ec623d1ac74 or bcc9eea7-7307-f45b-5aaf-27eca7d329f9.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "in": [ "222b7528-9e3a-294f-21bf-7ec623d1ac74", "bcc9eea7-7307-f45b-5aaf-27eca7d329f9" ] } ] }

System fields

You can filter content items by any of the system fields listed below. Unlike content field filters, system field filters go at the top level of the request payload, and not inside items.<locale>.

Workflow stage

You can filter content items by their workflow stage, Done, Review, In Progress, To do, or Archived. Simply pass the workflow stage as an argument in your request payload.

The example below fetches published content items with the en-EN locale.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "workflow_stage": [ { "eq": "Published" } ], "locales": [ { "eq": "en-EN" } ] }

The example below fetches content items in the Done stage.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "workflow_stage": [ { "eq": "Done" } ] }

The example below fetches content items in the Done or Review stages.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "workflow_stage": [ { "in": [ "Done", "Review" ] } ] }

Locales

You can filter content items by locale. Simply pass one or more locales in your request payload.

The example below fetches content items in the en-EN locale.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "locales": [ { "eq": "en-EN" } ] }

The example below fetches content items in the en-EN or en-US locales.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "locales": [ { "in": [ "en-EN", "en-US" ] } ] }

Model

In Prepr, models define the content structure for different types of content, like Article, Hero, Banner, Menu, etc.

The example below fetches content items for one model using the Model ID.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "eq": "93fb1b38-9a85-4d6e-9639-8c4a8a88454a" } }

The example below fetches content items for multiple models.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "in": [ "93fb1b38-9a85-4d6e-9639-8c4a8a88454a", "00fb1b38-9a85-4d6e-9639-8c4a8a88454a" ] } }

Dates

You can filter content items by different system date fields. Use publish_on, created_on, changed_on, or expire_on in your request payload, depending on the date you want to query.

All timestamps are in UTC format.

The example below fetches content items published between two timestamps.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { // 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 } ] }

Tags

You can filter content item collections by tags. Simply include the tags field in your request payload.

  • The example below queries content items with the tag 222b7528-9e3a-294f-21bf-7ec623d1ac74 or bcc9eea7-7307-f45b-5aaf-27eca7d329f9.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "in": [ "222b7528-9e3a-294f-21bf-7ec623d1ac74", "bcc9eea7-7307-f45b-5aaf-27eca7d329f9" ] } ] }
  • The example below queries all the content items with both the tag 222b7528-9e3a-294f-21bf-7ec623d1ac74 and bcc9eea7-7307-f45b-5aaf-27eca7d329f9.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "all": [ "222b7528-9e3a-294f-21bf-7ec623d1ac74", "bcc9eea7-7307-f45b-5aaf-27eca7d329f9" ] } ] }
  • The example below queries all the content items with at least one tag.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "has": true } ] }
  • The example below queries all the content items that don’t have either tag: 222b7528-9e3a-294f-21bf-7ec623d1ac74, bcc9eea7-7307-f45b-5aaf-27eca7d329f9.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "tags": [ { "nin": [ "222b7528-9e3a-294f-21bf-7ec623d1ac74", "bcc9eea7-7307-f45b-5aaf-27eca7d329f9" ] } ] }

Content fields

The table below shows which operators are available for each content-related field type.

Field typehashasneqinAdditional comments
Text✓✓✓✗
Asset✓✓✓✓
Stack✓✓✓✓
Content reference✓✓✓✓
Dynamic content✓✓✗✗
Boolean✓✓✓✗
List✓✓✓✗
Integer✓✓✓✗
Float✓✓✓✗
Remote content✓✓✓✓
Form✓✓✗✗Applies to HubSpot, Typeform, Pipedrive, ActiveCampaign, and Jotform.
Date✗✗✓✗Applies to different types of dates such as Date, Daterange, and Businesshours
Tag✓✓✓✓
Location✓✓✗✗
Social✓✓✗✗Applies to social platform fields such as X, Bluesky, Threads, Instagram, Facebook, YouTube, Vimeo, TikTok, Spotify, SoundCloud, and Apple Podcast.
Color✓✓✓✗

You can filter content items by a specific content field value. The filter options per type are different, but it’s also possible to combine multiple filters.

The sections below show some specific examples per field type beyond those in the filter arguments section.

Text

Get content items with a text field that matches a specific value exactly.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "seo_title": [ { "eq": "Summer campaign" } ] } } }

Content reference or Stack fields

You can fetch content items that contain a given content item. For example, when a web app visitor views the content item 10c503b4-e86b-422d-89d3-502b3faee34e, you may want to display suggestions that are related to this publication. Unlike recommendations, these content items are directly linked to each other.

The filter options, eq, in, has, and has not result in linked content items.

  • The example below fetches content items linked to one content item (an author).

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "authors": [ { "eq": "10c503b4-e86b-422d-89d3-502b3faee34e" } ] } } }
  • The example below fetches content items linked to any content item in a list.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "authors": [ { "in": [ "10c503b4-e86b-422d-89d3-502b3faee34e" ] } ] } } }
  • The example below fetches content items that have linked content.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "authors": [ { "has": true } ] } } }
  • The example below fetches content items without linked content.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "authors": [ { "hasn": true } ] } } }

Boolean

  • The example below fetches content items with the boolean field, premium_content, set to false:

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "premium_content": [ { "eq": 0 } ] } } }
  • The example below fetches content items with the boolean field, premium_content, set to true:

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "premium_content": [ { "eq": 1 } ] } } }

Remote content

  • The example below fetches content items that contain any shopify_product remote content:

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "shopify_product": [ { "has": true } ] } } }
  • The example below fetches content items without any shopify_product remote content.

    GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "shopify_product": [ { "has": false } ] } } }

Daterange

You can filter content items by a date range field before, after, or between dates.

This type of filtering is not available for other date field types.

In addition to the filter options listed in the table above, you can use the additional filter options below.

Argumentdescription
ltLess than from date.
lteLess than or equals from date.
gtGreater than from date.
gteGreater than or equals from date.

The example below queries content items with an event starting after (gt) a certain date.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "event_schedule": [ { "gt": 1600000000 } ] } } }

The example below queries content items with an event starting before (lt) a certain date.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "event_schedule": [ { "lt": 1600000000 } ] } } }

The example below queries content items with an event schedule that falls between two dates.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "event_schedule": [ { "gt": 1600000000, "lt": 1700000000 } ] } } }

Location

You can fetch content items that have a location, do not have a location, or fall within a given radius from a specified point.

In addition to the filter options for a location listed in the table above, you can fetch content items with a location within a specified radius (in metres) from specified latitude and longitude values.

The example below queries content items that contain any location value.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "office_location": [ { "has": true } ] } } }

The example below queries content items without a location value.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "office_location": [ { "hasn": true } ] } } }

The example below queries content items within 10 kilometers of a given latitude and longitude.

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "office_location": [ { "radius": 10000 "latitude": 52.3676, "longitude": 4.9041, } ] } } }

Combining multiple filters

You can filter content items by multiple fields at the same time. The example below filters content items by a boolean field (id: premium_content) and integer field (id: reading_time).

GET https://cdn.prepr.io/content_items Authorization: Bearer <YOUR-ACCESS-TOKEN> Content-Type: application/json { "model": { "id": "edc503b4-e86b-422d-89d3-502b3faee34e" }, "items": { "en-US": { "premium_content": [ { "eq": 1 } ], "reading_time": [ { "eq": 10 } ] } } }

This results in a list of content items that are marked as premium and have a reading time with value 10.

Last updated on