Syncing Content using the Content Fetch REST API

Follow

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.

Benefits

  • 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

Use Cases

  1. You want to reduce the amount of REST API calls made to your Agility CMS instance.
  2. You want so synchronize content from the CMS to another system such Redis Cache
  3. You are running a Server-Side Rendered (SSR) web app and you want to cache your content locally, reducing latency for retrieving content.
  4. 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.
  5. 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.

  1. Setup a webhook in Agility CMS so that you can be notified when changes to our CMS are made
  2. When a webhook request is received, make a call to the Sync API :
    curl -X GET "https://4bd933b3-53a2-4112-b0af-40077f8562c6-api.agilitycms.cloud/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.
  3. 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.
  4. Save the results into a local filesystem, database, or Redis Cache
  5. Continue to query to the Sync API until no results are returned or syncToken=0 - this means you are up to date.
  6. 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

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.