RECENT UPDATES:
06-Jan-2026 | v7.7.6 | All new article

Change Log

  • 06-Jan-2026 | v7.7.6 | All new article

Contributors:

Adam Wilson - Logo Pogo

api_request

This module component lets you make authenticated HTTP requests directly in your templates, via Liquid, using credentials stored in the `External API Credentials` section of the admin.

{% component type:"api_request", auth:"<ALIAS>", method:"<METHOD>", url:"<API ENDPOINT>", body: "<REQUEST OBJECT>" collectionVariable: "yourLiquidVariableName" %}

Parameters and Options

Parameter
Values
Required
Description
type
api_request
This system parameter identifies the type of component for retrieving data from the CMS.
auth
<ALIAS>
The item alias name that the credentials are to be sourced from.
method
<METHOD>

The supported HTTP methods are:

GET
Used to retrieve data from a server (it does not change any data).

POST
Used to send data to the server and create a new resource.

PUT
Used to update a resource by sending the entire new version of that resource.

PATCH
Used to modify existing data. It updates a resource by sending only the specific fields that need to be changed.

url
<API ENDPOINT>
The URL endpoint of the external API you are connecting to.
body
<REQUEST OBJECT>
A JSON object that represents the request sent to the external API.
eg: {\"limit\": 10}
headers
<HEADER NAME/VALUE PAIR>
A JSON object that represents the name/value pair for any HTTP Headers sent along with the request.
eg: {\"header name\": \"header value\"}
layout
<path/to/layout>

Path to file that will contain the Liquid layout content to be parsed.

If the parameter is blank, has an incorrectly referenced Layout, or is removed altogether then the component will still output the modules item data to a Liquid collection which can be accessed via the collectionVariable parameter.

collectionVariable
<yourLiquidVariableName>

Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

Accessing the Data

JSON Output

You can output the full JSON for your component data by referencing the root Liquid object {{this}} in your custom layout file, or directly on your page, if using the collectionVariable parameter in your component tag.

For example:

{% component type: ... collectionVariable: "myData" %}

You can then render the JSON like so:

{{myData}}

For more details on using this approach, see Part 2 of the free ‘Learning Liquid Course’.

Rendering Property Values

This data is accessible in two main ways:

1. Using Liquid in the specified layout file via the this object, eg:

{{this.response['name']}}

2. Directly on the Page or Template via a Liquid Collection if collectionVariable was added to the Component tag.

An example using collectionVariable with value "myApiData":

{% component type: "api_request", auth: "myCredentials", method: "GET", url:"https://example.com/api", collectionVariable: "myApiData" %}

Looping through the collection to render the data provided by the API, eg:

  • United States
  • Australia
  • Germany
  • France

The code:

<ul>
{% for i in myApiData.response %}
    <li>{{i['name']}}</li>
{% endfor %}
</ul>