PHPackages                             esi/numverify-api-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. [API Development](/categories/api)
4. /
5. esi/numverify-api-client-php

ActiveLibrary[API Development](/categories/api)

esi/numverify-api-client-php
============================

Numverify API Client for PHP

v3.0.1(2y ago)34.7k↑205.7%1[1 issues](https://github.com/ericsizemore/numverify-api-client-php/issues)[3 PRs](https://github.com/ericsizemore/numverify-api-client-php/pulls)MITPHPPHP ^8.2 &lt;8.5CI passing

Since Mar 11Pushed 3d agoCompare

[ Source](https://github.com/ericsizemore/numverify-api-client-php)[ Packagist](https://packagist.org/packages/esi/numverify-api-client-php)[ GitHub Sponsors](https://github.com/ericsizemore)[ Fund](https://ko-fi.com/ericsizemore)[ RSS](/packages/esi-numverify-api-client-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (10)Versions (11)Used By (0)

Numverify API Client Library for PHP
====================================

[](#numverify-api-client-library-for-php)

Numverify phone number validation and country API client library for PHP.

[![Build Status](https://camo.githubusercontent.com/3fab8f6b5a1a2e43d54c52da2ee7f0287c6d8b23edf9d39f114f168ee9929f05/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6e756d7665726966792d6170692d636c69656e742d7068702f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/numverify-api-client-php/build-status/master)[![Code Coverage](https://camo.githubusercontent.com/1a7970b80c4cadd23f6b693cfd77aa322cd76cb61df5484cfc4273a40be9d2f6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6e756d7665726966792d6170692d636c69656e742d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/numverify-api-client-php/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/34e5e5f47a037945b8a91f8afdf709a7c1abb884f48ce86e47d9b046c79f1b4d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6572696373697a656d6f72652f6e756d7665726966792d6170692d636c69656e742d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/ericsizemore/numverify-api-client-php/?branch=master)[![Continuous Integration](https://github.com/ericsizemore/numverify-api-client-php/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/ericsizemore/numverify-api-client-php/actions/workflows/continuous-integration.yml)[![Type Coverage](https://camo.githubusercontent.com/b0b4de26154ae860cad4394dbcc35c099d2ac8dc14490c43a21578a2c386d904/68747470733a2f2f73686570686572642e6465762f6769746875622f6572696373697a656d6f72652f6e756d7665726966792d6170692d636c69656e742d7068702f636f7665726167652e737667)](https://shepherd.dev/github/ericsizemore/numverify-api-client-php)[![Psalm Level](https://camo.githubusercontent.com/bb9df7b28bc6233605891bb9bb1d8ddd9e510c03c8b2718be0d19bb97ce471d9/68747470733a2f2f73686570686572642e6465762f6769746875622f6572696373697a656d6f72652f6e756d7665726966792d6170692d636c69656e742d7068702f6c6576656c2e737667)](https://shepherd.dev/github/ericsizemore/numverify-api-client-php)[![Latest Stable Version](https://camo.githubusercontent.com/b7edab0b7a6f2bbce10abd757d40c424aafe344356d8d5f77d185e8f6c415b30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6573692f6e756d7665726966792d6170692d636c69656e742d7068702e737667)](https://packagist.org/packages/esi/numverify-api-client-php)[![Downloads per Month](https://camo.githubusercontent.com/5ccd37404e9613dc81cb63713d97be9e80627b4e7485d26728f4d73a567bbb8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6573692f6e756d7665726966792d6170692d636c69656e742d7068702e737667)](https://packagist.org/packages/esi/numverify-api-client-php)[![License](https://camo.githubusercontent.com/87615fef58a337673d60d97582da3e7f81f3ea4f9e5f8530e210281c3731736b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6573692f6e756d7665726966792d6170692d636c69656e742d7068702e737667)](https://packagist.org/packages/esi/numverify-api-client-php)

This library is a fork of [`markrogoyski/numverify-api-client-php`](https://github.com/markrogoyski/numverify-api-client-php). See [Credits](#credits) for more information.

Features
--------

[](#features)

- Cache of client (Guzzle) calls. See [`Construct API to use a cache`](#construct-api-to-use-a-cache)
- Phone number validation API
    - Validate phone numbers
    - Carrier information
    - Line type
    - Location info: country, local information
    - Phone number formats
- Countries API
    - List of countries
    - Country names, country codes, dialing codes

Numverify API documentation:

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

[](#installation)

Compatible with PHP &gt;= 8.2 and can be installed with [Composer](https://getcomposer.org).

```
$ composer require esi/numverify-api-client-php
```

Usage
-----

[](#usage)

### Create New API

[](#create-new-api)

```
use Numverify\Api;

$accessKey = 'AccountAccessKeyGoesHere';
$api       = new Api($accessKey);
```

### Phone Number Validation API

[](#phone-number-validation-api)

```
$phoneNumber          = '14158586273';
$validatedPhoneNumber = $api->validatePhoneNumber($phoneNumber);

// Phone number information.
if ($validatedPhoneNumber->isValid()) {
    $number              = $validatedPhoneNumber->getNumber();              // 14158586273
    $localFormat         = $validatedPhoneNumber->getLocalFormat();         // 4158586273
    $internationalPrefix = $validatedPhoneNumber->getInternationalFormat(); // +14158586273
    $countryPrefix       = $validatedPhoneNumber->getCountryPrefix();       // +1
    $countryCode         = $validatedPhoneNumber->getCountryCode();         // US
    $countryName         = $validatedPhoneNumber->getCountryName();         // United States of America
    $location            = $validatedPhoneNumber->getLocation();            // Novato
    $carrier             = $validatedPhoneNumber->getCarrier();             // AT&T Mobility LLC
    $lineType            = $validatedPhoneNumber->getLineType();            // mobile
}

// Use optional country code parameter for local (non-E.164) phone numbers.
$phoneNumber = '4158586273';
$countryCode = 'US';
$validatedPhoneNumber = $api->validatePhoneNumber($phoneNumber, $countryCode);

// PHP Interfaces.
$stringRepresentation = (string) $validatedPhoneNumber;
$jsonRepresentation   = json_encode($validatedPhoneNumber);
```

### Countries API

[](#countries-api)

```
$countries = $api->getCountries();

// Find countries (by country code or by name).
$unitedStates = $countries->findByCountryCode('US');
$japan        = $countries->findByCountryName('Japan');

// Country information.
$usCountryCode = $unitedStates->getCountryCode(); // US
$usCountryName = $unitedStates->getCountryName(); // United States
$usDialingCode = $unitedStates->getDialingCode(); // +1

$japanCountryCode = $japan->getCountryCode();     // JP
$japanCountryName = $japan->getCountryName();     // Japan
$japanDialingCode = $japan->getDialingCode();     // +81

// Country collection is iterable.
foreach ($countries as $country) {
    $countryCode = $country->getCountryCode();
    $countryName = $country->getCountryName();
    $dialingCode = $country->getDialingCode();
}

// Country collection PHP interfaces.
$numberOfCountries  = count($countries);
$jsonRepresentation = json_encode($numberOfCountries);

// Country PHP interfaces.
$stringRepresentation = (string) $unitedStates;   // US: United States (+1)
$jsonRepresentation   = json_encode($unitedStates);
```

### Options

[](#options)

#### Signature of the Api Constructor

[](#signature-of-the-api-constructor)

```
    /**
     * Api constructor.
     *
     * Requires an access key. You can get one from Numverify.
     *
     * @see https://numverify.com/product
     *
     * Note: If you are on their free plan, $useHttps = true will not work for you.
     *
     * @param string               $accessKey API access key.
     * @param bool                 $useHttps  (optional) Flag to determine if API calls should use http or https.
     * @param null|ClientInterface $client    (optional) Parameter to provide your own Guzzle client.
     * @param array $options   (optional) Array of options to pass to the Guzzle client.
     */
    public function __construct(
        #[SensitiveParameter]
        private readonly string $accessKey,
        bool $useHttps = false,
        ?ClientInterface $client = null,
        array $options = []
    );
```

#### Construct API to use HTTPS for API Calls

[](#construct-api-to-use-https-for-api-calls)

Note: The Numverify api has different plan options when signing up for an access key. The 'free' plan cannot use the secure (HTTPS) url for the API.

```
use Numverify\Api;

$useHttps = true;
$api      = new Api($accessKey, $useHttps);  // Optional second parameter
```

#### Construct API to use a Custom Guzzle Client or Options

[](#construct-api-to-use-a-custom-guzzle-client-or-options)

Note: If creating and passing your own client to `Api`, it will completely ignore `$useHttps`.

```
use GuzzleHttp\Client;
use Numverify\Api;

$client = new Client([
    'base_uri' => 'http://apilayer.net/api',
    'timeout' => 10
]);

$api = new Api($accessKey, false, $client);
```

If you simply want to change some of Guzzle's default options, pass them along to the optional $options parameter instead.

```
use Numverify\Api;

$api = new Api($accessKey, false, null, ['timeout' => 10]);

// or
$api = new Api($accessKey, false, options: ['timeout' => 10]);
```

#### Construct API to use a Cache

[](#construct-api-to-use-a-cache)

The Api constructor allows you to pass an optional `$options` parameter, typically used to pass Guzzle options on to the client.

If you specify `cachePath` within `$options`, and it is a valid directory, the constructor will add the cache handler to Guzzle's handler stack.

```
use Numverify\Api;

$api = new Api($accessKey, false, options: ['cachePath' => '/tmp']);
```

### Exceptions

[](#exceptions)

API failures throw a `NumverifyApiFailureException`

```
// Numverify API server error.
try {
    $validatedPhoneNumber = $api->validatePhoneNumber($phoneNumber);
} catch (\Numverify\Exception\NumverifyApiFailureException $e) {
    $statusCode = $e->getStatusCode(); // 500
    $message    = $e->getMessage();    // Unknown error - 500 Internal Server Error
}

// Numverify API failure response
try {
    $validatedPhoneNumber = $api->validatePhoneNumber($phoneNumber);
} catch (\Numverify\Exception\NumverifyApiFailureException $e) {
    $statusCode = $e->getStatusCode(); // 200
    $message    = $e->getMessage();    // Type:invalid_access_key Code:101 Info:You have not supplied a valid API Access Key.
}
```

About
-----

[](#about)

### Requirements

[](#requirements)

- PHP 8.2.0 or above.

### Credits

[](#credits)

- Author: [Eric Sizemore](https://github.com/ericsizemore)
- Thanks to [all Contributors](https://github.com/ericsizemore/numverify-api-client-php/contributors).

`numverify-api-client-php` is forked from [`markrogoyski/numverify-api-client-php`](https://github.com/markrogoyski/numverify-api-client-php) by [`Mark Rogoyski`](https://github.com/markrogoyski).

My thanks to them, and all their contributors. To view changes in this library in comparison to the original library, please see the [CHANGELOG.md](./CHANGELOG.md) file.

Contributing
------------

[](#contributing)

See [CONTRIBUTING](./CONTRIBUTING.md) for more information.

Bugs and feature requests are tracked on [GitHub](https://github.com/ericsizemore/numverify-api-client-php/issues).

### Contributor Covenant Code of Conduct

[](#contributor-covenant-code-of-conduct)

See [CODE\_OF\_CONDUCT.md](./CODE_OF_CONDUCT.md)

### Backward Compatibility Promise

[](#backward-compatibility-promise)

See [backward-compatibility.md](./backward-compatibility.md) for more information on Backwards Compatibility.

### Changelog

[](#changelog)

See the [CHANGELOG](./CHANGELOG.md) for more information on what has changed recently.

### License

[](#license)

See the [LICENSE](./LICENSE.md) for more information on the license that applies to this project.

### Security

[](#security)

See [SECURITY](./SECURITY.md) for more information on the security disclosure process.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance58

Moderate activity, may be stable

Popularity28

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

2

Last Release

841d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/723810?v=4)[Eric Sizemore](/maintainers/ericsizemore)[@ericsizemore](https://github.com/ericsizemore)

---

Top Contributors

[![ericsizemore](https://avatars.githubusercontent.com/u/723810?v=4)](https://github.com/ericsizemore "ericsizemore (332 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (290 commits)")[![markrogoyski](https://avatars.githubusercontent.com/u/10004372?v=4)](https://github.com/markrogoyski "markrogoyski (44 commits)")[![editionslva](https://avatars.githubusercontent.com/u/26386519?v=4)](https://github.com/editionslva "editionslva (1 commits)")[![tenshiAMD](https://avatars.githubusercontent.com/u/13580338?v=4)](https://github.com/tenshiAMD "tenshiAMD (1 commits)")

---

Tags

apicarrier-lookupclientcountry-codesdialing-codesnumverifyphone-numbervalidate-phone-numberapiclientphone-numbercountry codesnumverifycarrier lookupvalidate phone numberdialing codes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/esi-numverify-api-client-php/health.svg)

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

###  Alternatives

[markrogoyski/numverify-api-client-php

Numverify API Client for PHP

1221.5k](/packages/markrogoyski-numverify-api-client-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k9.5M89](/packages/openai-php-laravel)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[resend/resend-php

Resend PHP library.

617.2M43](/packages/resend-resend-php)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

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