PHPackages                             masnathan/api-caller - 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. masnathan/api-caller

AbandonedArchivedLibrary[HTTP &amp; Networking](/categories/http)

masnathan/api-caller
====================

Calling APIs made easy.

v2.0.0(8y ago)51.2k[1 issues](https://github.com/MASNathan/APICaller/issues)1MITPHPPHP &gt;=5.6

Since Oct 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/MASNathan/APICaller)[ Packagist](https://packagist.org/packages/masnathan/api-caller)[ Docs](https://github.com/MASNathan/APICaller)[ RSS](/packages/masnathan-api-caller/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (8)Versions (6)Used By (1)

APIcaller
=========

[](#apicaller)

[![Downloads with Composer](https://camo.githubusercontent.com/9a80edcc40f7613fe5c685c5cdd24fd9a7666931ee3bebf1df745074f19934f0/68747470733a2f2f706f7365722e707567782e6f72672f6d61736e617468616e2f6170692d63616c6c65722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/masnathan/api-caller)[![SensioLabs Insight](https://camo.githubusercontent.com/453158d249b5d7d746f9582bcbd4e808dfed2b25f18cdaf15b46d9d56f49f904/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61316266623761382d306233342d343131382d613435312d6663386631353865663963372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/6d9231d8-9140-4b02-9522-5d3c3aa3d6f2)[![ReiDuKuduro @gittip](https://camo.githubusercontent.com/7e9efc67c5c98dcf25825fab912f954aeea2e8e8aebde707a368dcf21875fc94/687474703a2f2f626f74746c6570792e6f72672f646f63732f6465762f5f7374617469632f4769747469702e706e67)](https://www.gittip.com/ReiDuKuduro/)

APIcaller is a class that helps you build API wrappers.
You don't have to worry about building URLs, or even about parsing the requested data.

How to use
----------

[](#how-to-use)

You will have to extend the `Client` class and the `Caller` class, the `Client` will handle all the configuration to use on the requests and the `Caller` will be used as the interface to interact with the API.

```
use MASNathan\APICaller\Client;
use MASNathan\APICaller\Caller;

class MyPackageClient extends Client
{
    /**
     * Here you can set the default headers and parameters on a global scope
     */
    public function __construct($ip = null)
    {
        $this->setDefaultHeaders([
            'User-Agent' => 'PHP APICaller SDK',
            'Accept'     => 'application/json',
            'Token'      => '123456',
        ]);
        $this->setDefaultParameters([
            'ip' => $ip ?: '127.0.0.1',
        ]);
    }

    /**
     * Returns the API Endpoint
     *
     * @return string
     */
    public function getEndpoint()
    {
        return 'http://api.domain.com/v1/';
    }
}

class MyPackageCaller extends Caller
{
    public function requestSomething($foo, $bar)
    {
        $params = [
            'foo' => $foo,
            'bar' => $bar,
        ];

        // this will result in this url http://api.domain.com/v1/some-method.json?ip={$ip}&foo={$foo}&bar={$bar}
        $response = $this->client->get('some-method.json', $params);

        $data = $this->handleResponseContent($response, 'json');

        // Do something with your data

        return $data;
    }
}
```

Well, this is how you can start creating your class, now, lets make some calls!

```
$client = new MyPackageClient('8.8.8.8');
$caller = new MyPackageCaller($client);

$result = $caller->requestSomething(13, 37);

var_dump($result);
```

This will call the following url:`http://api.domain.com/v1/some-method.json?ip=8.8.8.8&foo=13&bar=37`.

Installation
------------

[](#installation)

To install the SDK, you will need to be using [Composer](http://composer.org) in your project. If you don't have composer installed check this page and follow the [installation steps](https://getcomposer.org/download/)

This library is not hard coupled to Guzzle or any other library that sends HTTP messages. It uses an abstraction called [HTTPlug](http://httplug.io/). This will give you the flexibility to choose what PSR-7 implementation and HTTP client to use.

To get started ASAP you should run the following command:

```
# Add APIcaller as a dependency
$ composer require masnathan/api-caller php-http/curl-client guzzlehttp/psr7
```

Why do I need to require all those packages?
--------------------------------------------

[](#why-do-i-need-to-require-all-those-packages)

APICaller depends on the virtual package [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation)which requires to you install an adapter, but we do not care which one. That is an implementation detail in your application. We also need a PSR-7 implementation and a message factory.

You don't have to use the [php-http/curl-client](https://github.com/php-http/curl-client) if you don't want to. Read more about the virtual packages, why this is a good idea and about the flexibility it brings at the [HTTPlug docs](http://docs.php-http.org/en/latest/index.html).

License
=======

[](#license)

This library is under the MIT License, see the complete license [here](LICENSE)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~346 days

Total

5

Last Release

3220d ago

Major Versions

0.3.0 → 1.0.02017-07-21

1.0.0 → v2.0.02017-07-21

PHP version history (2 changes)0.2.0PHP &gt;=5.3.0

1.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2139464?v=4)[André Filipe](/maintainers/MASNathan)[@MASNathan](https://github.com/MASNathan)

---

Top Contributors

[![MASNathan](https://avatars.githubusercontent.com/u/2139464?v=4)](https://github.com/MASNathan "MASNathan (75 commits)")

---

Tags

api-clientapi-wrapperapicallerhttp-clientphprequestapiwebservice

### Embed Badge

![Health badge](/badges/masnathan-api-caller/health.svg)

```
[![Health](https://phpackages.com/badges/masnathan-api-caller/health.svg)](https://phpackages.com/packages/masnathan-api-caller)
```

###  Alternatives

[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[dhope0000/lxd

PHP-based API wrapper for LXD REST API.

136.2k](/packages/dhope0000-lxd)[elementaryframework/water-pipe

URL routing framework and requests/responses handler for PHP

254.6k4](/packages/elementaryframework-water-pipe)[megaads/apify

A pretty library to help developers build RESTful APIs lightly, quickly and properly even without writing code

151.7k](/packages/megaads-apify)

PHPackages © 2026

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