Agility CMS Sync SDK
The Agility CMS Sync REST API provides an interface to sync, store, and access content locally.
By keeping a local cache of your content, your web app can access content faster.
- Access your content quickly, and locally in your web or mobile app
- Use your own persistent storage, such as Gatsby GraphQL, a Database, or Local Storage
- Simplify syncing content
- You want to reduce the amount of REST API calls made to your Agility CMS instance.
- 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 Agility CMS Content Fetch API and is available for all customers.
This is the general flow that a developer would need to synchronize content from Agility CMS to another system.
- Setup a webhook in Agility CMS so that you can be notified when changes to our CMS are made
- 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.
- Save the results into a local filesystem, database, or Redis Cache
- Continue to query to the Sync API until no results are returned or syncToken=0 - this means you are up to date.
- 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.