Coder Social home page Coder Social logo

ipsquads / php Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 73 KB

IPSquads PHP library for IP Address Geolocation, Timezone, Currency & other information.

Home Page: https://ipsquads.com

License: Apache License 2.0

PHP 100.00%
ipgeolocation iplookup-php ipdatabase ipinfo

php's Introduction

PHP Library for IP Address Geolocation, Timezone, Currency & other information.

Latest Version on Packagist Tests Total Downloads

IPSquads PHP library for IP Address Geolocation, Timezone, Currency & other information.

How companies are using IP Squads API?

IPSquads is helping many companies & organizations for various use-cases:

  • Content Localization
  • Analytics
  • Fraud Prevention
  • Targeted online advertising
  • Geographic rights management

Getting Started

By default, requests are throttled at 20 requests per minute if access key is not passed. You can remove this throttle limit by getting a FREE access key through which you can make 1000 unthrottled requests per day.

If you are a non-profit organization, you may request to increase this limit. You can drop us a mail at [email protected].

If you would like to upgrade for more than 1000 requests per day, you may select the plan here: https://ipsquads.com/product/

Installation

In-order to get started,

You can install the package via composer:

composer require ipsquads/php

Usage

To get all the details of an IP Address.

use Ipsquads\Php\IPSquads;
$access_key = 'FREE';
$ip_squads = new IPSquads($access_key);
$ip_data = $ip_squads->getDetails('54.70.143.245');

JSON Representation

{
  "ip_address": "54.70.143.245",
  "ip_type": "IPv4",
  "country_name": "United States",
  "country_code": "US",
  "country_languages": "en-US,es-US,haw,fr",
  "continent_code": "NA",
  "continent_name": "North America",
  "city": "Boardman",
  "zip": "97818",
  "region_name": "Oregon",
  "region_code": "USOR",
  "latitude": 45.83986,
  "longitude": -119.70058,
  "asn": {
    "asn": 16509,
    "asn_org": "AMAZON-02"
  },
  "location": {
    "is_eu": false,
    "postal_regex": "^d{5}(-d{4})?$",
    "capital": "Washington",
    "calling_code": "1"
  },
  "timezone": {
    "code": "America/Los_Angeles",
    "dst_offset": -7,
    "gmt_offset": -8,
    "current_time": "2020-10-12T22:52:09.911223+05:30",
    "current_time_unix": "1602523329.911223"
  },
  "currency": {
    "name": "Dollar",
    "code": "USD"
  }
}

To get only the currency details

If you are interested in only currency details, you can use the below method.

use Ipsquads\Php\IPSquads;
$access_key = 'FREE';
$ip_squads = new IPSquads($access_key);
$ip_data = $ip_squads->getCurrencyDetails('54.70.143.245');

To get only the timezone details

If you are interested in only getting the timezone details of a visitor based on the IP Address, you can do that using the below method.

use Ipsquads\Php\IPSquads;
$access_key = 'FREE';
$ip_squads = new IPSquads($access_key);
$ip_data = $ip_squads->getTimezoneDetails('54.70.143.245');

To get only the network details

If you are only looking for the network details of an IP Address, you can do using the below method.

use Ipsquads\Php\IPSquads;
$access_key = 'FREE';
$ip_squads = new IPSquads($access_key);
$ip_data = $ip_squads->getNetworkDetails('54.70.143.245');

Caching

By default, any result returned from IPSquads server are cached for quick access & prevent you from using more credits unnecessarily.

Under the hood, this SDK uses symfony/cache library for caching.

The default TTL of cache is 3600 seconds. If you would like to increase or decrease this limit, you can do so by modifying the way IPSquads is getting initialized.

use Ipsquads\Php\IPSquads;
$access_key = 'FREE';
$settings = [
  'expires_after' => '1000'
];
$ip_squads = new IPSquads($access_key, $settings);

Cache adapter

As a default, FilesystemAdapter cache is used. If you would like to use any other adapter of symfony/cache library, you can do so by passing the instance of a Cache Adapter. To check the available cache adapters, click here.

use Ipsquads\Php\IPSquads;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
$access_key = 'FREE';
$settings = [
  'cache_adapter' => (new ApcuAdapter)
];
$ip_squads = new IPSquads($access_key, $settings);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The Apache License. Please see License File for more information.

php's People

Contributors

adrianmrn avatar freekmurze avatar irfanm96 avatar mvdnbrk avatar pforret avatar sdklab007 avatar weerd avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.