Applications, especially data-driven apps, should work even without an internet connection, while using updated information all the time. To do this, the client app must synchronize with Contentstack regularly, and especially after a period of internet disconnection. This synchronization is now done through the Sync API.
Contentstack’s Sync API allows you to sync published content of your stack with your app, and provide only incremental updates (i.e., delta updates) thereafter. This keeps your app data up-to-date, and allows it to work offline as well.
The Sync API is part of our Content Delivery APIs and can be used to sync complete data and fetch incremental updates subsequently. It provides three main synchronization requests:
Initial sync: This request is used to sync complete data, i.e., the content of a stack that has ever been published to the specified environment. This is usually used to load data during app initialization when the user uses the app for the very first time. You can use various queries to get the results of specific content types or starting from a specific date or both.
Subsequent sync: This request helps you keep your app up-to-date by providing delta updates. If an initial sync is done, this request fetches only the content that was published since the last sync.
Pagination token: If the response of the initial sync or subsequent sync requests contains more than 100 records, the response is paginated. You will get the first 100 records in the response along with a pagination token, which you can use to fetch subsequent batches of data.
Read our Sync API documentation to get started with the Sync API.
Most of our content delivery SDKs support Sync API. Click the links below to understand how to use the Sync API with our SDKs.
You can also refer to our SDK-specific playground apps to get started with Contentstack Sync API. You can clone these apps and try our the APIs to get a first-hand experience of the synchronization methods.
The Persistence Library helps you save data on the local database of your sync app, and lets your app work offline as well. This library contains methods that are required to map data fields of your content types and Realm.
We have created a couple of example applications that demonstrate the usage of data persistence with our SDKs. Use the links below to navigate to the required pages: