Skip to content
Utilise the Guzzle HTTP client from within your Craft templates.
Branch: v1
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Fetch plugin for Craft CMS 3.x

Utilise the Guzzle HTTP client from within your Craft templates.


This plugin requires Craft CMS 3.0.0 or later.


To install the plugin, follow these instructions.

  1. Open your terminal and go to your Craft project:

     cd /path/to/project
  2. Then tell Composer to load the plugin:

     composer require lukeyouell/craft-fetch
  3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Fetch.

Using Fetch

This plugin is built to work with the standard Guzzle request options


Parameter Example value
client { base_uri : '', timeout : 10 }
method 'POST'
destination 'api/0.1/test'
options { auth : ['username', 'password'] }

Example Usage


{% set client = {
    base_uri : '',
    timeout : 10
} %}

{% set options = {
    auth : ['username', 'password'],
    form_params : {
      url : ''
} %}

{% set request = fetch(client, 'POST', 'api/0.1/test', options) %}

Response (successful)

   "body": {

You can fetch the string response by adding an additional parameter of false like so:

{% set request = fetch(client, 'POST', 'api/0.1/test', options, false) %}

Response (error)

   "reason":"Client error: `POST https:\/\/\/api\/0.1\/test` resulted in a `401 Authorization Required` response:\n{\u0022error\u0022:\u0022Invalid e-mail and\/or API key\u0022}\n\n"

Fetch Roadmap

Some things to do, and ideas for potential features:

Brought to you by Luke Youell

You can’t perform that action at this time.