Verbb Team Verbb Team Feb 2023 1 min read

Hot on the heels of releasing our Auth (opens new window) Craft module, we're releasing Consume — a plugin to make HTTP requests in your Twig templates and consume data from third-party API providers. What's exciting about this is you'll be able to create and use OAuth-based clients without having to worry about refresh tokens, token management, etc. You can think of it as the client-friendly UI for the Auth module.

Consume supports creating "clients" in the control panel, which you can call in your templates. These clients are either OAuth-based, or Credential-based (a traditional API key). Clients can be configured with base settings in the control panel like query strings, headers and more.

How to create clients in the control panel to use in templates.

Or, you can create HTTP requests directly in your templates. Using OAuth-based providers won't work (because you'll need to complete the initial authentication handshake first), but it's a useful feature if you wanted to download the content of a feed, or even scrape the contents of a web page. You'll have access to a Guzzle (opens new window) client in your templates to create the request as required.

Consume supports 80+ popular OAuth-based API providers. If your provider isn't supported, you can use the Generic OAuth client and add the required OAuth endpoints.

Of course, Consume also comes with a caching mechanism that you can configure, or you can roll your own using the Craft {% cache %} tag.

Finally, Consume also provides helpers to parse the content from the provided endpoint. It supports converting JSON, XML and CSV to arrays, so you can loop through the data in your templates. Consume also supports plain text and HTML if that's the type of content that's reported back.

If you're looking for an alternative to Fetch (opens new window) or OAuth 2.0 Client (opens new window), take Consume for a spin.

Consume (opens new window) is available today for Craft 4 for $19.