PHPackages                             adeelnawaz/polr-api-client - 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. [API Development](/categories/api)
4. /
5. adeelnawaz/polr-api-client

ActiveLibrary[API Development](/categories/api)

adeelnawaz/polr-api-client
==========================

PHP Rest API client for Polr Project

1.0(5y ago)03.7k1[1 PRs](https://github.com/adeelnawaz/polr-api-client/pulls)1MITPHP

Since May 30Pushed 3y agoCompare

[ Source](https://github.com/adeelnawaz/polr-api-client)[ Packagist](https://packagist.org/packages/adeelnawaz/polr-api-client)[ RSS](/packages/adeelnawaz-polr-api-client/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (4)Used By (1)

Polr API Client
===============

[](#polr-api-client)

This package is a PHP client API library for open source project [Polr Project](https://docs.polrproject.org/en/latest/developer-guide/api/#api-endpoints). It supports all APIs from Polr v2.2.0. Pull requests and improvement suggestions are welcome.
Note: If you are working with Symfony, use [this](https://github.com/adeelnawaz/polr-api-bundle) instead.

Installation via composer
-------------------------

[](#installation-via-composer)

In your console, navigate to your project directory and execute the following command to download the latest stable version of this package:

```
$ composer require adeelnawaz/polr-api-client
```

Usage
-----

[](#usage)

*(see `examples/` directory for PHP example code for each API method)*

In order to use the API, instantiate an object of `PolrApi`. Upon instantiation of the object, the following have to be provided:

- the URL to the API
- the secret key of the user
- the quota of the user

After instantiating the API, create DTO object(s) (`DTO\Link`, etc) for the method you intend to use and call the method. This will result in calling the respective REST API endpoint and returning the relative `DTO\Response` object.
*(See Docblocks of the `PolrApi` methods for further information on input/output DTOs)*

In case of a failed API call, the `PolrApi` methods throw `ApiResponseException`. The exception has getters for `code`, `message`, and a machine readable short string `error_code` returned by the Polr REST API.

Example:

```
// Register composer spl autoload
$autoloader = require __DIR__ . '/../vendor/autoload.php';

// Instantiate PolrApi object
$api = new \Adeelnawaz\PolrApiClient\PolrApi(
    "POLR_API_URL",
    "POLR_API_KEY",
    "POLR_API_QUOTA"
);

// Prepare DTO for API method input
$link = new \Adeelnawaz\PolrApiClient\DTO\Link();
$link->setUrl('https://www.google.com/search?tbm=isch&source=hp&biw=1863&bih=916&ei=IksNW5eLHqzisAfvgKKQBg&q=samurai+jack&oq=samurai+jack&gs_l=img.3..0l10.799.2671.0.2891.13.10.0.3.3.0.54.372.9.9.0....0...1ac.1.64.img..1.12.380.0...0.NlHgI6Y6mmY')
    ->setIsSecret(true);

try {
    /**
     * @var \Adeelnawaz\PolrApiClient\DTO\Response\Link $responseLink
     */
    $responseLink = $api->shortenLink($link);

    print_r($responseLink);
} catch (\Adeelnawaz\PolrApiClient\Exception\ApiResponseException $e) {
    echo "Error: ({$e->getCode()} - {$e->getErrorCode()}) \"{$e->getMessage()}\"\n";
}

```

**Note**
The Quota is requests per second. Specify the right quota for the key/user otherwise you might run into API overuse, resulting in exceptions. Set `0` for unlimited

Response
--------

[](#response)

The response object for each method is either a DTO or array of DTOs from `\Adeelnawaz\PolrApiClient\DTO\Response` namespace. Please see API method docblocks for applicable response DTO for each method.

**Error Response**

In case of an error the API methods throw `Adeelnawaz\PolrApiClient\Exception\ApiResponseException`. The valuable information contained within the exception includes

- `getCode()` - returns the status code returned by Polr API. See [Polr documentation](https://docs.polrproject.org/en/latest/developer-guide/api/#error-responses) for possible codes
- `getMessage()` - returns the error message returned by Polr API
- `getErrorCode()` - returns the machine readable short error string such as *QUOTA\_EXCEEDED*

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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

Total

2

Last Release

1989d ago

Major Versions

0.1 → 1.02021-01-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/ace188249f74545d5de6d184e26b89d3490c39c466c266693abfc51803356bda?d=identicon)[adeelnawaz](/maintainers/adeelnawaz)

---

Top Contributors

[![adeelnawaz](https://avatars.githubusercontent.com/u/2161678?v=4)](https://github.com/adeelnawaz "adeelnawaz (6 commits)")

### Embed Badge

![Health badge](/badges/adeelnawaz-polr-api-client/health.svg)

```
[![Health](https://phpackages.com/badges/adeelnawaz-polr-api-client/health.svg)](https://phpackages.com/packages/adeelnawaz-polr-api-client)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M314](/packages/api-platform-core)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[api-platform/symfony

Symfony API Platform integration

354.0M110](/packages/api-platform-symfony)[api-platform/serializer

API Platform core Serializer

244.3M71](/packages/api-platform-serializer)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M120](/packages/web-auth-webauthn-lib)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

53675.5k15](/packages/solspace-craft-freeform)

PHPackages © 2026

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