PHPackages                             megaads/apify-client-php - 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. megaads/apify-client-php

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

megaads/apify-client-php
========================

Apify client for PHP

1.0.15(5mo ago)21.6k↑100%MITPHPPHP &gt;=5.6.4

Since Aug 5Pushed 5mo agoCompare

[ Source](https://github.com/megaads-vn/apify-client-php)[ Packagist](https://packagist.org/packages/megaads/apify-client-php)[ Docs](https://www.megaads.vn)[ RSS](/packages/megaads-apify-client-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (17)Used By (0)

Apify Client for PHP
====================

[](#apify-client-for-php)

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

[](#installation)

### System requirements

[](#system-requirements)

- PHP: &gt;= 5.6
- Laravel/ Lumen Framework: 4.\* or newer

### Require the composer package

[](#require-the-composer-package)

```
`composer require megaads/apify-client-php`

```

Create query builder
--------------------

[](#create-query-builder)

```
use Megaads\ApifyClient\Client;

$query = Client::endpoint("product", [
    Client::OPTION_API_HOST => "https://api.domain.com",
    Client::OPTION_API_AUTH => "token=dsfqwe123sdf2342c",
    Client::OPTION_REQUEST_HEADER => ["Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l"]
]);
```

Add custom field
----------------

[](#add-custom-field)

Add a custom parameter to request URL

```
$query->addField("customer_id", 123);

$query->addField("version", "1.0.0");
```

Get request URL
---------------

[](#get-request-url)

The simplest method to see the generated request URL

```
$query->toURL();
```

Pagination
----------

[](#pagination)

ParameterRequiredDefaultDescriptionpage\_idNo0Page index, start at 0page\_sizeNo50Number of rows to retrieve per page```
$query->pageId(0);

$query->pageSize(100);
```

Sorting
-------

[](#sorting)

### Sort ascending

[](#sort-ascending)

```
$query->sort("user_id");
```

### Sort descending

[](#sort-descending)

```
$query->sort("-created_at");
```

### Sort by multiple columns

[](#sort-by-multiple-columns)

```
$query->sort(["user_id", "-created_at"]);
```

### Selection

[](#selection)

Select columns from the records. SQL aggregate functions such as `COUNT`, `MAX`, `MIN`, `SUM`, `AVG`, SQL aliases are also available

```
$query->select("id");

$query->select(["content", "user_id", "sum(view_count) as view_sum"]);
```

### Group By

[](#group-by)

Group the result-set by one or more columns and combine with aggregate functions using `Selection`

```
$query->select(["user_id", "sum(view_count) as view_sum"]);

$query->group("user_id");
```

### Filtering

[](#filtering)

OperatorConditionFor exampleClient::SELECTION\_EQUALEqual to`$query->filter("user_id", Client::SELECTION_EQUAL, 1);`Client::SELECTION\_NOT\_EQUALNot equal`$query->filter("user_id", Client::SELECTION_NOT_EQUAL, 1);`Client::SELECTION\_GREATERGreater`$query->filter("user_id", Client::SELECTION_GREATER, 1);`Client::SELECTION\_GREATER\_EQUALGreater or equal`$query->filter("user_id", Client::SELECTION_GREATER_EQUAL, 1);`Client::SELECTION\_LESSLess`$query->filter("user_id", Client::SELECTION_LESS, 1);`Client::SELECTION\_LESS\_EQUALLess or equal`$query->filter("user_id", Client::SELECTION_LESS_EQUAL, 1);`Client::SELECTION\_INIn`$query->filter("user_id", Client::SELECTION_IN, [1,2,3]);`Client::SELECTION\_NOT\_INNot in`$query->filter("user_id", Client::SELECTION_NOT_IN, [1,2,3]);`Client::SELECTION\_BETWEENBetween`$query->filter("user_id", Client::SELECTION_BETWEEN, [1,20]);`Client::SELECTION\_NOT\_BETWEENNot between`$query->filter("user_id", Client::SELECTION_NOT_BETWEEN, [1,20]);`Client::SELECTION\_LIKELike`$query->filter("title", Client::SELECTION_LIKE, "hello");`Client::SELECTION\_NOT\_LIKENot like`$query->filter("title", Client::SELECTION_NOT_LIKE, "hello");`Relationships
-------------

[](#relationships)

Apify provides the ability to embed relational data into the results

For example

```
$query->embed("cities");

$query->embed(["nation", "districts"]);
```

### Filtering on relationships

[](#filtering-on-relationships)

```
$query->filter("nation.location_code", Client::SELECTION_EQUAL, "EU");

$query->filter("districts.name", Client::SELECTION_LIKE, land);
```

Retrieve data
-------------

[](#retrieve-data)

### Find: Retrieve single record

[](#find-retrieve-single-record)

```
$query->find(1);
```

### Get: Retrieve all records that match the query

[](#get-retrieve-all-records-that-match-the-query)

```
$query->get();
```

Response format

```
[
    "meta" => [
        "has_next" => true,
        "total_count" => 100,
        "page_count" => 2,
        "page_size" => 50,
        "page_id" => 0
    ],
    "result" => [],
    "status" => "successful"
]
```

### First: Retrieve the first record that matchs the query

[](#first-retrieve-the-first-record-that-matchs-the-query)

```
$query->first();

```

Response format

```
[
    "result" => [],
    "status" => "successful"
]
```

### Count: Retrieve the number of records that match the query

[](#count-retrieve-the-number-of-records-that-match-the-query)

```
$query->count();

```

Response format

```
[
    "result" => 50,
    "status" => "successful"
]
```

### Increment/ Decrement: Provides convenient methods for incrementing or decrementing the value of a selected column

[](#increment-decrement-provides-convenient-methods-for-incrementing-or-decrementing-the-value-of-a-selected-column)

```
$query->select("view_count");

$query->increment();

```

Response format

```
[
    "result" => 1,
    "status" => "successful"
]
```

Send custom request
-------------------

[](#send-custom-request)

```
use Megaads\ApifyClient\Client;

$query = Client::request("https://api.domain.com/product",
Client::METHOD_POST,
[
    "name" => "Hello",
    "code" => "C0001"
],
[
    "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l"
]);
```

License
-------

[](#license)

The Apify is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

Contact us/ Instant feedback
----------------------------

[](#contact-us-instant-feedback)

Email:

Skype: phult.bk

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% 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 ~155 days

Recently: every ~571 days

Total

16

Last Release

153d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72ad425c743522a807fd15e2a7b0ada9c2a2127ecca76fbef37cf9292022006a?d=identicon)[megaads-vn](/maintainers/megaads-vn)

---

Top Contributors

[![phult](https://avatars.githubusercontent.com/u/4711640?v=4)](https://github.com/phult "phult (14 commits)")[![quanbka](https://avatars.githubusercontent.com/u/13042109?v=4)](https://github.com/quanbka "quanbka (3 commits)")[![lapdx](https://avatars.githubusercontent.com/u/5915409?v=4)](https://github.com/lapdx "lapdx (1 commits)")

---

Tags

apilaravelrestlumenwebserviceMicroserviceapi-generator

### Embed Badge

![Health badge](/badges/megaads-apify-client-php/health.svg)

```
[![Health](https://phpackages.com/badges/megaads-apify-client-php/health.svg)](https://phpackages.com/packages/megaads-apify-client-php)
```

###  Alternatives

[megaads/apify

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

151.7k](/packages/megaads-apify)[wn/lumen-generators

A collection of generators for Lumen and Laravel 5.

350205.3k2](/packages/wn-lumen-generators)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[noitran/opendox

OpenApi(Swagger) 3.0 package for Lumen 5.5+ and Laravel 5.5+ with REDOC UI and SwaggerUI 3

2313.9k](/packages/noitran-opendox)[rap2hpoutre/jacky

Opinionated REST JSON HTTP API client for laravel

174.4k](/packages/rap2hpoutre-jacky)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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