Using the SDK with NPM (Node Package Manager)
- Install the Agility Content Fetch JS SDK package into your project:
> npm install @agility/content-fetch
import agility from '@agility/content-fetch'
- Initialize the client with your Guid, ApiKey, and optionally set isPreview=true (if you are using a preview API Key).
Don't know your Guid or API Key? See Retrieving your API Key(s), Guid, and API URL.
Then you can use the client to execute requests in a variety of ways:
Using the SDK with a Script Reference and Global Variable
While we highly recommend using an NPM set up for new projects, we understand that there are times where that just isn't feasible. For these cases, you can include the SDK by referencing it in a <script> tag and then accessing it using the assigned global variable called agility.
Add a reference to the agility-content-fetch.browser.js file:
<!-- Use a specific version (i.e. 0.5.0) -->
<!-- Or, Use the latest version -->
Next, you can access the global variable named agility, initialize the client, and start making API calls.