---
title: "DataSync Filesystem SDK API Reference"
description: "Contentstack DataSync Filesystem SDK API reference with methods, examples, and usage for querying and managing content from the local filesystem."
url: "https://www.contentstack.com/docs/developers/sdks/datasync-sdk-filesystem/typescript/reference"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-06-05"
---

# DataSync Filesystem SDK API Reference

## DataSync Filesystem SDK API Reference

## Overview

The Contentstack DataSync Filesystem SDK enables developers to synchronize and query Contentstack data directly from a local filesystem, optimizing content delivery and access.

**Additional Resource:** To know more about DataSync Filesystem SDK, refer to the [Get Started with DataSync Filesystem SDK](/docs/developers/sdks/datasync-sdk/typescript/get-started-with-datasync-filesystem-sdk/) documentation.

## Contentstack

The Contentstack module creates an instance of the Contentstack class, which serves as the entry point for initializing a stack.

## Stack

A [stack](/docs/developers/set-up-stack/about-stack) is a repository or a container that holds all the [entries](/docs/content-managers/author-content/about-entries)/[assets](/docs/content-managers/working-with-assets/about-assets) of your site. It allows multiple users to [create](/docs/content-managers/working-with-entries/create-an-entry), [edit](/docs/content-managers/working-with-entries/edit-an-entry), [approve](/docs/content-managers/use-workflows/send-an-entry-for-publish-or-unpublish-approval), and [publish](/docs/content-managers/publish-content) their content within a single space.

The Stack instance provides access to all query methods for fetching entries, assets, and content type data from the local filesystem.

```
Example:
import { Contentstack } from "@contentstack/datasync-filesystem-sdk";
const config = {
  contentStore: {
    baseDir: './_contents',
    defaultSortingField: 'updated_at',
    locale: 'en-us',
    projections: {
      _content_type_uid: 0,
    },
    referenceDepth: 2,
  },
}

const Stack = Contentstack.Stack(config);
```

Base directory of the folder where data is stored

Default locale to use when .language() is not specified in a query

The default nested reference field depth considered when calling .includeReferences(). This can be overridden by passing a numerical argument to .includeReferences(n)

Keys that by default would be removed from results. Pass key: 0 to remove, key: 1 to override the existing

## Global

The Global class provides a collection of methods that define and execute complex queries in the Datasync Filesystem SDK. Use it to filter, sort, and retrieve content from the local filesystem based on specific conditions.

## and

The and method combines multiple query conditions using a logical AND operator and returns entries that meet all the mentioned conditions.

```
Example:
Stack
 .contentType('example')
 .entries()
 .and([{ title: 'John' }, { age: 30 } ])
 .find()
 .then((result) => {
   // Queries local filesystem for entries with title "John" and age 30
 })
 .catch((error) => {
   // Handle errors that occur during the query execution
 })
```

Filters defining the conditions to match the entries

## ascending

The ascending method sorts the fetched entries in ascending order based on the specified field.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.ascending('created_at').find()
data.then((result) => {
  // ‘result’ contains the list of entries which is sorted in ascending order on the basis of ‘created_at’.
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID used to sort the entries

## asset

The asset method retrieves a single asset by its UID.

```
Example:
Stack.asset('uid').find();
// or
Stack.asset().find();
```

UID of the asset

## assets

The assets method retrieves details of all assets.

```
Example:
Stack.assets().find();
```

## connect

The connect method establishes a connection to the filesystem with optional configuration overrides.

```
Example:
Stack.connect({ overrides })
  .then((baseDir) => {
    // Connection established
  })
  .catch((error) => {
    // Handle errors related to filesystem connection
  });
```

Provides optional overrides or filesystem-specific settings

## contentType

The contentType method specifies the content type to query on.

```
Example:
Stack.contentType('example').find()
 .then((result) => {
   // returns entries filtered based on 'example' content type
 })
 .catch((error) => {
   // Handle errors that occur during the query execution
 })
```

UID of the content type

## contentTypes

The contentTypes method retrieves schemas of all content types.

```
Example:
Stack.contentTypes().find()
```

## count

The count method returns the total number of entries matching the query.

```
Example:
const query = Stack.contentType('example').entries().count().find()
query.then((result) => {
  // returns 'example' content type's entries
}).catch(error) => {
  // Handle errors that occur during the query execution
})
```

## descending

The descending method sorts the fetched entries in descending order based on the specified field.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.descending('created_at').find()
data.then((result) => {
  // ‘result’ contains the list of entries which is sorted in descending order on the basis of ‘created_at’.
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID used to sort the entries

## entry

The entry method retrieves a single entry by its UID from the specified content type.

```
Example:
Stack.contentType('example').entry('bltabcd12345').find();
// or
Stack.contentType('example').entry().find();
```

The UID of the entry

## except

The except method accepts an array of field UIDs. Only the fields specified in the array will be excluded from the result set.

```
Example:
const query = Stack.contentType('example').entries().except(['title','uid']).find()
query.then((result) => {
  // ‘result’ contains a list of entries without field title and uid 
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

The field to evaluate

## excludeReferences

The excludeReferences method excludes all references of the entries being scanned.

```
Example:
Stack.contentType('example')
 .entries()
 .excludeReferences()
 .find()
 .then((result) => {
   // ‘result’ entries without references
 }).catch((error) => {
   // Handle errors that occur during the query execution
 })
```

## entries

The entries method retrieves entries from the specified content type.

```
Example:
Stack.contentType('example').entries().find();
```

## exists

The exists method retrieves entries if the value of the specified field exists.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.exists('featured').find()
data.then((result) => {
  // ‘result’ contains the list of entries in which "featured" exists.
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

## findOne

The findOne method queries the local database using the built or provided query and returns a single matching entry, asset, or content type object. It processes the data, applies filters, and resolves references before returning the result.

```
Example:
Stack.contentType('blog')
 .entries()
 .findOne()
```

A query object that overrides all previously built query conditions

## find

The find method queries the local database using the built or optionally provided query object. It processes the data, applies filters, and resolves references before returning the result.

```
Example:
Stack.contentType('blog').entries().find()
.then((result) => {
   // returns blog content type's entries
})
.catch((error) => {
   // Handle errors that occur during the query execution
})
```

A query object that overrides all previously built query conditions

## getQuery

The getQuery method returns the query object built with the applied conditions and filters.

```
Example:
Stack.contentType('example')
 .equalTo('title','Demo')
 .getQuery()
 .find()
```

## greaterThan

The greaterThan method retrieves entries where the value of the specified field is greater than the given number.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.greaterThan('created_at','2015-03-12').find()
data.then((result) => {
  // result contains the data of entries where the 'created_at' date will be greaterthan '2015-03-12'
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## greaterThanOrEqualTo

The greaterThanOrEqualTo method retrieves entries where the field's value is greater than or equal to the specified number.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.greaterThanOrEqualTo('created_at','2015-03-12').find()
data.then((result) => {
  // result contains the data of entries where the 'created_at' date will be  greaterThan or equalto '2015-03-12'
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## include

The include method includes a specific field in the returned result.

```
Example:
Stack.contentType('example')
 .entries()
 .include(['authors','categories'])
 .find()
```

UID of the field

## includeCount

The includeCount method returns the total count of matching entries along with the result set.

```
Example:
Stack.contentType('example')
 .entries()
 .includeCount()
 .find()
```

## includeContentType

The includeContentType method includes the full content type schema along with each entry in the response.

```
Example:
Stack.contentType('example')
 .entries()
 .includeContentType()
 .find()
 .then((result) => {
   // Expected result
   {
     entries: [
       {
         ...,
       },
     ],
     content_type_uid: 'example',
     locale: 'en-us',
     content_type: {
       ..., // Content type example's schema
     }
   }
 }).catch((error) => {
   // Handle errors that occur during the query execution
 })
```

## includeReference

The includeReference method includes referenced entries or assets in the response.

```
Example:
Stack.contentType('example')
 .entries()
 .includeReference()
 .find()
```

Overrides the default reference depth of 4

## language

The language method sets the locale to be used when querying entries.

```
Example:
Stack.contentType('blog').entries().language('fr-fr').find();
```

Language to query on

## lessThan

The lessThan method retrieves entries where the value of the specified field is less than the given number.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.lessThan('created_at','2015-06-22').find()
data.then((result) => {
  // result contains the data who's 'created_at date' is less than '2015-06-22'
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## lessThanOrEqualTo

The lessThanOrEqualTo method retrieves entries where the field's value is less than or equal to the specified number.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.lessThanOrEqualTo('created_at','2015-06-22').find()
data.then((result) => {
  // result contain the data of entries where the 'created_at' date will be less than or equalto '2015-06-22'.
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## limit

The limit method sets the maximum number of entries to retrieve.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.limit(10).find()
data.then((result) => {
  // result contains the limited number of entries
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Maximum number of entries to be returned

## notContainedIn

The notContainedIn method retrieves entries where the specified field's value does not match any in the given array.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.notContainedIn('title', ['Demo', 'Welcome']).find()
data.then((result) => {
  // 'result' contains the list of entries where value of the title field should not be either "Demo" or ‘Welcome’
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## notEqualTo

The notEqualTo method retrieves entries where the field’s value does not equal the specified value.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.notEqualTo('title','Demo').find()
data.then((result) => {
  // ‘result’ contains the list of entries where value of the ‘title’ field will not be 'Demo'.
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Field UID to filter

An array of values to match against

## only

The only method limits the returned fields in the result to the ones specified.

```
Example:
const query = Stack.contentType('example').entries().only(['title','uid']).find()
query.then((result) => {
  // ‘result’ contains a list of entries with field title and uid only
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

The field to evaluate

## or

The or method combines multiple conditions using the logical OR operator.

```
Example:
Stack
 .contentType('example')
 .entries()
 .or([{ title: 'John'}, { title: 'Jane'}])
 .find()
 .then((result) => {
   //  Queries local filesystem for entries with title "John" and age 30
 })
 .catch((error) => {
    // Handle errors that occur during the query execution
})
```

Array of Query objects or raw query conditions

## query

The query method initializes a query builder for the selected content type or resource.

```
Example:
Stack.contentType('example').entries().query({"authors.name": "John Doe"}).find()
 .then((result) => {
   // returns entries, who's reference author's name equals "John Doe"
 })
 .catch((error) => {
   // Handle errors that occur during the query execution
 })
```

A raw JSON query object to define custom filters

## queryReferences

The queryReferences method allows you to perform a query on referenced entries.

```
Example:
Stack.contentType('blog')
 .entries()
 .includeReference() // This would include all references of the content type
 .queryReferences({"authors.name": "John Doe"})
 .find()
```

Query filter to apply on the referenced entries

## referenceDepth

The referenceDepth method is used alongside .includeReferences() to override the default reference resolution depth of **2**. This allows you to resolve deeply nested references—e.g., if A → B → C → D, all levels down to D will be included in the result.

```
Example:
Stack.contentType('blog')
 .entries()
 .includeReferences()
 .referenceDepth(4)
 .find()
```

Level of nested references to be fetched

## regex

The regex method retrieves entries where the specified field matches the given regular expression.

```
Example:
let blogQuery = Stack.contentType('example').entries()
blogQuery.regex('title','^Demo').find() //regex without options
//or
blogQuery.regex('title','^Demo', 'i').find() //regex with options
```

Field UID to filter

An array of values to match against

Value to match or compare against the entry field

## schema

The schema method fetches the schema definition of a content type.

```
Example:
Stack.schema(uid?: string).find()
```

Fetches the schema for the content type with the given UID

## schemas

The schemas method fetches the schemas definition of a content type.

```
Example:
Stack.schemas.find()
```

## skip

The skip method skips a given number of results from the beginning of the result set.

```
Example:
let blogQuery = Stack.contentType('example').entries()
let data = blogQuery.skip(5).find()
data.then((result) => {
  //result
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Skips the specified number of entries in the result set

## tags

The tags method retrieves all unique tags present in the content entries.

```
Example:
const query = Stack.contentType('example').entries().tags(['technology', 'business']).find()
query.then((result) => {
  // "result" contains list of entries which have tags "technology" and "business".
}).catch((error) => {
  // Handle errors that occur during the query execution
})
```

Entries/Assets that have the specified tags

## where

Pass JS expression or a full function to the query system. Evaluate js expressions

```
Example:
const query = Stack.contentType('example').entries().where("this.title === 'Amazon_Echo_Black'").find()
query.then((result) => {
  // ‘result’ contains the list of entries where value of ‘title’ is equal to ‘Amazon_Echo_Black’.
}).catch(error) => {
  // Handle errors that occur during the query execution
})
```

UID of the field

Matches the entry field against this value