PHPackages                             ipgeolocation/ipgeolocation-php-sdk - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ipgeolocation/ipgeolocation-php-sdk

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ipgeolocation/ipgeolocation-php-sdk
===================================

Ipgeolocation provides a set of APIs to make ip based decisions.

v2.0.1(10mo ago)411.5k↓18.8%21[2 issues](https://github.com/IPGeolocation/ip-geolocation-api-php/issues)Apache-2.0PHPPHP ^8.1

Since Jul 3Pushed 3mo ago7 watchersCompare

[ Source](https://github.com/IPGeolocation/ip-geolocation-api-php)[ Packagist](https://packagist.org/packages/ipgeolocation/ipgeolocation-php-sdk)[ Docs](https://ipgeolocation.io)[ RSS](/packages/ipgeolocation-ipgeolocation-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (4)Used By (0)

IP Geolocation API PHP SDK
==========================

[](#ip-geolocation-api-php-sdk)

Overview
--------

[](#overview)

The official **PHP Client Library/SDK** for **[IPGeolocation.io](https://ipgeolocation.io)**'s set of APIs, provides a quick, developer friendly, way to access IP Location, threat intelligence, Timezone, Astronomy, ASN, Abuse Contact, and user-agent data. Lookup your own IP or provide any IPv4, IPv6 or domain name to get structured results in PHP, without the need for manual HTTP handling.

- [IP Location API](https://ipgeolocation.io/ip-location-api.html): Get all-in-one unified solution for **location** (city, locality, state, country, etc.), **currency**, **network** (AS number, ASN name, organization, asn type, date of allocation, company/ISP name, company type, company domain), **timezone** , **useragent** string parsing, **security** (threat score, is\_tor, is\_bot, proxy\_provider, cloud\_provider), and **abuse contact** (route/CIDR network, country, address, email, phone numbers) information.
- [IP Security API](https://ipgeolocation.io/ip-security-api.html): Get security, network, location, hostname, timezone and useragent parsing.
- [ASN API](https://ipgeolocation.io/asn-api.html): Get ASN details along with peers, upstreams, downstreams, routes, and raw WHOIS.
- [Abuse Contact API](https://ipgeolocation.io/ip-abuse-contact-api.html): Get abuse emails, phone numbers, kind, organization, route/CIDR network and country.
- [Astronomy API](https://ipgeolocation.io/astronomy-api.html): Get sunrise, sunset, moonrise, moonset, moon phases with precise twilight period times in combination with location information.
- [Timezone API](https://ipgeolocation.io/timezone-api.html): Get timezone name, multiple time formats, daylight saving status and its details along with location information.
- [Timezone Convert API](https://ipgeolocation.io/timezone-api.html): Convert time between timezone names, geo coordinates, location addresses, IATA codes, ICAO codes, or UN/LOCODE.
- [User Agent API](https://ipgeolocation.io/user-agent-api.html): Get browser, Operating System, and device info from single or multiple Useragent string parsing.

This library aims to empower developers to integrate threat intelligence, personalization, fraud prevention, compliance, and analytics features directly into PHP based applications. Whether you're enriching signup forms with ip geolocation data, localizing content, embedding threat intelligence in back-end systems, or converting time zones and currencies, the library ensures seamless, scalable integration with IPGeolocation.io's global API infrastructure.

Based on:

- API version: 2.0.0

**Official Release:**

- Available on [**Packagist**](https://packagist.org/packages/ipgeolocation/ipgeolocation-php-sdk)
- Source Code: [**GitHub Repository**](https://github.com/IPGeolocation/ip-geolocation-api-php)

Table of Contents
-----------------

[](#table-of-contents)

1. [Requirements](#requirements)
2. [Installation](#installation)
    - [Using Composer](#using-composer)
    - [Manual Installation](#manual-installation)
3. [API Documentation Links](#api-documentations)
4. [API Endpoints](#api-endpoints)
5. [Fields and Methods Availability](#fields-and-methods-availability)
6. [Authentication Setup](#authentication-setup)
    - [How to Get Your API Key](#how-to-get-your-api-key)
    - [ApiKeyAuth](#apikeyauth)
7. [IP Geolocation Examples](#ip-geolocation-examples)
    - [Developer (Free) Plan Examples](#developer-free-plan-examples)
    - [Standard Plan Examples](#standard-plan-examples)
    - [Advanced Plan Examples](#advanced-plan-examples)
    - [Bulk IP Geolocation Examples](#bulk-ip-geolocation-example)
8. [IP Security Examples](#ip-security-examples)
    - [Get Default Fields](#get-default-fields-2)
    - [Include Multiple Optional Fields](#include-multiple-optional-fields)
    - [Request with Field Filtering](#request-with-field-filtering)
    - [Bulk IP Security Lookup](#bulk-ip-security-lookup)
9. [ASN API Examples](#asn-api-examples)
    - [Get ASN Information by IP Address](#get-asn-information-by-ip-address)
    - [Get ASN Information by ASN Number](#get-asn-information-by-asn-number)
    - [Combine All objects using Include](#combine-all-objects-using-include)
10. [Abuse Contact API Examples](#abuse-contact-api-examples)
    - [Lookup Abuse Contact by IP](#lookup-abuse-contact-by-ip)
    - [Lookup Abuse Contact with Specific Fields](#lookup-abuse-contact-with-specific-fields)
    - [Lookup Abuse Contact while Excluding Fields](#lookup-abuse-contact-while-excluding-fields)
11. [Timezone API Examples](#timezone-api-examples)
    - [Get Timezone by IP Address](#get-timezone-by-ip-address)
    - [Get Timezone by Timezone Name](#get-timezone-by-timezone-name)
    - [Get Timezone from Any Address](#get-timezone-from-any-address)
    - [Get Timezone from Location Coordinates](#get-timezone-from-location-coordinates)
    - [Get Timezone and Airport Details from IATA Code](#get-timezone-and-airport-details-from-iata-code)
    - [Get Timezone and City Details from UN/LOCODE](#get-timezone-and-city-details-from-unlocode)
12. [Timezone Converter Examples](#timezone-converter-examples)
    - [Convert Current Time from One Timezone to Another](#convert-current-time-from-one-timezone-to-another)
13. [User Agent API Examples](#user-agent-api-examples)
    - [Parse a Basic User Agent String](#parse-a-basic-user-agent-string)
    - [Bulk User Agent Parsing Example](#bulk-user-agent-parsing-example)
14. [Astronomy API Examples](#astronomy-api-examples)
    - [Astronomy by Coordinates](#astronomy-by-coordinates)
    - [Astronomy by IP Address](#astronomy-by-ip-address)
    - [Astronomy by Location String](#astronomy-by-location-string)
    - [Astronomy for Specific Date](#astronomy-for-specific-date)
    - [Astronomy in Different Language](#astronomy-in-different-language)
15. [Models](#models)

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Composer
- Guzzle (installed automatically via Composer)

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

[](#installation)

### Using Composer

[](#using-composer)

It is recommended to install the SDK using Composer:

```
composer require ipgeolocation/ipgeolocation-php-sdk
```

If you want to include a local development version:

```
composer install
```

### Manual Installation

[](#manual-installation)

If you wish to manually include the SDK without Composer:

1. Clone this repository
2. Include the autoload.php from the vendor folder: ```
    require_once('/path/to/vendor/autoload.php');
    ```
3. Ensure dependencies in `vendor/` are installed via: ```
    composer install
    ```

API Documentations
------------------

[](#api-documentations)

The documentation below corresponds to the available APIs:

- [**Overview**](https://ipgeolocation.io/documentation.html)
- [**IP GeoLocation API**](https://ipgeolocation.io/documentation/ip-location-api.html)
- [**IP Security API**](https://ipgeolocation.io/documentation/ip-security-api.html)
- [**ASN API**](https://ipgeolocation.io/documentation/asn-api.html)
- [**IP Abuse Contact API**](https://ipgeolocation.io/documentation/ip-abuse-contact-api.html)
- [**Timezone API**](https://ipgeolocation.io/documentation/timezone-api.html)
- [**User-Agent API**](https://ipgeolocation.io/documentation/user-agent-api.html)
- [**Astronomy API**](https://ipgeolocation.io/documentation/astronomy-api.html)

For a detailed comparison of what each plan offers, visit the [Pricing Page](https://ipgeolocation.io/pricing.html).

API Endpoints
-------------

[](#api-endpoints)

All URIs are relative to **

ClassMethodHTTP requestDescription*IPGeolocationAPI*[**getIpGeolocation**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPGeolocationAPI.md#getipgeolocation)**GET** /ipgeoGet geolocation data for a single IP address*IPGeolocationAPI*[**getBulkIpGeolocation**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPGeolocationAPI.md#getbulkipgeolocation)**POST** /ipgeo-bulkGet geolocation data for multiple IP addresses in a single API request*IPSecurityAPI*[**getIpSecurityInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPSecurityAPI.md#getipsecurityinfo)**GET** /securityRetrieve security information (VPN, TOR, proxy, etc.) for a single IP*IPSecurityAPI*[**getBulkIpSecurityInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPSecurityAPI.md#getbulkipsecurityinfo)**POST** /security-bulkRetrieve security threat intelligence for multiple IPs*ASNLookupAPI*[**getAsnInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/ASNLookupAPI.md#getasninfo)**GET** /asnGet details of any ASN number or associated IP address*AbuseContactAPI*[**getAbuseContactInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/AbuseContactAPI.md#getabusecontactinfo)**GET** /abuseRetrieve abuse reporting contact information for a given IP address*AstronomyAPI*[**getAstronomyDetails**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/AstronomyAPI.md#getastronomydetails)**GET** /astronomyGet sunrise, sunset, moonrise, moonset, and related data for a location*TimezoneAPI*[**getTimezoneInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/TimezoneAPI.md#gettimezoneinfo)**GET** /timezoneTimezone information details*TimeConversionAPI*[**convertTimeBetweenTimezones**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/TimeConversionAPI.md#converttimebetweentimezones)**GET** /timezone/convertConvert time between two specified timezones*UserAgentAPI*[**getUserAgentDetails**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#getuseragentdetails)**GET** /user-agentGet details of user-agent*UserAgentAPI*[**parseUserAgentString**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#parseuseragentstring)**POST** /user-agentHandle single User-Agent string*UserAgentAPI*[**parseBulkUserAgentStrings**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#parsebulkuseragentstrings)**POST** /user-agent-bulkHandle multiple user-agent string lookupsFields and Methods Availability
-------------------------------

[](#fields-and-methods-availability)

IP Geolocation offers four plans from billing point of view: **Free, Standard, Security, Advance**. The availability of each method calling from the respective class, over all plans are presented below.

ClassMethodFreeStandardSecurityAdvance*IPGeolocationApi*[**getIpGeolocation**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPGeolocationAPI.md#get_ip_geolocation)✔✔✖✔*IPGeolocationApi*[**getBulkIpGeolocation**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPGeolocationAPI.md#get_bulk_ip_geolocation)✖✔✖✔*IPSecurityApi*[**getIpSecurityInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPSecurityAPI.md#get_ip_security_info)✖✖✔✖*IPSecurityApi*[**getBulkIpSecurityInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/IPSecurityAPI.md#get_bulk_ip_security_info)✖✖✔✖*ASNLookupApi*[**getAsnInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/ASNLookupAPI.md#get_asn_info)✖✖✖✔*AbuseContactApi*[**getAbuseContactInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/AbuseContactAPI.md#get_abuse_contact_info)✖✖✖✔*AstronomyApi*[**getAstronomyDetails**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/AstronomyAPI.md#get_astronomy_details)✔✔✔✔*TimezoneApi*[**getTimezoneInfo**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/TimezoneAPI.md#get_timezone_info)✔✔✔✔*TimeConversionApi*[**convertTimeBetweenTimezones**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/TimeConversionAPI.md#convert_time_between_timezones)✔✔✔✔*UserAgentApi*[**getUserAgentDetails**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#get_user_agent_details)✔✔✔✔*UserAgentApi*[**parseUserAgentString**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#parse_user_agent_string)✔✔✔✔*UserAgentApi*[**parseBulkUserAgentStrings**](https://github.com/IPGeolocation/ip-geolocation-api-php/blob/master/docs/Api/UserAgentAPI.md#parse_bulk_user_agent_strings)✖✔✔✔Tip

The availability of fields in every API endpoint across Free and Paid plans is provided in the ***Reference Table*** within each respective API Documentation. e.g., for IPGeolocationApi, please visit .

Authentication Setup
--------------------

[](#authentication-setup)

To authenticate API requests, you will need an API key from [ipgeolocation.io](https://ipgeolocation.io/).

### How to Get Your API Key

[](#how-to-get-your-api-key)

1. **Sign up** here:
2. **(optional)** Verify your email, if you signed up using email.
3. **Log in** to your account:
4. After logging in, navigate to your **Dashboard** to find your API key:

### ApiKeyAuth

[](#apikeyauth)

Once you've obtained the api key, configure your can configure it as follows:

```
