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

ActiveLibrary[API Development](/categories/api)

lingxi/api-client
=================

lingxi common api client

v0.0.18(5y ago)48.8k↓100%3MITPHPPHP &gt;=5.6CI failing

Since May 25Pushed 5y ago4 watchersCompare

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

READMEChangelog (3)Dependencies (5)Versions (7)Used By (0)

api-client
==========

[](#api-client)

灵析 Api 通用 Client，基于 guzzlehttp/guzzle 实现

[![Build Status](https://camo.githubusercontent.com/08f1621b404e123464b91fbb165b86377921134070acef9f875a1831b247fb85/68747470733a2f2f7472617669732d63692e6f72672f6c696e6778692f6170692d636c69656e742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lingxi/api-client)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2594ce0243c7e6c3e8cf2c7d64b44a8c94dc89242e341774de65e09d8f520a7e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c696e6778692f6170692d636c69656e742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lingxi/api-client/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/47aa25e5f5b28182803b8670a3a54e5642a23a8021c3e0694ca467aab158137d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c696e6778692f6170692d636c69656e742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lingxi/api-client/?branch=master)[![Build Status](https://camo.githubusercontent.com/aed3698205d02bb9dd8c78b65c1e4000781fcac81f4222fd91b55549ee3a58c6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c696e6778692f6170692d636c69656e742f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lingxi/api-client/build-status/master)

### 安装

[](#安装)

composer.json 中添加

```
composer require lingxi/api-client
```

### Feature

[](#feature)

- 灵析 api 接口自动验证
- 支持接口参数自动替换。类似 Laravel 的路由参数替换。请求 uri 中 {user\_id} 会被 $query\['user\_id'\] 的值替换

### 用法

[](#用法)

#### 初始化

[](#初始化)

> 全部参数都可以使用 Setter 方法设置。即不需要再实例化的时候传递参数。

```
$apiOptions = [
    'base_uri'    => 'http://api.lingxi360.com',
    'api_key'     => 'api_key',
    'api_secret'  => 'api_secret',
];
$apiClient = new ApiClient($apiOptions);
```

##### option 允许的值

[](#option-允许的值)

选项说明默认值`base_uri``base_uri`Empty String`time_out`请求超时时间`5.0``api_key``api_key`Empty String`api_secret``api_secret`Empty String`api_version`Api 版本'v1'##### 链式操作

[](#链式操作)

```
$apiClient  = new ApiClient();
$apiClient->setBaseUri($apiOptions['base_uri'])
    ->setApiVersion($apiOptions['api_version'])
    ->setConsumer($apiOptions['api_key'], $apiOptions['api_secret'])
    ->setApiType($apiOptions['api_type'])
    ->setOutTime($apiOptions['time_out']);
```

#### 基本操作

[](#基本操作)

```
// 获取 http 请求对象，返回 GuzzleHttp\Psr7\Request 实例
$apiClient->get($uri, $query)->getRequest();
// 获取请求的数据
$apiClient->get($uri, $query)->getRequestData();
// 获取 Http 响应对象。返回 GuzzleHttp\Psr7\Response 的实例
$apiClient->get($uri, $query)->getResponse();
// post 操作
$apiClient->post($uri, $data)->getResponse();
// put 操作
$apiClient->put($uri, $data)->getResponse();
// delete 操作
$apiClient->delete($uri, $data)->getResponse();
// patch 操作
$apiClient->patch($uri, $data)->getResponse();
// 发起一个请求。$method 为 HTTP 请求动词
$apiClient->request($method, $uri, $data)->getResponse();
// 获取 api 返回的数据
$apiClient->get($uri, $query)->getResponseData();
// 获取 Http 响应码
$apiClient->get($uri, $query)->getResponseCode();
// 获取最后一次请求的 URL
$apiClient->getLastUrl();
// 获取请求传输时间
$apiClient->getTransferTime();
```

#### Getter

[](#getter)

```
$apiClient->getBaseUri();
$apiClient->getApiVersion();
$apiClient->getOutTime();
$apiClient->getApiKey();
$apiClient->getApiSecret();
```

#### Setter

[](#setter)

```
$apiClient->setBaseUri();
$apiClient->setBaseUri();
$apiClient->setApiVersion();
$apiClient->setOutTime();
```

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~280 days

Total

6

Last Release

2082d ago

### Community

Maintainers

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

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

---

Top Contributors

[![lingxi-iconfont](https://avatars.githubusercontent.com/u/29588939?v=4)](https://github.com/lingxi-iconfont "lingxi-iconfont (4 commits)")[![yekz](https://avatars.githubusercontent.com/u/3784533?v=4)](https://github.com/yekz "yekz (2 commits)")[![feymanlee](https://avatars.githubusercontent.com/u/14125552?v=4)](https://github.com/feymanlee "feymanlee (1 commits)")[![ljbink](https://avatars.githubusercontent.com/u/33534410?v=4)](https://github.com/ljbink "ljbink (1 commits)")[![sword-jin](https://avatars.githubusercontent.com/u/11711621?v=4)](https://github.com/sword-jin "sword-jin (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[alexacrm/dynamics-webapi-toolkit

Web API toolkit for Microsoft Dynamics 365 and Dynamics CRM

81324.1k1](/packages/alexacrm-dynamics-webapi-toolkit)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)[keboola/storage-api-client

Keboola Storage API PHP Client

10387.5k25](/packages/keboola-storage-api-client)

PHPackages © 2026

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