https://github.com/bigdatacloudapi/bigdatacloud-php
Official PHP SDK for BigDataCloud APIs — IP Geolocation, Reverse Geocoding, Phone & Email Verification, Network Engineering
https://github.com/bigdatacloudapi/bigdatacloud-php
api-client bigdatacloud composer geolocation ip-geolocation laravel packagist php reverse-geocoding sdk
Last synced: 8 days ago
JSON representation
Official PHP SDK for BigDataCloud APIs — IP Geolocation, Reverse Geocoding, Phone & Email Verification, Network Engineering
- Host: GitHub
- URL: https://github.com/bigdatacloudapi/bigdatacloud-php
- Owner: bigdatacloudapi
- License: mit
- Created: 2026-04-10T23:44:40.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-04-11T00:03:32.000Z (4 months ago)
- Last Synced: 2026-06-30T23:20:48.455Z (24 days ago)
- Topics: api-client, bigdatacloud, composer, geolocation, ip-geolocation, laravel, packagist, php, reverse-geocoding, sdk
- Language: PHP
- Size: 21.5 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# BigDataCloud PHP SDK
[](https://packagist.org/packages/bigdatacloudapi/bigdatacloud)
[](LICENSE)
[](https://www.php.net)
Official PHP SDK for [BigDataCloud](https://www.bigdatacloud.com) APIs. Strongly-typed client for IP Geolocation, Reverse Geocoding, Phone & Email Verification, and Network Engineering.
Zero external dependencies — requires only `ext-curl` and `ext-json`.
## Installation
```bash
composer require bigdatacloudapi/bigdatacloud
```
## API Key
Get a free API key at [bigdatacloud.com/login](https://www.bigdatacloud.com/login). No credit card required.
```bash
export BIGDATACLOUD_API_KEY=your-key-here
```
## Quick Start
```php
use BigDataCloud\BigDataCloudClient;
// Reads BIGDATACLOUD_API_KEY from environment
$client = BigDataCloudClient::fromEnvironment();
// Or pass the key directly
// $client = new BigDataCloudClient('your-key-here');
// IP Geolocation
$geo = $client->ipGeolocation->get('1.1.1.1');
echo "{$geo->location->city}, {$geo->country->name}\n";
// Reverse Geocoding
$place = $client->reverseGeocoding->reverseGeocode(-33.87, 151.21);
echo "{$place->city}, {$place->countryName}\n";
// Phone Validation — countryCode is required
$phone = $client->verification->validatePhone('+61412345678', 'AU');
echo "Valid: " . ($phone->isValid ? 'yes' : 'no') . ", Type: {$phone->lineType}\n";
// Email Verification
$email = $client->verification->verifyEmail('user@example.com');
echo "Valid: " . ($email->isValid ? 'yes' : 'no') . ", Disposable: " . ($email->isDisposable ? 'yes' : 'no') . "\n";
```
## Confidence Area
The `confidenceArea` field may encode multiple polygons. Use the helper:
```php
use BigDataCloud\ConfidenceAreaHelper;
$geo = $client->ipGeolocation->getWithConfidenceArea('1.1.1.1');
$polygons = ConfidenceAreaHelper::splitIntoPolygons($geo->confidenceArea);
foreach ($polygons as $i => $ring) {
echo "Ring " . ($i + 1) . ": " . count($ring) . " points\n";
}
```
## Available APIs
| Client | Methods |
|--------|---------|
| `$client->ipGeolocation` | `get`, `getWithConfidenceArea`, `getFull`, `getCountryByIp`, `getCountryInfo`, `getAllCountries`, `getHazardReport`, `getUserRisk`, `getAsnInfo`, `getNetworkByIp`, `getTimezoneByIanaId`, `getTimezoneByIp`, `parseUserAgent` |
| `$client->reverseGeocoding` | `reverseGeocode`, `reverseGeocodeWithTimezone`, `getTimezoneByLocation` |
| `$client->verification` | `validatePhone`, `validatePhoneByIp`, `verifyEmail` |
| `$client->networkEngineering` | `getAsnInfoFull`, `getReceivingFrom`, `getTransitTo`, `getBgpPrefixes`, `getNetworksByCidr`, `getAsnRankList`, `getTorExitNodes` |
## Phone Validation
Both methods require explicit country context — never uses server IP silently:
```php
// You know the country
$phone = $client->verification->validatePhone('+61412345678', 'AU');
// You know the end user's IP (pass their IP, not your server's)
$phone = $client->verification->validatePhoneByIp('0412345678', $userIp);
```
## Error Handling
```php
use BigDataCloud\BigDataCloudException;
try {
$geo = $client->ipGeolocation->get('1.1.1.1');
} catch (BigDataCloudException $e) {
echo "API error {$e->statusCode}: {$e->getMessage()}\n";
}
```
## Samples
```bash
export BIGDATACLOUD_API_KEY=your-key-here
php samples/ip_geolocation.php
php samples/reverse_geocoding.php
php samples/verification.php
php samples/network_engineering.php
```
## Requirements
- PHP 8.1+
- ext-curl
- ext-json
## License
MIT — see [LICENSE](LICENSE).