ContentstackClient

View as Markdown

ContentstackClient

Initialize an instance of ‘Stack’
NameTypeDescription
SerializerOptions JsonSerializerOptions

Gets or sets the options that should be used for deserialization.

ContentstackClient

Initializes an instance of the ContentstackClient class.

NameTypeDescription
apiKeystring

API Key of your stack on Contentstack.

deliveryTokenstring

Delivery token of your stack on Contentstack.

environmentstring

Environment from where you want to fetch content.

hoststring

Specifies the base URL for the Contentstack API.

Default: cdn.contentstack.io

regionContentstackRegion

Specifies the database region for your stack. You can choose from the following: NA, EU, AU, Azure NA, Azure EU, and GCP NA.

Default: ContentstackRegion.US

versionstring

Specifies the version of the Contentstack API to use.

Default: v3

ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
NameTypeDescription
optionsContentstackOptions

used to get stack details via class ContentstackOptions to create client.

var options = new ContentstackOptions()

 {

       ApiKey = "api_key",

       DeliveryToken = "delivery_token"

       Environment = "environment"

 }

ContentstackClient stack = new ContentstackClient(options);

GetVersion

Get url base version

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

String url = stack.GetVersion();

Asset

Represents a Asset. Creates Asset Instance.

NameTypeDescription
Uidstring

This is Asset Uid of an Asset.

using Contentstack.Core;

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

Asset asset = stack.Asset("asset_uid");

AssetLibrary

Represents a AssetLibrary. Creates AssetLibrary Instance.
using Contentstack.Core; 

using Contentstack.Core.Models;

ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

AssetLibrary assetLibrary = stack.AssetLibrary();

ContentType

Represents a ContentType. Creates ContenntType Instance.
NameTypeDescription
contentTypeUidstring
ContentType UID.

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

ContentType contentType = stack.ContentType("content_type_uid");

GetApplicationKey

Get stack application key

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

String apiKey = stack.GetApplicationKey();

GetAccessToken

Get stack access token

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

String accessToken = stack.GetAccessToken();

GetEnvironment

Get stack environment

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

String environment = stack.GetEnvironment();

GetContentTypes

This method returns comprehensive information of all the content types of a particular stack in your account.

NameTypeDescription
paramDictionary<string, object>

dictionary of additional parameter

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");


var param = new Dictionary<string, object>();

param.Add("include_global_field_schema",true);

param.Add("limit", 10);

param.Add("skip", 10);

param.Add("include_count", "true");

var result = await stack.GetContentTypes(param);

LivePreviewQuery

To add live preview Query for Contentstack preview call

NameTypeDescription
queryDictionary<string, string>

Query parameter containing hash and content type UID

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

await client.LivePreviewQueryAsync(new System.Collections.Generic.Dictionary<string, string>()

{

	{"live_preview" , "live_preview_hash_from_url_query" },

	{"content_type_uid", "content_type_uid<span>_from_url_query</span>" },

	{"entry_uid", "entry_uid<span>_from_url_query</span>" }

});

RemoveHeader

Remove header key.

NameTypeDescription
keystring

key to be remove from header

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

stack.RemoveHeader("custom_header_key")

SyncToken

Syncs the token.

NameTypeDescription
SyncTokenstring

Sync token.

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncToken("sync_token");

SyncRecursive

Syncs the recursive language.

NameTypeDescription
Localestring

Locale

SyncTypeSyncType

Sync type.

ContentTypeUidstring

Content type uid.

StartFromDateTime

Start from.

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncRecursive();

using Contentstack.Core;

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncRecursive(SyncType: SyncType.AssetPublished);

using Contentstack.Core;

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncRecursive(ContentTypeUid: "source");

using Contentstack.Core;

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncRecursive(StartFrom:DateTime.Now);

using Contentstack.Core;

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await client.SyncRecursive(SyncType: SyncType.EntryPublished, ContentTypeUid: "source");

SyncPaginationToken

Syncs the pagination token.

NameTypeDescription
paginationTokenstring

Pagination token.

using Contentstack.Core; 

using Contentstack.Core.Models;


ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");

SyncStack result = await stack.SyncPaginationTokenn("pagination_token");