jalendport/craft-fetch

This package is abandoned and no longer maintained. The author suggests using the verbb/consume package instead.

Utilise the Guzzle HTTP client from within your Craft templates.

Maintainers

Package info

github.com/jalendport/craft-fetch

Documentation

Type:craft-plugin

pkg:composer/jalendport/craft-fetch

Transparency log

Fund package maintenance!

jalendport

Statistics

Installs: 27 862

Dependents: 1

Suggesters: 0

Stars: 23

Open Issues: 0

2.0.0-beta.1 2023-06-08 22:22 UTC

This package is auto-updated.

Last update: 2026-07-22 15:32:50 UTC


README

Warning

This plugin has been abandoned.

icon

Fetch plugin for Craft CMS

Why this plugin is retired

Fetch made synchronous, uncached HTTP requests during Twig rendering. That was a convenient shortcut in 2018, but it's now a well-documented performance anti-pattern: every page render blocks on the external API, and if that API slows down or goes down, so does your site. Craft can also now do everything this plugin did natively, with no plugin installed.

Migrating away from Fetch

Option 1: Native Twig (direct replacement)

Guzzle ships with Craft, and Craft's create() Twig function can instantiate it — no plugin required. This is a drop-in replacement for what Fetch did:

{% set client = create('GuzzleHttp\\Client') %}

{% set response = client.request('GET', 'https://api.example.com/endpoint', {
    timeout: 5,
    http_errors: false,
}) %}

{% if response.getStatusCode() == 200 %}
    {% set data = response.getBody().getContents() | json_decode %}
{% endif %}

Note that this has the same drawback Fetch had: it blocks the render. If you use it, wrap the output in a {% cache %} tag at minimum.

Option 2: Do it properly (recommended for production)

  • Server-side data: fetch in a custom module/service and cache the result, keeping HTTP out of the render path entirely.
  • Async partials: use Sprig or htmx to load API-driven fragments after first paint.
  • Non-critical or personalized data: fetch client-side in JavaScript.

Option 3: Maintained plugin alternatives

  • Consume by Verbb — commercial; built-in caching, OAuth/credential management in the control panel, JSON/XML/CSV/HTML parsing.
  • Simple Guzzle — free; template-level requests with caching.

Thanks

Thanks to Luke Youell for creating this plugin, and to everyone who used and contributed to it over the years.