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

ActiveLibrary[API Development](/categories/api)

aftermarketpl/api
=================

Client for the AfterMarket.pl public API.

v0.6.2(7y ago)03.6k1Apache-2.0PHPPHP &gt;=5.6

Since Nov 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/aftermarketpl/aftermarketpl-api-php)[ Packagist](https://packagist.org/packages/aftermarketpl/api)[ RSS](/packages/aftermarketpl-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (15)Used By (0)

AfterMarket.pl API client class for PHP
=======================================

[](#aftermarketpl-api-client-class-for-php)

This library allows you to issue calls to the AfterMarket.pl public API from PHP.

Quick start
-----------

[](#quick-start)

Install the library using `composer`.

```
composer require aftermarketpl/api

```

Create the API client object, providing your API key. [Click here to obtain your API key.](https://www.aftermarket.pl/API/Create/)

```
$client = new Aftermarketpl\Api\Client(array(
    "key" => "... your public key ...",
    "secret" => "... your secret key ...",
));
```

Call an API function and obtain a result. [Click here to see the list of API functions.](https://json.aftermarket.pl/)

```
try {
    $result = $client->send("/domain/check", array(
        "names" => array("check-1.pl", "check-2.pl"),
    ));
    print_r($result);
}
catch(Aftermarketpl\Api\Exception\Exception $exception) {
    print_r($exception->getResponse());
}
```

Use Guzzle-style asynchronous call:

```
$promise = $client->sendAsync("/domain/check", array(
    "names" => array("check-1.pl", "check-2.pl"),
));
$promise->then(
    function($result) {
        print_r($result);
    },
    function($exception) {
        print_r($exception->$getResponse();
    }
);
$promise->wait();
```

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

[](#installation)

You can install the API library in two ways.

1. The easiest way is to use `composer`:

```
composer require aftermarketpl/api

```

2. If you are not using `composer`, you can install the library manually. In order to do that, download and unpack the files (only the `lib` directory is necessary), and include the library's autoloader in your PHP files:

```
require "... path to the lib folder.../autoload.php";
```

In the latter case, you don't need the Guzzle library if you don't plan on using asynchronous requests

- the library will switch to plain CURL in that case.

API keys
--------

[](#api-keys)

To connect to the API, you need an API key. [Click here to obtain your API key.](https://www.aftermarket.pl/API/Create/)

You can have more than one API key. Each API key has a set of operations which can be performed using that key. You can also limit the key usage to a specific set of IP addresses.

After creating an API key, you can modify its permissions, revoke or disable it on the Aftermarket.pl website.

Reference
---------

[](#reference)

### Creating the class

[](#creating-the-class)

To create a new client class, use:

```
$client = new Aftermarketpl\Api\Client($options);
```

The `$options` variable is an array, which can contain the following values:

- `key` - The public key used to connect to the API.
- `secret` - The secret key used to connect to the API.
- `debug` - If set to `true`, the CURL calls to the API will be performed with the CURL\_VERBOSE flag, allowing you to debug connection errors.
- `url` - Alternative URL to use when connecting to the API. You don't normally need to use this option.

The parameters `key` and `secret` are necessary for making calls to the API. However, you do not need to specify them at class creation time - see the section *Modifying the class* below.

### Making API calls

[](#making-api-calls)

```
$result = $client->send($command, $parameters);
```

The function `send()` is used to send an API command to the server. You need to specify two parameters:

- `$command` - The name of the command, for example `"/domain/check"`. [Click here to see the list of API functions.](https://json.aftermarket.pl/)
- `$parameters` - Array containing the command parameters. The actual contents depend on the command. Can be omitted of the command does not take any parameters.

The return value is the data structure returned by the API command. Its contents also depend on the actual command used - see the API reference for details on what is being returned by each command.

### Asynchronous calls

[](#asynchronous-calls)

```
$promise = $client->sendAsync($command, $parameters);
$promise->then(function($response) { ... }, function($exception) { ... });
$response = $promise->wait();
```

The function `sendAsync()` uses the Guzzle library to send an API call asynchronously. The input parameters are the same as with the `send()` function, but the returned value is a promise which resolves to the data structure returned from the API command.

Refer to Guzzle documentation for information on how to use promises with asynchronous calls.

### Exceptions

[](#exceptions)

If something goes wrong, a subclass of `Aftermarketpl\Api\Exception\Exception` is thrown. This class extends the standard `Exception` class with the method `getResponse()`, which returns the contents of the response received from the server. This value is, of course, only valid when the actual call to the server has been made; if the error occurred before that, the value is `null`.

### Modifying the class

[](#modifying-the-class)

You can modify the created client class in runtime, using the following functions:

```
$client->setAuth($key, $secret);`
$client->getAuthKey();
$client->getAuthSecret();
$client->setDebug($debug);
$client->getDebug();
$client->setUrl($url);
$client->getUrl();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Total

14

Last Release

2708d ago

### Community

Maintainers

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

---

Top Contributors

[![MichalPleban](https://avatars.githubusercontent.com/u/9946531?v=4)](https://github.com/MichalPleban "MichalPleban (14 commits)")

---

Tags

apiaftermarket

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[get-stream/stream-chat

A PHP client for Stream Chat (https://getstream.io/chat/)

301.8M2](/packages/get-stream-stream-chat)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)

PHPackages © 2026

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