Trustip
HomeFeaturesAboutPricing
  • Get Started
  • Code Examples
    • PHP
    • Laravel
    • Node js
    • JavaScript
  • API Rate Limits
Powered by GitBook
On this page
  • Installation
  • Usage
  • Exceptions
  • Security
  • Credits
  • License

Was this helpful?

  1. Code Examples

Laravel

You can call our API using our Laravel package.

PreviousPHPNextNode js

Last updated 1 year ago

Was this helpful?

Installation

You can install the package via composer:

composer require trustip/trustip
TRUSTIP_API_KEY=your_api_key

You can publish the config file with:

php artisan vendor:publish --provider="Trustip\Trustip\Providers\TrustipServiceProvider" 

Or create the config file config/trustip.php and add this code:

<?php

return [
    /*
     * The API key used to authenticate with the trustip API.
     *
     * You can get your API key from https://trustip.io
     */
    'api_key' => env('TRUSTIP_API_KEY'),
];

Usage

You can use it as a dependency injection in Route or Controller

use Trustip\Trustip\ProxyCheck;

Route::get('/check-ip', function (ProxyCheck $proxyCheck) {
    $ip = "8.8.8.8";
    try {
        $result = $proxyCheck->check($ip);
        return $result;
    } catch (\Exception $e) {
        return $e->getMessage();
    }
});

Or by using Trustip facade :

use Trustip;

$result = Trustip::check('8.8.8.8');

After that, you should get an output similar to this:

{
    "status":"success",
    "data": {
        "ip":"8.8.8.8",
        "is_proxy":true,
    }
}

If there's an error, the output will be similar to this:

{
    "status":"error",
    "message":"Invalid IP address"
}

You can also use the isIpProxy helper function in your controllers or other classes:

The isIpProxy will return false if the check method throws an exception or returns an error

if (isIpProxy('8.8.8.8')) {
    // IP is a proxy
} else {
    // IP is not a proxy
}

Exceptions

  • Trustip\Trustip\Exceptions\MissingApiKeyException is thrown if the api key is not found in the env file.

  • Trustip\Trustip\Exceptions\InvalidIpAddressException is thrown if the ip address passed to the check method is invalid

Security

Credits

License

You need to set TRUSTIP_API_KEY in your .env file before using the package. You can get the API key from

If the IP is proxy the is_proxy will be true if not it will be false you can read more at

Check all errors on .

If you discover any security related issues, please email instead of using the issue tracker.

The MIT License (MIT). Please see for more information.

Trustip.io
https://docs.trustip.io
https://docs.trustip.io
[email protected]
Trustip.io
All Contributors
License File
GitHub - trustip/trustip: A Laravel package from Trustip.io for VPN and Proxy detection, it allows you to check if an IP address is a Proxy, VPN, TOR, Hosting, Bad search engine robots.GitHub
Logo