Content Sync API

The Content Sync API makes it easy to keep a content cache or copy of Agility content so it can be readily accessible to your digital solution without calling home to Agility.

Use Cases

  • You need to support an offline mode and access content without making an API call to Agility.
  • You want to reduce the amount of REST API calls made to Agility.
  • You want so synchronize content from the CMS to another system such Redis Cache.
  • You are running a Server-Side Rendered (SSR)web app and you want to cache your content locally, reducing latency for retrieving content.
  • You are using a Static Site Generator (SSG) and you don't want to have to re-source all of your content on each build.
  • You have a client-side Single Page Application, and want to cache content in local storage in the browser.

How it Works

The Sync API endpoint is part of the Content Fetch API and is available for all customers.

These are the general steps a developer would need to synchronize content from Agility CMS to another system.

Step one: Setup a Webhook in Agility so that you can be notified when changes to our CMS are made.

Step two: When a webhook request is received, make a call to the Sync API :

curl -X GET "https://api.aglty.io/4582b5fa-u/fetch/en-us/sync/items?syncToken=0&pageSize=500" -H "accept: application/json" -H "APIKey: xxxxxxxxxx"

Your first call to the API will have a syncToken of 0

The above call will return all content from the CMS in a paginated manner (max 500 per request), and provide the next syncToken to use.

Step three: Save the results into a local filesystem, database, or Redis Cache

Step four: Continue to query to the Sync API until no results are returned or syncToken=0- this means you are up to date.

Step five: Store the last syncToken you had, so that the next time you call the API you'll get the content that has changed since your last syncToken

Using a Sync SDK

Agility CMS provides a JS SDK to handle syncing and managing for your sync token as well as providing interfaces for storing and accessing previously synced content.

Sync Content using the JS SDK