---
title: "Query"
description: "Query"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/python/reference/query"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-13"
---

# Query

## Query

Retrieves assets

## query

Adds key value pairs to the to the query parameters

```
import contentstack;

stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query = query.query("key":"value")
```

## addParams

Adds Query Parameters to the to the request

```
import contentstack;

stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query = query.addParam({"key":"value"})
```

## param

Adds Query Parameters to the to the request

```
import contentstack;

stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query = query.param("key", "value")
```

## order_by_descending

you can sort them in the descending order with respect to the value of a specific field in the response body

```
import contentstack;

stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query.order_by_descending("key")
```

## order_by_ascending

you can sort them in the ascending order with respect to the value of a specific field in the response body.

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query.order_by_ascending("key")
```

## limit

A limit on the number of objects to return./p>

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query.limit(count)
```

## skip

The number of objects to skip before returning any. skip\_count No of objects to skip from returned objects

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query.skip(count)
```

## include_count

Retrieve count and data of objects in result

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query()
query.include_count()
```

## where

Get entries containing the field values matching the condition in the query

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
content_type = stack.content_type('content_type_uid')
query = content_type.query("field_uid", QueryOperation.EQUALS)
query.where()
```

## add_param

This method adds key and value to the Query

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.add_param("key","value")
```

## include_reference_content_type_uid

This method also includes the content type UIDs of the referenced entries returned in the response

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_reference_content_type_uid()
```

## include_content_type

This method also includes the ContentType in the entry

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_content_type()
```

## include_reference

When you fetch an entry of a content type that has a reference field, by default, the content of the referred entry is not fetched. It only fetches the UID of the referred entry, along with the content of the specified entry

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_reference()
```

## excepts

Specifies list of field\_uid that would be excluded from the response. It refers to the top-level fields of the schema

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.excepts()
```

## only

Specifies an array of only keys in BASE object that would be included in the response. It refers to the top-level fields of the schema

```
Example 1:
Displays values of the specified fields of entries or assets in the response.
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.only("title")Example 2:
The only function with an array of field UIDs will include data of mentioned fields and exclude the data of all other fields for each entry.
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type('demo').query().add_param('only[BASE][]', ['title','description'])
response = query.find()
```

## find_one

It fetches single query response

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
response = query.find_one()
```

## locale

Language code of which the entries need to be included. Only the entries published in this locale will be displayed

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
response = query.locale()
```

## find

It fetches the query response

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
response = query.find()
```

## include_embedded_items

Retrieve the published pranch in the response

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_embedded_items()
```

## include_branch

Retrieve the published pranch in the response

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_branch()
```

## include_fallback

Retrieve the published content of the fallback locale if an entry is not localized in specified locale

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.include_fallback()
```

## include_metadata

Includes Query metadata along with response body.

```
import contentstack

stack = contentstack.Stack('api_key','delivery_token','environment')
query = stack.content_type('contenttype_uid').query()
result = query.include_metadata().find()
print(result)
```

## where_not_in

Get entries having values based on referenced fields. This query works the opposite of $in\_query and retrieves all entries that does not satisfy query conditions made on referenced fields.

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.where_not_in("brand")
```

## where_in

Get entries having values based on referenced fields. This query retrieves all entries that satisfy the query conditions made on referenced fields

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query = query.where_in("brand")
```

## search

This method provides only the entries matching the specified value.

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query = query.search("search_keyword")
```

## tags

Include tags with which to search entries that accept variable-length argument lists

```
import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
query = stack.content_type("content_type_uid").query()
query.tags('black', 'gold', 'silver')
response = query.fetch()
```

## query_operator

query\_operator Get entries that satisfy all the conditions provided in the '$and' query.

```
import contentstack;
from contentstack.basequery import QueryOperation

stack = contentstack.Stack(api_key, delivery_token, environment);
query1 = stack.content_type("content_type_uid_1").query()
query2 = stack.content_type("content_type_uid_2").query()
query3 = stack.content_type("content_type_uid_3").query()
query2 = self.query1.where("price", QueryOperation.IS_LESS_THAN, fields=90)
query3 = self.query2.where("discount", QueryOperation.INCLUDES, fields=[20, 45])
query1 = query1.query_operator(query2, query3)
response = query1.find()
```

## Query | Python Delivery SDK | Contentstack

The Query class in the Python Delivery SDK builds and runs queries to retrieve and filter entries from your Contentstack stack.