PHPackages                             leowebguy/simple-guzzle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. leowebguy/simple-guzzle

ActiveCraft-plugin[HTTP &amp; Networking](/categories/http)

leowebguy/simple-guzzle
=======================

Simple Guzzle plugin for Craft CMS

2.0.0(2y ago)0364[1 issues](https://github.com/leowebguy/simple-guzzle/issues)proprietaryPHPPHP ^8.2

Since Apr 20Pushed 1y ago1 watchersCompare

[ Source](https://github.com/leowebguy/simple-guzzle)[ Packagist](https://packagist.org/packages/leowebguy/simple-guzzle)[ RSS](/packages/leowebguy-simple-guzzle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (4)Used By (0)

Simple Guzzle plugin for Craft CMS
==================================

[](#simple-guzzle-plugin-for-craft-cms)

A simple way to call guzzle and cache data from API's

Table of Contents
-----------------

[](#table-of-contents)

1. [Install](#install)
2. [Parameters](#parameters)
3. [Usage](#usage)
    1. [GET Json](#get-json)
    2. [GET non-Json](#get-non-json)
    3. [GET with Options](#get-with-options)
    4. [GET with Caching](#get-with-caching)
    5. [POST with Bearer Auth](#post-with-bearer-auth)
    6. [POST with Basic Auth](#post-with-basic-auth)
4. [Twig Output](#twig-output)

Install
-------

[](#install)

```
composer require leowebguy/simple-guzzle && php craft plugin/install simple-guzzle
```

Parameters
----------

[](#parameters)

ParameterExample value`client``{ base_uri: 'https://api.myapi.com/' }``method``'GET'``destination``'v1/path'``headers``{ headers: { 'client_id': 'your-id', 'client_secret': 'your-secret' }}``cache``0`Usage
-----

[](#usage)

### GET Json

[](#get-json)

```
{% set request = guzzle({
    base_uri : 'https://official-joke-api.appspot.com/'
}, 'GET', 'random_joke') %}

{% header "Content-Type: application/json; charset=utf-8" %}
{{ request|json_encode|raw }}
```

Result

```
{
    "type": "general",
    "setup": "Who is the coolest Doctor in the hospital?",
    "punchline": "The hip Doctor!",
    "id": 302
}
```

### GET non-Json

[](#get-non-json)

*Plugin will automatically return string if result can't be parsed as Json*

```
{% set request = guzzle({
    base_uri : 'http://api.geonames.org/'
}, 'GET', 'srtm1?lat=50.01&lng=10.2&username=demo&style=full') %}

{{ request }}
```

Result

```
"208"

```

### GET with Options

[](#get-with-options)

```
{% set request = guzzle({
    base_uri: 'https://currency-converter5.p.rapidapi.com/'
}, 'GET', 'currency/convert?from=USD&to=CAD&amount=1', {
    headers: {
        'X-RapidAPI-Key': 'you-api-key',
        'X-RapidAPI-Host': 'currency-converter5.p.rapidapi.com'
    }
}) %}
```

Result

```
{
    "base_currency_code": "USD",
    "base_currency_name": "United States dollar",
    "amount": "1.0000",
    "updated_date": "2023-04-19",
    "rates": {
        "CAD": {
            "currency_name": "Canadian dollar",
            "rate": "1.3443",
            "rate_for_amount": "1.3443"
        }
    },
    "status": "success"
}
```

### GET with Caching

[](#get-with-caching)

By default cache will be set to `0` meaning no caching unless you provide a cache duration in seconds. ex: `3600` = 1h , `86400` = 24h

```
{% set request = guzzle({
    base_uri : 'https://official-joke-api.appspot.com/'
}, 'GET', 'random_joke', {}, 3600) %}

{% header "Content-Type: application/json; charset=utf-8" %}
{{ request|json_encode|raw }}
```

### POST with Bearer Auth

[](#post-with-bearer-auth)

```
{% set request = guzzle({
    base_uri: 'https://api-ssl.bitly.com/'
}, 'POST', 'v4/bitlinks', {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer my-bearer-token'
    },
    body: '{
              "domain": "bit.ly",
              "long_url": "https://craftcms.com/"
           }'
}) %}
```

Result

```
{
    "created_at": "2023-04-20T00:10:44+0000",
    "id": "bitly.is/41no4QW",
    "link": "https://bitly.is/41no4QW",
    "custom_bitlinks": [],
    "long_url": "https://craftcms.com/",
    "archived": false,
    "tags": [],
    "deeplinks": [],
    "references": {
        "group": "https://api-ssl.bitly.com/v4/groups/Bi331psZCY8"
    }
}
```

### POST with Basic Auth

[](#post-with-basic-auth)

```
{% set request = guzzle({
    base_uri: 'https://gtmetrix.com/api/2.0/'
}, 'POST', 'tests', {
    headers: {
        'Content-Type': 'application/vnd.api+json'
    },
    auth: ['my-auth', ''],
    body: '{
              "data": {
                  "type": "test",
                  "attributes": {
                      "url":      "https://craftcms.com"
                  }
              }
           }'
}) %}
```

*Basic auth usually accepts username and password as parameters ex: `auth: ['username', 'password'],` in the example above the `token` is passed as username and pw is blank, per gtmetrix documentation.*

Result

```
{
    "data": {
        "id": "tMsUIR0M",
        "type": "test",
        "attributes": {
            ...
        }
    },
    "meta": {
        "credits_left": 49,
        "credits_used": 1
    },
    "links": {
        "self": "https://gtmetrix.com/api/2.0/tests/tMsUIR0M"
    }
}
```

Twig Output
-----------

[](#twig-output)

Making sure y'all understand how to output those results into your template.

```
{% set request = guzzle({
    base_uri: 'https://api.openai.com/v1/'
}, 'POST', 'completions', {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer my-bearer-token'
    },
    body: '{
              "model": "text-davinci-003",
              "prompt": "Hello, who are you?"
           }'
}) %}

Question: Hello, who are you?
Answer: {{ request.choices[0].text }}
```

Output

```
Question: Hello, who are you?
Answer: I'm Naveen. It's nice to meet you.
```

In the example above `request` outputs:

```
{
    "id": "cmpl-77BD86ixAzutOIdaOP6nNY98V5vSf",
    "object": "text_completion",
    "created": 1681945746,
    "model": "text-davinci-003",
    "choices": [
        {
            "text": "\n\nI'm Naveen. It's nice to meet you.",
            "index": 0,
            "logprobs": null,
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 6,
        "completion_tokens": 14,
        "total_tokens": 20
    }
}
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~171 days

Total

3

Last Release

783d ago

Major Versions

1.0.1 → 2.0.02024-03-27

PHP version history (2 changes)1.0.0PHP ^8.0.2

2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/44216bb5de0cacbd3d995a1a71c3ee395bd36380305e547ac31452f86d4cd713?d=identicon)[leowebguy](/maintainers/leowebguy)

---

Top Contributors

[![leowebguy](https://avatars.githubusercontent.com/u/8460020?v=4)](https://github.com/leowebguy "leowebguy (5 commits)")

---

Tags

craft-cmscraft-cms-plugincraft4craft5apicurlGuzzlegetpostfetch

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/leowebguy-simple-guzzle/health.svg)

```
[![Health](https://phpackages.com/badges/leowebguy-simple-guzzle/health.svg)](https://phpackages.com/packages/leowebguy-simple-guzzle)
```

###  Alternatives

[phpgt/fetch

Asynchronous HTTP client with promises.

3724.0k3](/packages/phpgt-fetch)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[elementaryframework/water-pipe

URL routing framework and requests/responses handler for PHP

254.6k4](/packages/elementaryframework-water-pipe)[jalendport/craft-fetch

Utilise the Guzzle HTTP client from within your Craft templates.

2327.6k1](/packages/jalendport-craft-fetch)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
