Stack

View as Markdown

Stack

Retrieves stack

NameTypeDescription
headers (required)dict
early_access dict

Optional array of header strings for early access features.

sync_param dict
endpoint str
api_key (required)str
delivery_token (required)str
environment (required)str
host str
version str
region Region

DB region for your stack. You can choose from seven regions namely, AWS NA, AWS EU, AWS AU, Azure NA, Azure EU, GCP NA, and GCP EU

timeout int
branch str
retry_strategy Retry
live_preview_dict dict

live_preview_query

live_preview_query accepts key-value pair objects to the query

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

response = stack.live_preview_query(**kwargs)

print(response)

image_transform

Image Delivery API covers the parameters that you can add to the URL to retrieve, manipulate (or convert) image files and display it to your web or mobile properties.

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

response = stack.image_transform("image_url", **kwargs)

print(response)

sync_token

You can use the sync token (that you receive after the initial sync)to get the updated content next time. The sync token fetchesonly the content that was addedafter your last sync and the details of the content that was deleted or updated.

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

response = stack.sync_token("sync_token")

print(response)

pagination

If the result of the initial sync (or subsequent sync)contains more than 100 records, the response would bepaginated. It provides a pagination token in the response.However, you do not have to use the pagination tokenmanually to get the next batch.
import contentstack
stack = contentstack.Stack(api_key = 'api_key', access_token = 'access_token', environment = 'environment')
result = stack.pagination('pagination_token')
if result is not None:
   logger.info(result)
        # result.items: Contains sync data
        # result.paginationToken: For fetching the next batch of entries using pagination token
        # result.syncToken: For performing subsequent sync after initial sync
else:
    logger.error(result)

asset_query

initial sync of the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

response = stack.

(
















)

print(

)

asset_query

assets of the stack

import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment);
assets = stack.asset_query()
print()

asset

asset of the stack

import contentstack;


stack = contentstack.Stack('api_key', 'delivery_token', 'environment');

asset = stack.asset("uid")

print(asset)

get_live_preview

live_previewfor the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

result = stack.get_live_preview

print(result)

get_headers

headers for the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

result = stack.get_headers

print(result)

get_branch

branch for the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

result = stack.get_branch

print(result)

get_environment

environment for the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

result = stack.get_environment

print(result)

get_delivery_token

Delivery Token for the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment);

result = stack.get_delivery_token

print(result)

get_api_key

api_key for the stack

import contentstack;


stack = contentstack.Stack(api_key, delivery_token, environment)          

result = stack.get_api_key

print(result)

early_access

Array of header strings for early access features.

import contentstack;
stack = contentstack.Stack(api_key, delivery_token, environment, early_access=["early_access_1", "early_access_2"]);