This is the official JavaScript/TypeScript library for accessing live and preview content from your Agility CMS instance.
You can use this in both Node.js and browser-based JavaScript apps.
Don't have an Agility CMS instance? Sign up for Free Trial today!
- Query the high-availability, CDN-backed Agility Fetch REST API
- Get a sitemap for a given channel
- Get a page, including its content zones, modules, and their content
- Get a content item
- Query a content list using a filter syntax
- Get the details of a media gallery
- Keep track of syncing content to your app
In order to use this SDK, you'll need to install the @agility/content-fetch package and you'll also need to authenticate your requests.
You must have access to an Agility instance to retrieve the guid and generate your apiKey. Or, you must have these values provided to you.
npm
npm install @agility/content-fetch
yarn
yarn add @agility/content-fetch
import agility from "@agility/content-fetch"
//initialize the api client
const api = agility.getApi({
guid: "[guid]",
apiKey: "[your-api-key]",
})
//make the request: get a content item with the ID 22 in locale 'en-us'
const contentItems = await api.getContentItem({
contentID: 22,
locale: "en-us",
})Full documentation for this SDK can be found in our Agility Fetch JS SDK Reference Doc.
For docs & help around Agility CMS, please see Agility CMS Documentation
About using the Content Fetch API and authenticating API calls
Retrieving your API Key(s), Guid, and API URL
Making your First Call with the Content Fetch API
Calilng the Content Fetch API using the Javascript SDK
Page Management in a Headless CMS
Using Agility CMS with Next.js
Creating a Next.js component in Agility CMS
Creating a page model in Agility CMS
Deploying your Agility CMS Next.js app to Vercel
If you would like to contribute to this SDK, you can fork the repository and submit a pull request. We'd love to include your updates.
An essential part of contributing to this SDK is adding and running unit tests to ensure the stability of the project.
> npm run test
Releases are published to npm automatically by .github/workflows/npm-publish.yml whenever a v* tag is pushed to the repo. To cut a release:
- Bump the
versionfield inpackage.json(following semver) and merge that change intomaster. - Tag the merge commit and push the tag:
git tag v2.0.12 git push origin v2.0.12 - The workflow verifies the tag matches
package.json's version, builds the package, and publishes it to npm under thebetadist-tag. - Once you've verified the
betarelease, promote it tolatest:npm dist-tag add @agility/content-fetch@2.0.12 latest
Publishing uses npm's Trusted Publishing (OIDC) — no NPM_TOKEN secret is stored in this repo.