Introducing the Contentstack Sync API for Developers

Contentstack Sync API for data synchronization.jpeg

It goes without saying that mobile applications these days should be capable of working even with intermittent or no internet connection.

Consider the Gmail mobile app, for example. You can access existing emails and create new emails without an active internet connection. As soon as the device establishes an internet connection, the app fetches new incoming emails and sends the ones that you created.

This is made possible by a concept called ‘synchronization’.

Contentstack now brings you the same functionality via its new Sync API. Let’s dig deeper to understand what it is and how it works.

What is the Contentstack Sync API?

The Sync API allows you to save your app data on a device’s local storage and then fetch incremental changes through so-called delta updates. After it first syncs data, the system delivers only the content that was changed since the last sync.

Let’s understand the Sync API in more detail.

How does the Sync API work?

Applications, especially mobile apps, need to work even without an internet connection. 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.

When an application is accessed for the first time, the Initial Sync request of the Sync API allows your app to download and save a local copy of all the data of the stack (for e.g., all existing emails in your Gmail account). This ensures that even if the mobile loses internet connection, the user is able to access the data.

When the device re-connects to the internet, the Subsequent Sync request of the Sync API ensures that the app receives only the updates missed while the connection was lost (for e.g., new email received).

Without the Sync API, the device would always need an active internet connection, otherwise, it may not work. Furthermore, after losing internet connection, the app would need to fetch the entire content again the next time it establishes a connection.

That’s a lot of work for an app with potentially limited bandwidth or sporadic connectivity.

The Sync API is, therefore, a key component of any data-driven mobile app. Let’s look at some of the advantages of using the Sync API.

Advantages of Sync API

The Sync API is beneficial for developers and business users alike. It makes your app faster and smarter while saving time and preserving resources. Let’s look at some of the important advantages that Sync API offers.

  • Lower data consumption
    The Sync API allows your app to fetch only the data that has changed since the last sync. This consumes significantly less data compared to fetching the entire dataset, which is especially useful for data plans with strict usage limitations. It also means that users don’t miss important updates even when the internet connection is slow.
  • Improved app performance
    The Sync API ensures that your app can ignore data that hasn’t changed, and only load data that has been added or updated. As a result, it takes much less time to perform app operations that required the latest data.
  • All data at once
    The Initial Sync API request updates ALL the data in your app at once. It delivers everything that has ever been published to a publishing environment of the corresponding stack. This was previously not possible through the traditional content delivery API since they only help you obtain entries of a specific content type at once, not of all content types in a single request.
  • Fewer development cycles
    Thanks to Sync API, developers don’t have to spend time building synchronization infrastructure. They can instead work on building features that customers want, and leave the rest to Contentstack.

Ready to build powerful sync and offline apps?

Here are a few resources that you will get you started building your new Sync API-powered applications: