PHPackages                             reset-button/a-parser-api-php-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. reset-button/a-parser-api-php-client

ActiveLibrary[API Development](/categories/api)

reset-button/a-parser-api-php-client
====================================

PHP client for A-Parser API

1.0.0(1y ago)8324↑76.5%MITPHPPHP ^8.1

Since Dec 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ResetButton/a-parser-api-php-client)[ Packagist](https://packagist.org/packages/reset-button/a-parser-api-php-client)[ Docs](https://github.com/reset-button/a-parser-php-client)[ RSS](/packages/reset-button-a-parser-api-php-client/feed)WikiDiscussions master Synced 1mo ago

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

A-Aparser PHP API
=================

[](#a-aparser-php-api)

This A-parser PHP API library provides convenient access to the [A-Parser HTTP API](https://en.a-parser.com/docs/api/overview).

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

[](#requirements)

- php &gt;= 8.1
- guzzlehttp/guzzle &gt;= 7.0

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

[](#installation)

```
composer require reset-button/a-parser-api-php-client
```

Quickstart
----------

[](#quickstart)

```
//Define an a-parser instance
$aparser = new \ResetButton\AparserPhpClient\Aparser('http://full_url_to_api_endpoint','password');

//Define an action from https://en.a-parser.com/docs/api/methods
$taskConfAction = new \ResetButton\AparserPhpClient\Actions\GetTaskConfAction(1);

//Run the action and get the result
$result = $aparser->runAction($action);
```

Usage
-----

[](#usage)

### Basic Action Usage

[](#basic-action-usage)

Define an A-parser instance, passing full URL to API endpoint and password

```
//Define an a-parser instance
$aparser = new \ResetButton\AparserPhpClient\Aparser('full_url_to_api_endpoint','password');
```

Instantiate an action using the appropriate action class, as outlined in the official documentation

```
$taskConfAction = new \ResetButton\AparserPhpClient\Actions\GetTaskConfAction(1);
```

Run the action by calling `runAction` method

```
$result = $aparser->runAction($action);
```

### Using Parser class in Actions

[](#using-parser-class-in-actions)

All actions that accept parser name and config as parameter, accept a `Parser` instance instead (addTask, oneRequest, bulkRequest, getParserPreset, getParserInfo)

`Parser` class contains all logic, related to used parser in API methods, that used it

[![Parser class logic](./docs/parser.png)](./docs/parser.png)

In minimal approach you need only to create `Parser` instance without any configuration and pass it to corresponding method

```
$parser = new \ResetButton\AparserPhpClient\Parser('HTML::EmailExtractor','parser preset, if differs from default');
$action = new \ResetButton\AparserPhpClient\Actions\GetParserInfoAction($parser);
```

You can configure parser with options, overrides, etc before passing it to action by calling corresponding methods

```
$parser->addOption('parseLevel', '1', ["limit" => 0]);
$parser->addOverride('useproxy', false);
```

Or you can set full configuration at once using a corresponding method, this is useful when copy pasting from API request

[![drawing](./docs/setConfiguration.png)](./docs/setConfiguration.png)

```
$parser->setConfiguration([
    [
        "type" => "options",
        "id" => "parseLevel",
        "value" => 1,
        "additional" => [
          "limit" => "0"
        ]
    ],
    [
      "type" => "override",
      "id" => "useproxy",
      "value" => true
    ]
]);
```

> Note, that parser configuration has no effect in `getParserPreset` and `getParserInfo` actions.

### Configuring Actions

[](#configuring-actions)

All action required parameters are configured via constructor, and optional are set using builder pattern with corresponding parameters from the documentations with "set" prefix, for example

```
//Example 1
$action = new \ResetButton\AparserPhpClient\Actions\GetProxiesAction();
$action->setCheckers(['premium']); //set checkers parameter

//Example 2
$parser = new \ResetButton\AparserPhpClient\Parser('HTML::EmailExtractor','parser preset, if differs from default');
$action = new \ResetButton\AparserPhpClient\Actions\OneRequestAction($parser,'https://a-parser.com');
$action->setRawResults(true);
$action->setDoLog(false);
```

#### Configuring `addTask` action

[](#configuring-addtask-action)

This method is differs from others methods, it can be instantiated via passing at least one parser or passing a [previously saved preset](https://a-parser.com/docs/api/methods#starting-a-previously-saved-task), this two methods are implemented via named constructor

```
$parser = new \ResetButton\AparserPhpClient\Parser('HTML::EmailExtractor');
$actionViaParser = \ResetButton\AparserPhpClient\Actions\AddTaskAction::withParser($parser, ['query1']);
$actionViaPreset = \ResetButton\AparserPhpClient\Actions\AddTaskAction::withPreset('savedPreset', ['query1']);
```

Also, `addTask` action is a most complex action in API, so many setters for are not implemented and you should use `setDataValue` from Action Direct Methods to set parameters

```
$actionViaPreset = \ResetButton\AparserPhpClient\Actions\AddTaskAction::withPreset('savedPreset', ['query1']);
$actionViaPreset->setResultsUnique(); //Use setter
$actionViaPreset->setDataValue("saveFailedQueries", true); //Setter for this option is missing, using direct method
```

##### Setting queries source

[](#setting-queries-source)

You should pass queries when creating action, no matter the source. And then change queries source using `setQueriesFrom...` methods, default behavior is from **text**.

```
$fromText = \ResetButton\AparserPhpClient\Actions\AddTaskAction::withPreset('savedPreset', ['query1', 'query1']);

$fromFile = \ResetButton\AparserPhpClient\Actions\AddTaskAction::withPreset('savedPreset', ['filename1.txt', 'filename2.txt']);
$fromFile->setQueriesFromFiles();

//If you need change source again to text use
// $fromFile->setQueriesFromText();
```

#### Action Direct Methods

[](#action-direct-methods)

You can read any configuration option using `getDataValue` helper, if this option is not exists - null will returned

```
$taskConfAction = new \ResetButton\AparserPhpClient\Actions\GetTaskConfAction(1);
$taskConfAction->getDataValue("taskUid"); //will return 1
$taskConfAction->getDataValue("taskWrongUid"); //will return null
```

You can directly set/overwrite any configuration option using `setDataValue` helper. Use with caution.

```
$taskConfAction = new \ResetButton\AparserPhpClient\Actions\GetTaskConfAction(1);
$taskConfAction->setDataValue("taskUid", 10);
$taskConfAction->getDataValue("taskUid"); //will return 10
```

You can get all full configuration options using `getData` helper.

```
$parser = new \ResetButton\AparserPhpClient\Parser("SE::Google")
$parserPresetAction = new \ResetButton\AparserPhpClient\Actions\GetTaskConfAction($parser);
$taskConfAction->getData(); //will return ["parser" => "SE::Google", "preset": "default"]
```

### Aparser methods

[](#aparser-methods)

Instantiate A-parser instance by passing URL to API endpoint and password

```
$aparser = new \ResetButton\AparserPhpClient\Aparser('http://full_url_to_api_endpoint','password');
```

Prepare actions and run it by calling `runAction` method

```
$pingAction = new \ResetButton\AparserPhpClient\Actions\PingAction();
$getProxiesAction = new \ResetButton\AparserPhpClient\Actions\GetProxiesAction();
$resultPing = $aparser->runAction($pingAction);
$resultGetProxies = $aparser->runAction($getProxiesAction);
```

`runAction` will return `data` section from A-parser success response payload or throw a `AparserApiException` if A-parser responds with error

You can get JSON string from passed action using `getJsonString` helper.

```
$aparser->getJsonString($getPingAction); //will return something like {"password": "pass","action": "ping"}
```

At last, you can just copy JSON query from A-parser and send it via API directly even ignoring previously passed password

```
$jsonString = '{ "password": "pass", "action": "ping" }';
$aparser->runJsonString($jsonString);
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance40

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

2

Last Release

517d ago

### Community

Maintainers

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

---

Top Contributors

[![ResetButton](https://avatars.githubusercontent.com/u/18568959?v=4)](https://github.com/ResetButton "ResetButton (2 commits)")

---

Tags

phpapiclienta-parser

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/reset-button-a-parser-api-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/reset-button-a-parser-api-php-client/health.svg)](https://phpackages.com/packages/reset-button-a-parser-api-php-client)
```

###  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)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[picqer/sendcloud-php-client

A PHP Client for the SendCloud API

45400.4k1](/packages/picqer-sendcloud-php-client)[sima-land/api-php-client

Client library for Simaland APIs

311.5k](/packages/sima-land-api-php-client)

PHPackages © 2026

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