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

ActiveLibrary[API Development](/categories/api)

topthink/think-api
==================

v1.0.31(1y ago)2015.4k—8.3%2[1 issues](https://github.com/top-think/think-api/issues)1Apache-2.0PHP

Since Aug 14Pushed 1y agoCompare

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

READMEChangelog (10)Dependencies (3)Versions (33)Used By (1)

Think Api SDK For PHP
=====================

[](#think-api-sdk-for-php)

`ThinkAPI`
----------

[](#thinkapi)

`ThinkAPI`是`ThinkPHP`官方推出的统一`API`接口服务，提供接口调用服务及开发`SDK`，旨在帮助`ThinkPHP`开发者更方便的调用官方及第三方的提供的各类`API`接口及服务，从而更好的构建开发者生态，详细[参考这里](https://docs.topthink.com/think-api/)。

安装依赖
----

[](#安装依赖)

如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally) ，请直接在项目目录中运行以下内容来安装 Think Api SDK For PHP 作为依赖项：

```
composer require topthink/think-api

```

> 一些用户可能由于网络问题无法安装，可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer) 。

快速使用
----

[](#快速使用)

以查询身份证所属地区接口为例

```
use think\api\Client;

$client = new Client("YourAppCode");

$result = $client->idcardIndex()
    ->withCardno('身份证号码')
    ->request();

```

所有的接口服务和方法都支持IDE自动提示和完成（请务必注意方法大小写必须保持一致），基本上不需要文档即可完成接口开发工作，`ThinkAPI`所有的API调用服务必须设置`appCode`值，用于接口调用的身份认证。

> `AppCode`的值可以在[官方服务市场](https://market.topthink.com/)`->`我的服务`->`[安全信息](https://market.topthink.com/my/security)里面获取到，每个用户账号拥有一个唯一的`AppCode`值（请不要随意泄露）。

该SDK服务仅支持官方已经接入的API接口（所有支持的接口都在官方[API市场](https://market.topthink.com/api)），目前接口数量正在扩充中，你可以联系我们反馈你需要的API接口，我们来统一进行接入。

返回数据
----

[](#返回数据)

`ThinkAPI`所有的接口返回数据为`JSON`格式，通用规范如下：

名称类型说明codeint返回码,0 表示成功 其它表示失败messagestring返回提示信息dataobject返回数据> 如果为付费接口，则当`code`为0的时候计费，其中`data`包含的数据请参考具体的接口说明。

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 65.7% 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 ~44 days

Recently: every ~71 days

Total

32

Last Release

725d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7858077?v=4)[topthink](/maintainers/topthink)[@topthink](https://github.com/topthink)

---

Top Contributors

[![liu21st](https://avatars.githubusercontent.com/u/1111670?v=4)](https://github.com/liu21st "liu21st (44 commits)")[![yunwuxin](https://avatars.githubusercontent.com/u/2168125?v=4)](https://github.com/yunwuxin "yunwuxin (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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