PHPackages                             hejunjie/ip138 - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hejunjie/ip138

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hejunjie/ip138
==============

PHP 封装的 IP138 API SDK, 简化 IP、手机号归属地、天气查询信息接口以及二维码生成接口调用 | PHP SDK for IP138 API integration: IP lookup, mobile attribution, weather, QR code and more.

v1.0.1(1mo ago)6262[1 PRs](https://github.com/zxc7563598/php-ip138/pulls)MITPHPPHP &gt;=8.1

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/zxc7563598/php-ip138)[ Packagist](https://packagist.org/packages/hejunjie/ip138)[ RSS](/packages/hejunjie-ip138/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

hejunjie/ip138
==============

[](#hejunjieip138)

PHP SDK for [IP138](https://user.ip138.com/) — IP lookup, mobile attribution, weather queries, and QR code generation

[English](./README.md) ｜ [简体中文](./README.zh-CN.md)

---

While working on multiple projects, I frequently needed to call [IP138](https://user.ip138.com/) APIs. Since there was no official SDK, I had to write HTTP requests, assemble parameters, and handle responses from scratch every time — a lot of repetitive work.

So I wrapped all of IP138's currently available APIs into this PHP SDK. It makes integration much simpler in my own projects, and hopefully helps others with similar needs.

> This project has been parsed by [Zread](https://zread.ai/zxc7563598/php-ip138) — click to view a quick structural overview.

Features
--------

[](#features)

- Covers all IP138 open APIs: IP lookup, mobile attribution, weather queries, and QR code generation
- Supports both global token configuration and per-call token passing — convenient yet flexible
- Four API endpoints available: domestic/global, HTTP/HTTPS
- Response data matches the official IP138 API documentation exactly — no extra learning curve
- Requires PHP &gt;= 8.1

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

[](#installation)

```
composer require hejunjie/ip138
```

Quick Start
-----------

[](#quick-start)

Each IP138 API uses a separate token. Two configuration approaches are available:

### Option 1: Global Configuration (recommended for calling multiple APIs)

[](#option-1-global-configuration-recommended-for-calling-multiple-apis)

```
