Skip to content

Queries

Queries give you powerful NoSQL database-like functionality for content fetching. Use the query parameter to send a valid JSON query on Objects and Media endpoints.

Note
If accessing the endpoint via browser address bar, open and closed curly braces will need to be encoded: %7B and %7D respectively. This encoder tool may help.

Object attributes

Construct queries to search by the following Object attributes.

ParameterDescription
idObject Id
titleObject Title
slugObject Slug
contentObject Content
typeObject Type Slug
statusObject Status
localeObject Locale
created_atObject Created at Date
published_atObject Published at Date
modified_atObject Modified at Date
created_byObject Created by user id
modified_byObject Modified by user id
metadata.$keyMetadata value(s)

Media attributes

Construct queries to search by the following Media attributes.

ParameterDescription
idMedia Id
nameMedia name
original_nameMedia original name
sizeMedia size
typeMedia type
createdMedia created date
folderMedia folder
metadataMedia metadata (JSON)

Selectors

Use the following selectors to build your queries.

ParameterDescription
$eqMatches values that are equal to a specified value. Default key/value query.
$gtMatches values that are greater than a specified value.
$gteMatches values that are greater than or equal to a specified value.
$ltMatches values that are less than a specified value.
$lteMatches values that are less than or equal to a specified value.
$inMatches any of the values specified in an array.
$allMatches all of the values specified in an array.
$neMatches all values that are not equal to a specified value.
$ninMatches none of the values specified in an array.

Evaluation

ParameterDescription
$regex, $optionsSearch for string, use $options: "i" for case insensitive matches.

Logic Operators

ParameterDescription
$andReturns Objects that match all of the query conditions.
$notReturns Objects that do not match the query expression.
$orReturns Objects that match any of the specified conditions.
$norReturns Objects that fail to match any of the specified conditions.

Examples

💡

Learn More
Go to the examples section in the docs to learn more about Cosmic queries and available methods.

More query info

💡

Want more information?
Cosmic queries follow MongoDB methods of comparison and logical operators. See further documentation and more examples in the MongoDB docs.