---
title: "Client"
description: "Client"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/ruby/reference/client"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-04"
---

# Client

## Client

Initialize an instance of ‘Client’

## assets

Retrieves all assets of a stack by default.

```
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@assets = @stack.assets.fetch;
```

## asset

Retrieve a single asset with its UID.

```
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@asset = @stack.asset("asset_uid").fetch;
```

The asset uid

## content_types

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

```
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@content_types = @stack.content_types;
```

## content_type

Set the content type of which you want to retrieve the entries

```
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@content_type = @stack.content_type("content_type_uid");
```

UID of the existing content type

## live_preview_query

For live preview data to be fetched provide query parameter to this function

```
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@stack.live_preview_query({
	"live_preview": "live_preview_hash",
	"content_type_uid": "content_type_uid",
	"entry_uid": "entry_uid"
});
```

Query parameter for live preview contents.

## sync

Syncs your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates

```
For initializing sync:
require "contentstack";

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment");
@result = @stack..sync({'init': true});For initializing sync with entries of a specific locale:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'init': true, 'locale': 'en-us'});
For initializing sync with entries published after a specific date:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'init': true<span>,</span><span> </span><span>'start_date'</span><span>:</span><span> </span><span>'2018-10-22'</span>});
For initializing sync with entries of a specific content type:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'init': true, 'content_type_uid': 'session'});
For initializing sync with specific type:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'init': true, 'type': 'entry_published'});
For fetching the next batch of entries using pagination token:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'pagination_token': '<page_token>'});
 For performing subsequent sync after initial sync:
require "contentstack"; 

@stack = Contentstack::Client.new("api_key", "delivery_token", "environment"); 
@result = @stack.sync({'sync_token': '<sync_token>'})
```

initializing sync

initializing sync with entries of a specific locale

initializing sync with entries of a specific content type

Use the type parameter to get a specific type of content.Supports 'asset\_published', 'entry\_published', 'asset\_unpublished', 'entry\_unpublished', 'asset\_deleted', 'entry\_deleted', 'content\_type\_deleted'

Fetching the next batch of entries using pagination token

Performing subsequent sync after initial sync

## Client

Stack API key

Stack environment specific delivery token

Stack environment for data to be fetched from

Stack API Key.

Stack Delivery token.

Stack Environment name.

## Client | Ruby Delivery SDK | Contentstack

The Client class in the Ruby Delivery SDK initializes a client instance that serves as the entry point for accessing your Contentstack stack content.