This tutorial requires you to have signed up for an Agility subscription using the Blog template. Don't have it? Sign up now for free (forever)!
The Content Fetch API is a RESTful web service which can be called using any HTTP client. In this example, we'll show you how to make an API Request using a popular command-line tool called curl.
In order to make an Authenticated HTTP request to the Content Fetch API, you need the following values:
- API URL - the URL in which to make the request to
- API Key - the secret key that allows you to make a request to the API
See Retrieving your API Key and API URL for details on how to retrieve this information for your instance.
The following example requests a List of content from Agility based on the referenceName posts:
The response for the request is provided in JSON format:
The Anatomy of a Request
Each type of API request requires three mandatory parameters:
Your API Key, which is stored in the Headers of your API request.
Your API Type, which defines whether you are intending to request preview content (the latest) or fetch (only published content) - this is set in the URL path
Your Language Code, which represents the language code for the content you are requesting
URL Path Parameters
Since each type of API request is a GET request, all parameters (aside from the API Key) are set in the URL path.
All requests follow this pattern:
guid - Your unique ID for your instance.
apitype - "preview" or "fetch".
lang - The language code for the content you are requesting.
requestType - Represents the specific type of request you want to make (i.e. "item", "list", "page", "sitemap/flat", or "sitemap/nested").
requestParams - The parameters specific to this request type, this is usually an identifier for the type of content you want to retrieve such as a reference name or id. Some requests types also accept additional parameters in the form of a query string such as the "List" method, which accepts a series of sort, filter, and pagination parameters.
Explore the API
Check out the full details of the Content Fetch REST API, and execute requests from within the browser by Exploring the Content Fetch API using Swagger.