PHPackages                             adamculp/api-consumer - 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. adamculp/api-consumer

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

adamculp/api-consumer
=====================

Basic API wrapper for dealing with REST APIs.

1.0.0(13y ago)81253[1 issues](https://github.com/adamculp/api-consumer/issues)[1 PRs](https://github.com/adamculp/api-consumer/pulls)1MITPHPPHP &gt;=5.3.0CI failing

Since Apr 12Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/adamculp/api-consumer)[ Packagist](https://packagist.org/packages/adamculp/api-consumer)[ RSS](/packages/adamculp-api-consumer/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)DependenciesVersions (3)Used By (1)

[![CircleCI](https://camo.githubusercontent.com/5195440cfd297689935311a5bcaf9a0030f5345e9317aec577907e786ac41cbc/68747470733a2f2f636972636c6563692e636f6d2f67682f6164616d63756c702f6170692d636f6e73756d65722e7376673f7374796c653d737667)](https://circleci.com/gh/adamculp/api-consumer)

About
-----

[](#about)

Simple PHP 7.3 class to consume an API through GET using Curl. (created to consume APIs, and could be used for other things) Methods build API URL params, connection url, and parse expected JSON response.

In the future I intend to add the possibility of an XML return as well, and may even break out the limited Curl functionality to another class, or simply use Guzzle.

Requirements
------------

[](#requirements)

Requires PHP version 7.3 if namespaces are desired.

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

[](#installation)

This class can be used directly from a GIT clone:

```
git clone https://github.com/adamculp/api-consumer.git

```

You could also download the ApiConsumer package and move the directory to a desired location where your scripts can then call it.

Alternatively you could simply copy the ApiConsumer.php file to a desired location and call it that way as well.

Non-Composer Usage
------------------

[](#non-composer-usage)

This class was written using namespaces available via PHP 5.3+, and if left unchanged would be used in the following manner: NOTE: This class contains information needed to utilize a certain Mashery API at Active.com, but you can change the URL and params as needed for other APIs that return JSON.

```
require_once 'path/to/src/ApiConsumer/Consumer.php';
use ApiConsumer\Consumer;

$apiConsumer = new Consumer();
$url = 'http://api.amp.active.com/search?';

$apiConsumer->setUrl($url);

$meta = 'meta:channel=Running+meta:startDate:daterange:today..' . date('Y-m-d', strtotime('next month'));
$params = array(
                'k' => 'ultra+marathon',
                'v' => 'json',
                'l' => 'Florida',
                'r' => '25',
                's' => 'date_asc',
                'api_key' => '{Add API Key Here}',
                'm' => $meta
            );

$options = array(); // key=>value pairs can be added here to alter the curl call

$apiConsumer->setParams($params);

$apiConsumer->setOptions($options);

$apiConsumer->setResponseType('json');
$apiConsumer->setCallType('get');

$result = $apiConsumer->doApiCall();

```

Composer Usage
--------------

[](#composer-usage)

After either installing Composer using one of the two methods shown at  the composer.json would look like:

```
{
    "require": {
        "adamculp/api-consumer": "dev-master"
    }
}

```

Then you'll need to alter the require\_once in the sample above to point to the Composer autoload instead of to the class itself.

```
require_once 'vendor/autoload.php'; // to include the composer autoloader

```

From there you can use the $result array as you see fit.

Please use the /api-consumer/index.php as a working example (minus the API key) of how the class can be included and used.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance47

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community12

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

Unknown

Total

1

Last Release

4827d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/284451?v=4)[Adam Culp](/maintainers/adamculp)[@adamculp](https://github.com/adamculp)

---

Top Contributors

[![adamculp](https://avatars.githubusercontent.com/u/284451?v=4)](https://github.com/adamculp "adamculp (78 commits)")

---

Tags

api-consumercurlphprest-clientapiwrapperApi Wrappermashery api

### Embed Badge

![Health badge](/badges/adamculp-api-consumer/health.svg)

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

###  Alternatives

[wrapi/slack

Wrapper for Slack Web API

54277.5k2](/packages/wrapi-slack)[minicli/curly

Simple Curl Client

14262.8k5](/packages/minicli-curly)

PHPackages © 2026

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