---
title: "AssetLibrary"
description: "AssetLibrary"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/java/reference/assetlibrary"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-22"
---

# AssetLibrary

## AssetLibrary

In Contentstack, any files (images, videos, PDFs, audio files, and so on) that you upload get stored in your repository for future use. This repository of uploaded files is called Assets.

## sort

The sort method sorts the asset library based on order criteria.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.sort(keyOrderBy, ORDERBY.ASCENDING);
```

the key order by

the orderby can be applied using ORDERBY enums

## includeCount

The includeCount method includes the total count of assets in the asset library response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeCount();
```

## includeRelativeUrl

The includeRelativeUrl method includes the relative URLs of assets in the asset library response.

```
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack(context, apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary()
assets.includeRelativeUrl();
```

## includeMetadata

Includes asset metadata along with response body.

```
Stack stack = Contentstack.stack("apiKey", "deliveryToken", environment_name);
AssetLibrary assets = stack.assetLibrary();
assets.includeMetadata();
```

## where

The where() method retrieves the assets from the stack using any other field UID of the assets.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack(apiKey, deliveryToken, environment);
AssetLibrary assets = stack.assetLibrary().where("field_name","value");
assets.fetchAll(new FetchAssetsCallback() {
@Override
 public void onCompletion(ResponseType responseType, List<asset> assets, Error error) {
    System.out.println(assets);
       } });
```

Field UID of the Asset

Value of the Asset

## addParam

The addParam method adds a query parameter to the query.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
AssetLibrary assetLibObject = stack.assetlibrary();
assetLibObject.addParam(paramKey, paramValue);
```

Pass the key

Pass the value

## removeParam

The removeParam method removes a query parameter from the query.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
AssetLibrary assetLibObject = stack.assetlibrary();
assetLibObject.removeParam(paramKey);
```

Pass the key to be removed as a param

## limit

The limit method will return a specific number of assets in the output.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
AssetLibrary assetLibObject = stack.assetlibrary().limit(4);
```

Enter the number of assets to be returned.

## skip

The skip method will skip a specific number of assets in the output.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
AssetLibrary assetLibObject = stack.assetlibrary().skip(4);
```

Enter the number of assets to be skipped.

## Pagination

In a single instance, a query will retrieve only the first 100 items in the response. You can paginate and retrieve the rest of the items in batches using the skip and limit methods.

```
Example:
import com.contentstack.sdk.*;
Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
AssetLibrary assetLibObject = stack.assetlibrary();
int skip = 0, limit = 100;
final int[] totalAssetsFetched = {0};
final boolean[] hasMore = {true};
 while (hasMore[0]) {
             assetLibrary.skip(skip).limit(limit).fetchAll(new FetchAssetsCallback() {
                @Override
                public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
                    if (error != null) {
                        System.err.println("Error: " + error.getErrorMessage());
                        return;
                    }
                    for (Asset asset : assets) {
                        System.out.println(asset.toJSON());
                    }
                    totalAssetsFetched[0] += assets.size();
                }
            });
            skip += limit;
            System.out.println("Total assets fetched: " + totalAssetsFetched[0]);
            if (totalAssetsFetched[0] % limit != 0) {
                hasMore[0] = false;
            }
        }
```

## setLocale

The setLocale method sets the locale used for asset queries, so results are returned for a specific language or region.

```
This is an instance of method chaining. You can chain it with other AssetLibrary methods (for example, setLocale("en-us").includeCount().fetchAll(...)).
import com.contentstack.sdk.*;

Stack stack = Contentstack.stack("API_KEY", "DELIVERY_TOKEN", "ENVIRNOMENT");
AssetLibrary assets = stack.assetLibrary();
assets.setLocale("en-us");
assets.fetchAll(new FetchAssetsCallback() {
    @Override
    public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
        if (error != null) {
            System.err.println("Error: " + error.getErrorMessage());
            return;
        }
        // use assets
    }
});
```

Locale code for the query (for example, "en-us"). Used in requests built with fetchAll() to determine which localized asset data is returned.

## Config

## AssetLibrary | Java Delivery SDK | Contentstack

AssetLibrary fetches and manages the files you upload to your stack repository in the Contentstack Java Delivery SDK.