ipgeolocation_sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +2124 -0
- data/Rakefile +10 -0
- data/docs/ASNConnection.md +22 -0
- data/docs/ASNDetails.md +48 -0
- data/docs/ASNLookupApi.md +89 -0
- data/docs/ASNResponse.md +20 -0
- data/docs/ASNResponseXML.md +20 -0
- data/docs/ASNResponseXMLAsn.md +48 -0
- data/docs/Abuse.md +40 -0
- data/docs/AbuseContactApi.md +85 -0
- data/docs/AbuseResponse.md +20 -0
- data/docs/AbuseResponseXML.md +20 -0
- data/docs/Astronomy.md +68 -0
- data/docs/AstronomyApi.md +97 -0
- data/docs/AstronomyEvening.md +36 -0
- data/docs/AstronomyLocation.md +50 -0
- data/docs/AstronomyMorning.md +36 -0
- data/docs/AstronomyResponse.md +22 -0
- data/docs/AstronomyXMLResponse.md +22 -0
- data/docs/BulkIPGeolocation.md +42 -0
- data/docs/BulkIPSecurity.md +42 -0
- data/docs/CountryMetadata.md +22 -0
- data/docs/Currency.md +22 -0
- data/docs/ErrorResponse.md +18 -0
- data/docs/ErrorXMLResponse.md +18 -0
- data/docs/ErrorXMLResponseArray.md +18 -0
- data/docs/GeolocationResponse.md +38 -0
- data/docs/GeolocationXMLResponse.md +38 -0
- data/docs/GeolocationXMLResponseArray.md +38 -0
- data/docs/GetBulkIpGeolocation200ResponseInner1.md +49 -0
- data/docs/GetBulkIpGeolocationRequest.md +18 -0
- data/docs/GetBulkIpSecurityInfo200ResponseInner1.md +49 -0
- data/docs/IPLocationApi.md +175 -0
- data/docs/Location.md +58 -0
- data/docs/LocationMinimal.md +52 -0
- data/docs/Network.md +22 -0
- data/docs/NetworkAsn.md +38 -0
- data/docs/NetworkCompany.md +22 -0
- data/docs/NetworkMinimal.md +20 -0
- data/docs/NetworkMinimalAsn.md +22 -0
- data/docs/NetworkMinimalCompany.md +18 -0
- data/docs/ParseBulkUserAgentStringsRequest.md +18 -0
- data/docs/ParseUserAgentStringRequest.md +18 -0
- data/docs/Security.md +38 -0
- data/docs/SecurityAPIResponse.md +34 -0
- data/docs/SecurityAPIXMLResponse.md +34 -0
- data/docs/SecurityAPIXMLResponseArray.md +34 -0
- data/docs/SecurityApi.md +175 -0
- data/docs/TimeConversionApi.md +109 -0
- data/docs/TimeConversionResponse.md +24 -0
- data/docs/TimeConversionXMLResponse.md +24 -0
- data/docs/TimeZone.md +36 -0
- data/docs/TimeZoneDetailedResponse.md +26 -0
- data/docs/TimeZoneDetailedXMLResponse.md +26 -0
- data/docs/TimeZoneDstEnd.md +28 -0
- data/docs/TimeZoneDstStart.md +28 -0
- data/docs/TimezoneAirport.md +40 -0
- data/docs/TimezoneApi.md +99 -0
- data/docs/TimezoneDetail.md +56 -0
- data/docs/TimezoneDetailDstEnd.md +28 -0
- data/docs/TimezoneDetailDstStart.md +28 -0
- data/docs/TimezoneLocation.md +48 -0
- data/docs/TimezoneLocode.md +32 -0
- data/docs/UserAgentApi.md +235 -0
- data/docs/UserAgentData.md +32 -0
- data/docs/UserAgentDataDevice.md +24 -0
- data/docs/UserAgentDataEngine.md +24 -0
- data/docs/UserAgentDataOperatingSystem.md +26 -0
- data/docs/UserAgentXMLData.md +32 -0
- data/docs/UserAgentXMLDataArray.md +32 -0
- data/git_push.sh +57 -0
- data/ipgeolocation_sdk.gemspec +29 -0
- data/lib/ipgeolocation_sdk/api/abuse_contact_api.rb +86 -0
- data/lib/ipgeolocation_sdk/api/asn_lookup_api.rb +92 -0
- data/lib/ipgeolocation_sdk/api/astronomy_api.rb +116 -0
- data/lib/ipgeolocation_sdk/api/ip_geolocation_api.rb +186 -0
- data/lib/ipgeolocation_sdk/api/ip_security_api.rb +184 -0
- data/lib/ipgeolocation_sdk/api/time_conversion_api.rb +122 -0
- data/lib/ipgeolocation_sdk/api/timezone_api.rb +113 -0
- data/lib/ipgeolocation_sdk/api/user_agent_api.rb +158 -0
- data/lib/ipgeolocation_sdk/api_client.rb +393 -0
- data/lib/ipgeolocation_sdk/api_error.rb +58 -0
- data/lib/ipgeolocation_sdk/configuration.rb +308 -0
- data/lib/ipgeolocation_sdk/models/abuse.rb +305 -0
- data/lib/ipgeolocation_sdk/models/abuse_response.rb +229 -0
- data/lib/ipgeolocation_sdk/models/abuse_response_xml.rb +229 -0
- data/lib/ipgeolocation_sdk/models/asn_connection.rb +238 -0
- data/lib/ipgeolocation_sdk/models/asn_response.rb +230 -0
- data/lib/ipgeolocation_sdk/models/asn_response_asn.rb +368 -0
- data/lib/ipgeolocation_sdk/models/asn_response_xml.rb +229 -0
- data/lib/ipgeolocation_sdk/models/asn_response_xml_asn.rb +364 -0
- data/lib/ipgeolocation_sdk/models/astronomy.rb +445 -0
- data/lib/ipgeolocation_sdk/models/astronomy_evening.rb +301 -0
- data/lib/ipgeolocation_sdk/models/astronomy_location.rb +364 -0
- data/lib/ipgeolocation_sdk/models/astronomy_morning.rb +301 -0
- data/lib/ipgeolocation_sdk/models/astronomy_response.rb +238 -0
- data/lib/ipgeolocation_sdk/models/astronomy_xml_response.rb +238 -0
- data/lib/ipgeolocation_sdk/models/bulk_ip_geolocation.rb +113 -0
- data/lib/ipgeolocation_sdk/models/bulk_ip_security.rb +113 -0
- data/lib/ipgeolocation_sdk/models/country_metadata.rb +240 -0
- data/lib/ipgeolocation_sdk/models/currency.rb +238 -0
- data/lib/ipgeolocation_sdk/models/error_response.rb +220 -0
- data/lib/ipgeolocation_sdk/models/error_xml_response.rb +220 -0
- data/lib/ipgeolocation_sdk/models/error_xml_response_array.rb +220 -0
- data/lib/ipgeolocation_sdk/models/geolocation_response.rb +310 -0
- data/lib/ipgeolocation_sdk/models/geolocation_xml_response.rb +310 -0
- data/lib/ipgeolocation_sdk/models/geolocation_xml_response_array.rb +310 -0
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_geolocation200_response_inner1.rb +105 -0
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_geolocation_request.rb +241 -0
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_security_info200_response_inner1.rb +105 -0
- data/lib/ipgeolocation_sdk/models/location.rb +400 -0
- data/lib/ipgeolocation_sdk/models/location_minimal.rb +373 -0
- data/lib/ipgeolocation_sdk/models/network.rb +238 -0
- data/lib/ipgeolocation_sdk/models/network_asn.rb +310 -0
- data/lib/ipgeolocation_sdk/models/network_company.rb +238 -0
- data/lib/ipgeolocation_sdk/models/network_minimal.rb +229 -0
- data/lib/ipgeolocation_sdk/models/network_minimal_asn.rb +238 -0
- data/lib/ipgeolocation_sdk/models/network_minimal_company.rb +220 -0
- data/lib/ipgeolocation_sdk/models/parse_bulk_user_agent_strings_request.rb +222 -0
- data/lib/ipgeolocation_sdk/models/parse_user_agent_string_request.rb +220 -0
- data/lib/ipgeolocation_sdk/models/security.rb +310 -0
- data/lib/ipgeolocation_sdk/models/security_api_response.rb +292 -0
- data/lib/ipgeolocation_sdk/models/security_apixml_response.rb +292 -0
- data/lib/ipgeolocation_sdk/models/security_apixml_response_array.rb +292 -0
- data/lib/ipgeolocation_sdk/models/time_conversion_response.rb +247 -0
- data/lib/ipgeolocation_sdk/models/time_conversion_xml_response.rb +247 -0
- data/lib/ipgeolocation_sdk/models/time_zone.rb +301 -0
- data/lib/ipgeolocation_sdk/models/time_zone_detailed_response.rb +256 -0
- data/lib/ipgeolocation_sdk/models/time_zone_detailed_xml_response.rb +256 -0
- data/lib/ipgeolocation_sdk/models/time_zone_dst_end.rb +265 -0
- data/lib/ipgeolocation_sdk/models/time_zone_dst_start.rb +265 -0
- data/lib/ipgeolocation_sdk/models/timezone_airport.rb +319 -0
- data/lib/ipgeolocation_sdk/models/timezone_detail.rb +391 -0
- data/lib/ipgeolocation_sdk/models/timezone_detail_dst_end.rb +265 -0
- data/lib/ipgeolocation_sdk/models/timezone_detail_dst_start.rb +265 -0
- data/lib/ipgeolocation_sdk/models/timezone_location.rb +355 -0
- data/lib/ipgeolocation_sdk/models/timezone_locode.rb +283 -0
- data/lib/ipgeolocation_sdk/models/user_agent_data.rb +283 -0
- data/lib/ipgeolocation_sdk/models/user_agent_data_device.rb +247 -0
- data/lib/ipgeolocation_sdk/models/user_agent_data_engine.rb +247 -0
- data/lib/ipgeolocation_sdk/models/user_agent_data_operating_system.rb +256 -0
- data/lib/ipgeolocation_sdk/models/user_agent_xml_data.rb +283 -0
- data/lib/ipgeolocation_sdk/models/user_agent_xml_data_array.rb +283 -0
- data/lib/ipgeolocation_sdk/version.rb +15 -0
- data/lib/ipgeolocation_sdk.rb +107 -0
- data/spec/api/abuse_contact_api_spec.rb +48 -0
- data/spec/api/asn_lookup_api_spec.rb +50 -0
- data/spec/api/astronomy_api_spec.rb +54 -0
- data/spec/api/ip_location_api_spec.rb +67 -0
- data/spec/api/security_api_spec.rb +67 -0
- data/spec/api/time_conversion_api_spec.rb +60 -0
- data/spec/api/timezone_api_spec.rb +56 -0
- data/spec/api/user_agent_api_spec.rb +74 -0
- data/spec/models/abuse_response_spec.rb +42 -0
- data/spec/models/abuse_response_xml_spec.rb +42 -0
- data/spec/models/abuse_spec.rb +90 -0
- data/spec/models/asn_connection_spec.rb +48 -0
- data/spec/models/asn_response_asn_spec.rb +126 -0
- data/spec/models/asn_response_spec.rb +42 -0
- data/spec/models/asn_response_xml_asn_spec.rb +126 -0
- data/spec/models/asn_response_xml_spec.rb +42 -0
- data/spec/models/astronomy_evening_spec.rb +90 -0
- data/spec/models/astronomy_location_spec.rb +132 -0
- data/spec/models/astronomy_morning_spec.rb +90 -0
- data/spec/models/astronomy_response_spec.rb +48 -0
- data/spec/models/astronomy_spec.rb +186 -0
- data/spec/models/astronomy_xml_response_spec.rb +48 -0
- data/spec/models/country_metadata_spec.rb +48 -0
- data/spec/models/currency_spec.rb +48 -0
- data/spec/models/error_response_spec.rb +36 -0
- data/spec/models/error_xml_response_array_spec.rb +36 -0
- data/spec/models/error_xml_response_spec.rb +36 -0
- data/spec/models/geolocation_response_spec.rb +96 -0
- data/spec/models/geolocation_xml_response_array_spec.rb +96 -0
- data/spec/models/geolocation_xml_response_spec.rb +96 -0
- data/spec/models/get_bulk_ip_geolocation200_response_inner1_spec.rb +32 -0
- data/spec/models/get_bulk_ip_geolocation200_response_inner_spec.rb +32 -0
- data/spec/models/get_bulk_ip_geolocation_request_spec.rb +36 -0
- data/spec/models/get_bulk_ip_security_info200_response_inner1_spec.rb +32 -0
- data/spec/models/get_bulk_ip_security_info200_response_inner_spec.rb +32 -0
- data/spec/models/location_minimal_spec.rb +138 -0
- data/spec/models/location_spec.rb +156 -0
- data/spec/models/network_asn_spec.rb +96 -0
- data/spec/models/network_company_spec.rb +48 -0
- data/spec/models/network_minimal_asn_spec.rb +48 -0
- data/spec/models/network_minimal_company_spec.rb +36 -0
- data/spec/models/network_minimal_spec.rb +42 -0
- data/spec/models/network_spec.rb +48 -0
- data/spec/models/parse_bulk_user_agent_strings_request_spec.rb +36 -0
- data/spec/models/parse_user_agent_string_request_spec.rb +36 -0
- data/spec/models/security_api_response_spec.rb +84 -0
- data/spec/models/security_apixml_response_array_spec.rb +84 -0
- data/spec/models/security_apixml_response_spec.rb +84 -0
- data/spec/models/security_spec.rb +96 -0
- data/spec/models/time_conversion_response_spec.rb +54 -0
- data/spec/models/time_conversion_xml_response_spec.rb +54 -0
- data/spec/models/time_zone_detailed_response_spec.rb +60 -0
- data/spec/models/time_zone_detailed_xml_response_spec.rb +60 -0
- data/spec/models/time_zone_dst_end_spec.rb +66 -0
- data/spec/models/time_zone_dst_start_spec.rb +66 -0
- data/spec/models/time_zone_spec.rb +90 -0
- data/spec/models/timezone_airport_spec.rb +102 -0
- data/spec/models/timezone_detail_dst_end_spec.rb +66 -0
- data/spec/models/timezone_detail_dst_start_spec.rb +66 -0
- data/spec/models/timezone_detail_spec.rb +150 -0
- data/spec/models/timezone_location_spec.rb +126 -0
- data/spec/models/timezone_locode_spec.rb +78 -0
- data/spec/models/user_agent_data_device_spec.rb +54 -0
- data/spec/models/user_agent_data_engine_spec.rb +54 -0
- data/spec/models/user_agent_data_operating_system_spec.rb +60 -0
- data/spec/models/user_agent_data_spec.rb +78 -0
- data/spec/models/user_agent_xml_data_array_spec.rb +78 -0
- data/spec/models/user_agent_xml_data_spec.rb +78 -0
- data/spec/spec_helper.rb +111 -0
- metadata +373 -0
data/README.md
ADDED
@@ -0,0 +1,2124 @@
|
|
1
|
+
# IPGeolocation SDK
|
2
|
+
|
3
|
+
Ipgeolocation provides a set of APIs to make ip based decisions.
|
4
|
+
|
5
|
+
|
6
|
+
- Supports IPGeolocation API version: 2.0
|
7
|
+
- Package version: 1.0.0
|
8
|
+
|
9
|
+
## Table of Contents
|
10
|
+
|
11
|
+
1. [Installation](#installation)
|
12
|
+
2. [Authentication](#authentication)
|
13
|
+
3. [API Endpoints](#api-endpoints)
|
14
|
+
4. [IP Geolocation Examples](#ip-geolocation-examples)
|
15
|
+
- [1. Developer (Free) Plan Examples](#1-developer-free-plan-examples)
|
16
|
+
- [2. Standard Plan Examples](#2-standard-plan-examples)
|
17
|
+
- [3. Advanced Plan Examples](#3-advanced-plan-examples)
|
18
|
+
- [Bulk IP Geolocation Example](#bulk-ip-geolocation-example)
|
19
|
+
5. [IP Security Examples](#ip-security-examples)
|
20
|
+
- [Basic Request (Minimal Setup)](#basic-request-minimal-setup)
|
21
|
+
- [Include Multiple Optional Fields](#include-multiple-optional-fields)
|
22
|
+
- [Request with Field Filtering](#request-with-field-filtering)
|
23
|
+
- [Bulk IP Security Request](#bulk-ip-security-request)
|
24
|
+
|
25
|
+
6. [ASN API Examples](#asn-api-examples)
|
26
|
+
- [Get ASN Information by IP Address](#get-asn-information-by-ip-address)
|
27
|
+
- [Get ASN Information by ASN Number](#get-asn-information-by-asn-number)
|
28
|
+
- [Combine All objects using Include](#combine-all-objects-using-include)
|
29
|
+
|
30
|
+
7. [Timezone API Examples](#timezone-api-examples)
|
31
|
+
- [Get Timezone by IP Address](#get-timezone-by-ip-address)
|
32
|
+
- [Get Timezone by Timezone Name](#get-timezone-by-timezone-name)
|
33
|
+
- [Get Timezone from Any Address](#get-timezone-from-any-address)
|
34
|
+
- [Get Timezone from Location Coordinates](#get-timezone-from-location-coordinates)
|
35
|
+
- [Get Timezone and Airport Details from IATA Code](#get-timezone-and-airport-details-from-iata-code)
|
36
|
+
- [Get Timezone and City Details from UN/LOCODE](#get-timezone-and-city-details-from-unlocode)
|
37
|
+
|
38
|
+
8. [Timezone Converter Examples](#timezone-converter-examples)
|
39
|
+
- [Convert Current Time from One Timezone to Another](#convert-current-time-from-one-timezone-to-another)
|
40
|
+
|
41
|
+
9. [User Agent API Examples](#user-agent-api-examples)
|
42
|
+
- [Parse a Basic User Agent String](#parse-a-basic-user-agent-string)
|
43
|
+
- [Bulk User Agent Parsing Example](#bulk-user-agent-parsing-example)
|
44
|
+
10. [Astronomy API Examples](#astronomy-api-examples)
|
45
|
+
- [Astronomy by Coordinates](#astronomy-by-coordinates)
|
46
|
+
- [Astronomy by IP Address](#astronomy-by-ip-address)
|
47
|
+
- [Astronomy by Location String](#astronomy-by-location-string)
|
48
|
+
- [Astronomy for Specific Date](#astronomy-for-specific-date)
|
49
|
+
- [Astronomy in Different Language](#astronomy-in-different-language)
|
50
|
+
|
51
|
+
11. [Documentation for Models](#documentation-for-models)
|
52
|
+
|
53
|
+
## Installation
|
54
|
+
|
55
|
+
### From RubyGems
|
56
|
+
|
57
|
+
Install via command line:
|
58
|
+
|
59
|
+
```bash
|
60
|
+
gem install ipgeolocation
|
61
|
+
```
|
62
|
+
|
63
|
+
Or add to your `Gemfile`:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
gem 'ipgeolocation', '~> 1.0.0'
|
67
|
+
```
|
68
|
+
|
69
|
+
Then run:
|
70
|
+
|
71
|
+
```bash
|
72
|
+
bundle install
|
73
|
+
```
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
### From Source (Local Build)
|
78
|
+
|
79
|
+
To build and install locally:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
gem build ipgeolocation.gemspec
|
83
|
+
gem install ./ipgeolocation-1.0.0.gem
|
84
|
+
```
|
85
|
+
|
86
|
+
---
|
87
|
+
|
88
|
+
### From GitHub
|
89
|
+
|
90
|
+
To install directly from a GitHub repository:
|
91
|
+
|
92
|
+
```ruby
|
93
|
+
gem 'ipgeolocation', git: 'https://github.com/IPGeolocation/ip-geolocation-ruby-sdk.git'
|
94
|
+
```
|
95
|
+
|
96
|
+
## Authentication
|
97
|
+
|
98
|
+
Please follow the [installation](#installation) procedure and then run the following code:
|
99
|
+
|
100
|
+
```ruby
|
101
|
+
# Load the gem
|
102
|
+
require 'ipgeolocation_sdk'
|
103
|
+
|
104
|
+
# Setup authorization
|
105
|
+
IpgeolocationSdk.configure do |config|
|
106
|
+
config.api_key['apiKey'] = 'YOUR API KEY'
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
## API Endpoints
|
111
|
+
|
112
|
+
All URIs are relative to *https://api.ipgeolocation.io/v2*
|
113
|
+
|
114
|
+
Class | Method | HTTP request | Description
|
115
|
+
------------ | ------------- | ------------- | -------------
|
116
|
+
*IpgeolocationSdk::ASNLookupApi* | [**get_asn_info**](docs/ASNLookupApi.md#get_asn_info) | **GET** /asn | Get details of any ASN number or associated IP address
|
117
|
+
*IpgeolocationSdk::AbuseContactApi* | [**get_abuse_contact_info**](docs/AbuseContactApi.md#get_abuse_contact_info) | **GET** /abuse | Retrieve abuse reporting contact information for a given IP address
|
118
|
+
*IpgeolocationSdk::AstronomyApi* | [**get_astronomy_details**](docs/AstronomyApi.md#get_astronomy_details) | **GET** /astronomy | Get sunrise, sunset, moonrise, moonset, and related data for a location
|
119
|
+
*IpgeolocationSdk::IPGeolocationAPI* | [**get_bulk_ip_geolocation**](docs/IPLocationApi.md#get_bulk_ip_geolocation) | **POST** /ipgeo-bulk | Get geolocation data for multiple IP addresses in a single API request
|
120
|
+
*IpgeolocationSdk::IPGeolocationAPI* | [**get_ip_geolocation**](docs/IPLocationApi.md#get_ip_geolocation) | **GET** /ipgeo | Get geolocation data for a single IP address
|
121
|
+
*IpgeolocationSdk::IPSecurityApi* | [**get_bulk_ip_security_info**](docs/SecurityApi.md#get_bulk_ip_security_info) | **POST** /security-bulk | Retrieve security threat intelligence for multiple IPs
|
122
|
+
*IpgeolocationSdk::IPSecurityApi* | [**get_ip_security_info**](docs/SecurityApi.md#get_ip_security_info) | **GET** /security | Retrieve security threat intelligence for a single IP
|
123
|
+
*IpgeolocationSdk::TimeConversionApi* | [**convert_time_between_timezones**](docs/TimeConversionApi.md#convert_time_between_timezones) | **GET** /timezone/convert | Convert time between two specified timezones
|
124
|
+
*IpgeolocationSdk::TimezoneApi* | [**get_timezone_info**](docs/TimezoneApi.md#get_timezone_info) | **GET** /timezone | Timezone information details
|
125
|
+
*IpgeolocationSdk::UserAgentApi* | [**get_user_agent_details**](docs/UserAgentApi.md#get_user_agent_details) | **GET** /user-agent | Get details of user-agent
|
126
|
+
*IpgeolocationSdk::UserAgentApi* | [**parse_bulk_user_agent_strings**](docs/UserAgentApi.md#parse_bulk_user_agent_strings) | **POST** /user-agent-bulk | Handle multiple user-agent string lookups
|
127
|
+
|
128
|
+
|
129
|
+
# Example Usage
|
130
|
+
|
131
|
+
## IP Geolocation Examples
|
132
|
+
|
133
|
+
This section provides usage examples of the `get_ip_geolocation()` method from the SDK across Free, Standard, and Advanced subscription tiers. Each example highlights different combinations of parameters: `fields`, `include`, and `excludes`.
|
134
|
+
|
135
|
+
### Parameters
|
136
|
+
|
137
|
+
#### `fields`
|
138
|
+
Use this parameter to include specific fields in the response.
|
139
|
+
|
140
|
+
#### `excludes`
|
141
|
+
Use this parameter to omit specific fields from the response.
|
142
|
+
|
143
|
+
#### `include`
|
144
|
+
Use this parameter to add optional modules to the response, such as:
|
145
|
+
- `security`
|
146
|
+
- `user_agent`
|
147
|
+
- `hostname`
|
148
|
+
- `liveHostname`
|
149
|
+
- `hostnameFallbackLive`
|
150
|
+
- `abuse`
|
151
|
+
- `dma`
|
152
|
+
- `timezone`
|
153
|
+
|
154
|
+
|
155
|
+
For complete details, refer to the official documentation: [IP Geolocation API Documentation](https://ipgeolocation.io/ip-location-api.html#documentation-overview)
|
156
|
+
|
157
|
+
The `ip` parameter in the SDK can accept any valid IPv4 address, IPv6 address, or domain name. If the `ip()` method is not used or the parameter is omitted, the API will return information about the public IP address of the device or server where the SDK is executed.
|
158
|
+
|
159
|
+
|
160
|
+
### 1. Developer (Free) Plan Examples
|
161
|
+
#### Default Fields
|
162
|
+
|
163
|
+
```ruby
|
164
|
+
get_geolocation_opts = {
|
165
|
+
ip: "8.8.8.8"
|
166
|
+
}
|
167
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
168
|
+
begin
|
169
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
170
|
+
p result
|
171
|
+
rescue IpgeolocationSdk::ApiError => e
|
172
|
+
puts "Error calling GeolocationApi: #{e}"
|
173
|
+
end
|
174
|
+
```
|
175
|
+
Sample Response:
|
176
|
+
```
|
177
|
+
class GeolocationResponse {
|
178
|
+
ip: 8.8.8.8
|
179
|
+
location: class Location {
|
180
|
+
continentCode: NA
|
181
|
+
continentName: North America
|
182
|
+
countryCode2: US
|
183
|
+
countryCode3: USA
|
184
|
+
countryName: United States
|
185
|
+
countryNameOfficial: United States of America
|
186
|
+
countryCapital: Washington, D.C.
|
187
|
+
stateProv: California
|
188
|
+
stateCode: US-CA
|
189
|
+
district: Santa Clara
|
190
|
+
city: Mountain View
|
191
|
+
zipcode: 94043-1351
|
192
|
+
latitude: 37.42240
|
193
|
+
longitude: -122.08421
|
194
|
+
isEu: false
|
195
|
+
countryFlag: https://ipgeolocation.io/static/flags/us_64.png
|
196
|
+
geonameId: 6301403
|
197
|
+
countryEmoji: 🇺🇸
|
198
|
+
}
|
199
|
+
countryMetadata: class CountryMetadata {
|
200
|
+
callingCode: +1
|
201
|
+
tld: .us
|
202
|
+
languages: [en-US, es-US, haw, fr]
|
203
|
+
}
|
204
|
+
currency: class Currency {
|
205
|
+
code: USD
|
206
|
+
name: US Dollar
|
207
|
+
symbol: $
|
208
|
+
}
|
209
|
+
}
|
210
|
+
```
|
211
|
+
Filtering Specific Fields from the Response (Use of 'exclude' and 'fields')
|
212
|
+
```ruby
|
213
|
+
get_geolocation_opts = {
|
214
|
+
ip: "8.8.4.4",
|
215
|
+
fields: "location",
|
216
|
+
excludes: "location.continent_code,location.continent_name"
|
217
|
+
}
|
218
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
219
|
+
begin
|
220
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
221
|
+
p result
|
222
|
+
rescue IpgeolocationSdk::ApiError => e
|
223
|
+
puts "Error calling GeolocationApi: #{e}"
|
224
|
+
end
|
225
|
+
```
|
226
|
+
Sample Response
|
227
|
+
```
|
228
|
+
class GeolocationResponse {
|
229
|
+
ip: 8.8.4.4
|
230
|
+
location: class Location {
|
231
|
+
countryCode2: US
|
232
|
+
countryCode3: USA
|
233
|
+
countryName: United States
|
234
|
+
countryNameOfficial: United States of America
|
235
|
+
countryCapital: Washington, D.C.
|
236
|
+
stateProv: California
|
237
|
+
stateCode: US-CA
|
238
|
+
district: Santa Clara
|
239
|
+
city: Mountain View
|
240
|
+
zipcode: 94043-1351
|
241
|
+
latitude: 37.42240
|
242
|
+
longitude: -122.08421
|
243
|
+
isEu: false
|
244
|
+
countryFlag: https://ipgeolocation.io/static/flags/us_64.png
|
245
|
+
geonameId: 6301403
|
246
|
+
countryEmoji: 🇺🇸
|
247
|
+
}
|
248
|
+
}
|
249
|
+
```
|
250
|
+
### 2. Standard Plan Examples
|
251
|
+
#### Default Fields
|
252
|
+
|
253
|
+
```ruby
|
254
|
+
get_geolocation_opts = {
|
255
|
+
ip: "8.8.8.8"
|
256
|
+
}
|
257
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
258
|
+
begin
|
259
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
260
|
+
p result
|
261
|
+
rescue IpgeolocationSdk::ApiError => e
|
262
|
+
puts "Error calling GeolocationApi: #{e}"
|
263
|
+
end
|
264
|
+
```
|
265
|
+
Sample Response:
|
266
|
+
```
|
267
|
+
class GeolocationResponse {
|
268
|
+
ip: 8.8.8.8
|
269
|
+
location: class Location {
|
270
|
+
continentCode: NA
|
271
|
+
continentName: North America
|
272
|
+
countryCode2: US
|
273
|
+
countryCode3: USA
|
274
|
+
countryName: United States
|
275
|
+
countryNameOfficial: United States of America
|
276
|
+
countryCapital: Washington, D.C.
|
277
|
+
stateProv: California
|
278
|
+
stateCode: US-CA
|
279
|
+
district: Santa Clara
|
280
|
+
city: Mountain View
|
281
|
+
zipcode: 94043-1351
|
282
|
+
latitude: 37.42240
|
283
|
+
longitude: -122.08421
|
284
|
+
isEu: false
|
285
|
+
countryFlag: https://ipgeolocation.io/static/flags/us_64.png
|
286
|
+
geonameId: 6301403
|
287
|
+
countryEmoji: 🇺🇸
|
288
|
+
}
|
289
|
+
countryMetadata: class CountryMetadata {
|
290
|
+
callingCode: +1
|
291
|
+
tld: .us
|
292
|
+
languages: [en-US, es-US, haw, fr]
|
293
|
+
}
|
294
|
+
network: class Network {
|
295
|
+
asn: class NetworkAsn {
|
296
|
+
asNumber: AS15169
|
297
|
+
organization: Google LLC
|
298
|
+
country: US
|
299
|
+
}
|
300
|
+
company: class NetworkCompany {
|
301
|
+
name: Google LLC
|
302
|
+
}
|
303
|
+
}
|
304
|
+
currency: class Currency {
|
305
|
+
code: USD
|
306
|
+
name: US Dollar
|
307
|
+
symbol: $
|
308
|
+
}
|
309
|
+
}
|
310
|
+
```
|
311
|
+
### Retrieving Geolocation Data in Multiple Languages
|
312
|
+
Here is an example to get the geolocation data for IP address '2001:4230:4890::1' in French language:
|
313
|
+
```ruby
|
314
|
+
get_geolocation_opts = {
|
315
|
+
ip: "2001:4230:4890::1",
|
316
|
+
lang: "fr"
|
317
|
+
}
|
318
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
319
|
+
begin
|
320
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
321
|
+
p result
|
322
|
+
rescue IpgeolocationSdk::ApiError => e
|
323
|
+
puts "Error calling GeolocationApi: #{e}"
|
324
|
+
end
|
325
|
+
```
|
326
|
+
|
327
|
+
Sample Response
|
328
|
+
```
|
329
|
+
class GeolocationResponse {
|
330
|
+
ip: 2001:4230:4890:0:0:0:0:1
|
331
|
+
location: class Location {
|
332
|
+
continentCode: AF
|
333
|
+
continentName: Afrique
|
334
|
+
countryCode2: MU
|
335
|
+
countryCode3: MUS
|
336
|
+
countryName: Maurice
|
337
|
+
countryNameOfficial:
|
338
|
+
countryCapital: Port Louis
|
339
|
+
stateProv: Wilhems des plaines
|
340
|
+
stateCode: MU-PW
|
341
|
+
district: Quatre Bornes
|
342
|
+
city: Quatre Bornes
|
343
|
+
zipcode: 72201
|
344
|
+
latitude: -20.24304
|
345
|
+
longitude: 57.49631
|
346
|
+
isEu: false
|
347
|
+
countryFlag: https://ipgeolocation.io/static/flags/mu_64.png
|
348
|
+
geonameId: 1106777
|
349
|
+
countryEmoji: 🇲🇺
|
350
|
+
}
|
351
|
+
countryMetadata: class CountryMetadata {
|
352
|
+
callingCode: +230
|
353
|
+
tld: .mu
|
354
|
+
languages: [en-MU, bho, fr]
|
355
|
+
}
|
356
|
+
network: class Network {
|
357
|
+
asn: class NetworkAsn {
|
358
|
+
asNumber: AS0
|
359
|
+
organization:
|
360
|
+
country:
|
361
|
+
}
|
362
|
+
company: class NetworkCompany {
|
363
|
+
name: African Network Information Center AfriNIC Ltd
|
364
|
+
}
|
365
|
+
}
|
366
|
+
currency: class Currency {
|
367
|
+
code: MUR
|
368
|
+
name: Mauritius Rupee
|
369
|
+
symbol: ₨
|
370
|
+
}
|
371
|
+
}
|
372
|
+
```
|
373
|
+
|
374
|
+
#### Include HostName, Timezone and User-Agent
|
375
|
+
```ruby
|
376
|
+
get_geolocation_opts = {
|
377
|
+
ip: "4.5.6.7",
|
378
|
+
include: "hostname,time_zone,user_agent"
|
379
|
+
}
|
380
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
381
|
+
begin
|
382
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
383
|
+
p result
|
384
|
+
rescue IpgeolocationSdk::ApiError => e
|
385
|
+
puts "Error calling GeolocationApi: #{e}"
|
386
|
+
end
|
387
|
+
```
|
388
|
+
Sample Response
|
389
|
+
```
|
390
|
+
class GeolocationResponse {
|
391
|
+
ip: 4.5.6.7
|
392
|
+
hostname: 4.5.6.7
|
393
|
+
location: class Location {
|
394
|
+
countryName: United States
|
395
|
+
countryCapital: Washington, D.C.
|
396
|
+
}
|
397
|
+
timeZone: class TimeZone {
|
398
|
+
name: America/Chicago
|
399
|
+
offset: -6
|
400
|
+
offsetWithDst: -5
|
401
|
+
currentTime: 2025-05-28 06:52:16.748-0500
|
402
|
+
currentTimeUnix: 1748433136.748
|
403
|
+
isDst: true
|
404
|
+
dstSavings: 1
|
405
|
+
dstExists: true
|
406
|
+
dstStart: class TimeZoneDstStart {
|
407
|
+
utcTime: 2025-03-09 TIME 08
|
408
|
+
duration: +1H
|
409
|
+
gap: true
|
410
|
+
dateTimeAfter: 2025-03-09 TIME 03
|
411
|
+
dateTimeBefore: 2025-03-09 TIME 02
|
412
|
+
overlap: false
|
413
|
+
}
|
414
|
+
dstEnd: class TimeZoneDstEnd {
|
415
|
+
utcTime: 2025-11-02 TIME 07
|
416
|
+
duration: -1H
|
417
|
+
gap: false
|
418
|
+
dateTimeAfter: 2025-11-02 TIME 01
|
419
|
+
dateTimeBefore: 2025-11-02 TIME 02
|
420
|
+
overlap: true
|
421
|
+
}
|
422
|
+
}
|
423
|
+
userAgent: class UserAgentData {
|
424
|
+
userAgentString: IPGeolocation/2.0.0/java
|
425
|
+
name: IPGeolocation Java SDK
|
426
|
+
type: Special
|
427
|
+
version: 2.0.0
|
428
|
+
versionMajor: 1
|
429
|
+
device: class UserAgentDataDevice {
|
430
|
+
name: Unknown
|
431
|
+
type: Unknown
|
432
|
+
brand: Unknown
|
433
|
+
cpu: Unknown
|
434
|
+
}
|
435
|
+
engine: class UserAgentDataEngine {
|
436
|
+
name: Unknown
|
437
|
+
type: Unknown
|
438
|
+
version: ??
|
439
|
+
versionMajor: ??
|
440
|
+
}
|
441
|
+
operatingSystem: class UserAgentDataOperatingSystem {
|
442
|
+
name: Unknown
|
443
|
+
type: Unknown
|
444
|
+
version: ??
|
445
|
+
versionMajor: ??
|
446
|
+
build: ??
|
447
|
+
}
|
448
|
+
}
|
449
|
+
}
|
450
|
+
```
|
451
|
+
**Note on Hostname Parameters**
|
452
|
+
|
453
|
+
The IP Geolocation API supports hostname lookup for all paid subscriptions. However, this is not included by default. To enable hostname resolution, use the `include` parameter with one of the following options:
|
454
|
+
|
455
|
+
- `hostname`: Performs a quick lookup using the internal hostname database. If no match is found, the IP is returned as-is. This is fast but may produce incomplete results.
|
456
|
+
- `liveHostname`: Queries live sources for accurate hostname resolution. This may increase response time.
|
457
|
+
- `hostnameFallbackLive`: Attempts the internal database first, and falls back to live sources if no result is found. This option provides a balance of speed and reliability.
|
458
|
+
|
459
|
+
### 3. Advanced Plan Examples
|
460
|
+
#### Include DMA, Abuse and Security
|
461
|
+
|
462
|
+
```ruby
|
463
|
+
get_geolocation_opts = {
|
464
|
+
ip: "8.8.8.8",
|
465
|
+
include: "dma,abuse,security",
|
466
|
+
excludes: "location.country_flag,location.country_emoji"
|
467
|
+
}
|
468
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
469
|
+
begin
|
470
|
+
result = geolocation_instance.get_ip_geolocation(get_geolocation_opts)
|
471
|
+
p result
|
472
|
+
rescue IpgeolocationSdk::ApiError => e
|
473
|
+
puts "Error calling GeolocationApi: #{e}"
|
474
|
+
end
|
475
|
+
```
|
476
|
+
Sample Response:
|
477
|
+
```
|
478
|
+
class GeolocationResponse {
|
479
|
+
ip: 8.8.8.8
|
480
|
+
location: class Location {
|
481
|
+
continentCode: NA
|
482
|
+
continentName: North America
|
483
|
+
countryCode2: US
|
484
|
+
countryCode3: USA
|
485
|
+
countryName: United States
|
486
|
+
countryNameOfficial: United States of America
|
487
|
+
countryCapital: Washington, D.C.
|
488
|
+
stateProv: California
|
489
|
+
stateCode: US-CA
|
490
|
+
district: Santa Clara
|
491
|
+
city: Mountain View
|
492
|
+
zipcode: 94043-1351
|
493
|
+
latitude: 37.42240
|
494
|
+
longitude: -122.08421
|
495
|
+
isEu: false
|
496
|
+
countryFlag: null
|
497
|
+
geonameId: 6301403
|
498
|
+
countryEmoji: null
|
499
|
+
accuracyRadius:
|
500
|
+
locality: Mountain View
|
501
|
+
dmaCode: 807
|
502
|
+
}
|
503
|
+
countryMetadata: class CountryMetadata {
|
504
|
+
callingCode: +1
|
505
|
+
tld: .us
|
506
|
+
languages: [en-US, es-US, haw, fr]
|
507
|
+
}
|
508
|
+
network: class Network {
|
509
|
+
asn: class NetworkAsn {
|
510
|
+
asNumber: AS15169
|
511
|
+
organization: Google LLC
|
512
|
+
country: US
|
513
|
+
asnName: GOOGLE
|
514
|
+
type: BUSINESS
|
515
|
+
domain: about.google
|
516
|
+
dateAllocated:
|
517
|
+
allocationStatus: assigned
|
518
|
+
numOfIpv4Routes: 965
|
519
|
+
numOfIpv6Routes: 104
|
520
|
+
rir: ARIN
|
521
|
+
}
|
522
|
+
connectionType:
|
523
|
+
company: class NetworkCompany {
|
524
|
+
name: Google LLC
|
525
|
+
type: Business
|
526
|
+
domain: googlellc.com
|
527
|
+
}
|
528
|
+
}
|
529
|
+
currency: class Currency {
|
530
|
+
code: USD
|
531
|
+
name: US Dollar
|
532
|
+
symbol: $
|
533
|
+
}
|
534
|
+
security: class Security {
|
535
|
+
threatScore: 0
|
536
|
+
isTor: false
|
537
|
+
isProxy: false
|
538
|
+
proxyType:
|
539
|
+
proxyProvider:
|
540
|
+
isAnonymous: false
|
541
|
+
isKnownAttacker: false
|
542
|
+
isSpam: false
|
543
|
+
isBot: false
|
544
|
+
isCloudProvider: false
|
545
|
+
cloudProvider:
|
546
|
+
}
|
547
|
+
abuse: class Abuse {
|
548
|
+
route: 8.8.8.0/24
|
549
|
+
country:
|
550
|
+
handle: ABUSE5250-ARIN
|
551
|
+
name: Abuse
|
552
|
+
organization: Abuse
|
553
|
+
role: abuse
|
554
|
+
kind: group
|
555
|
+
address: 1600 Amphitheatre Parkway
|
556
|
+
Mountain View
|
557
|
+
CA
|
558
|
+
94043
|
559
|
+
United States
|
560
|
+
emails: [network-abuse@google.com]
|
561
|
+
phoneNumbers: [+1-650-253-0000]
|
562
|
+
}
|
563
|
+
}
|
564
|
+
```
|
565
|
+
These examples demonstrate typical usage of the IP Geolocation API with different subscription tiers. Use `fields` to specify exactly which data to receive, `include` for optional data like security and user agent, and `excludes` to omit specific keys from the response.
|
566
|
+
|
567
|
+
**Note:** All features available in the Free plan are also included in the Standard and Advanced plans. Similarly, all features of the Standard plan are available in the Advanced plan.
|
568
|
+
|
569
|
+
## Bulk IP Geolocation Example
|
570
|
+
The SDK also supports bulk IP geolocation requests using the `get_bulk_ip_geolocation()` method. All parameters like `fields`, `include`, and `excludes` can also be used in bulk requests.
|
571
|
+
|
572
|
+
```ruby
|
573
|
+
post_geolocation_opts = {
|
574
|
+
ips: ["8.8.8.8", "asdasd"],
|
575
|
+
include: "security",
|
576
|
+
excludes: "location.country_flag,location.country_emoji"
|
577
|
+
}
|
578
|
+
geolocation_instance = IpgeolocationSdk::IPGeolocationApi.new
|
579
|
+
begin
|
580
|
+
result = geolocation_instance.get_bulk_ip_geolocation(post_geolocation_opts)
|
581
|
+
result.each do |item|
|
582
|
+
if IpgeolocationSdk::BulkIPGeolocation.is_success?(item) # GeolocationResponse
|
583
|
+
p item.ip
|
584
|
+
elsif IpgeolocationSdk::BulkIPGeolocation.is_error?(item) # ErrorResponse
|
585
|
+
p item.message
|
586
|
+
end
|
587
|
+
end
|
588
|
+
rescue IpgeolocationSdk::ApiError => e
|
589
|
+
puts "Error calling GeolocationApi: #{e}"
|
590
|
+
end
|
591
|
+
```
|
592
|
+
|
593
|
+
## IP Security Examples
|
594
|
+
|
595
|
+
This section provides usage examples of the `get_ip_security_info()` method from the SDK across various subscription tiers. Each example demonstrates different ways to query threat intelligence and risk metadata using parameters like fields, excludes, and optional modules.
|
596
|
+
|
597
|
+
For full API specifications, refer to the [official IP Security API documentation](https://ipgeolocation.io/ip-security-api.html#documentation-overview).
|
598
|
+
|
599
|
+
---
|
600
|
+
|
601
|
+
### Basic Request (Minimal Setup)
|
602
|
+
|
603
|
+
```ruby
|
604
|
+
get_ip_security_opts = {
|
605
|
+
ip: "2.56.188.34"
|
606
|
+
}
|
607
|
+
security_instance = IpgeolocationSdk::IPSecurityAPI.new
|
608
|
+
begin
|
609
|
+
result = security_instance.get_ip_security_info(get_ip_security_opts)
|
610
|
+
p result
|
611
|
+
rescue IpgeolocationSdk::ApiError => e
|
612
|
+
puts "Error calling GeolocationApi: #{e}"
|
613
|
+
end
|
614
|
+
```
|
615
|
+
|
616
|
+
Sample Response
|
617
|
+
```
|
618
|
+
class SecurityAPIResponse {
|
619
|
+
ip: 2.56.188.34
|
620
|
+
security: class Security {
|
621
|
+
threatScore: 80
|
622
|
+
isTor: false
|
623
|
+
isProxy: true
|
624
|
+
proxyType: VPN
|
625
|
+
proxyProvider: Nord VPN
|
626
|
+
isAnonymous: true
|
627
|
+
isKnownAttacker: true
|
628
|
+
isSpam: false
|
629
|
+
isBot: false
|
630
|
+
isCloudProvider: true
|
631
|
+
cloudProvider: Packethub S.A.
|
632
|
+
}
|
633
|
+
}
|
634
|
+
```
|
635
|
+
### Include Multiple Optional Fields
|
636
|
+
```ruby
|
637
|
+
get_ip_security_opts = {
|
638
|
+
ip: "2.56.188.34",
|
639
|
+
include: "location,network,currency,time_zone,user_agent,country_metadata,hostname"
|
640
|
+
}
|
641
|
+
security_instance = IpgeolocationSdk::IPSecurityAPI.new
|
642
|
+
begin
|
643
|
+
result = security_instance.get_ip_security_info(get_ip_security_opts)
|
644
|
+
p result
|
645
|
+
rescue IpgeolocationSdk::ApiError => e
|
646
|
+
puts "Error calling GeolocationApi: #{e}"
|
647
|
+
end
|
648
|
+
```
|
649
|
+
|
650
|
+
Sample Response
|
651
|
+
```
|
652
|
+
class SecurityAPIResponse {
|
653
|
+
ip: 2.56.188.34
|
654
|
+
hostname: 2.56.188.34
|
655
|
+
security: class Security {
|
656
|
+
threatScore: 80
|
657
|
+
isTor: false
|
658
|
+
isProxy: true
|
659
|
+
proxyType: VPN
|
660
|
+
proxyProvider: Nord VPN
|
661
|
+
isAnonymous: true
|
662
|
+
isKnownAttacker: true
|
663
|
+
isSpam: false
|
664
|
+
isBot: false
|
665
|
+
isCloudProvider: true
|
666
|
+
cloudProvider: Packethub S.A.
|
667
|
+
}
|
668
|
+
location: class LocationMinimal {
|
669
|
+
continentCode: NA
|
670
|
+
continentName: North America
|
671
|
+
countryCode2: US
|
672
|
+
countryCode3: USA
|
673
|
+
countryName: United States
|
674
|
+
countryNameOfficial: United States of America
|
675
|
+
countryCapital: Washington, D.C.
|
676
|
+
stateProv: Texas
|
677
|
+
stateCode: US-TX
|
678
|
+
district: Dallas County
|
679
|
+
city: Dallas
|
680
|
+
zipcode: 75207
|
681
|
+
latitude: 32.78916
|
682
|
+
longitude: -96.82170
|
683
|
+
isEu: false
|
684
|
+
countryFlag: https://ipgeolocation.io/static/flags/us_64.png
|
685
|
+
geonameId: 7181768
|
686
|
+
countryEmoji: 🇺🇸
|
687
|
+
}
|
688
|
+
network: class NetworkMinimal {
|
689
|
+
asn: class NetworkMinimalAsn {
|
690
|
+
asNumber: AS62240
|
691
|
+
organization: Clouvider Limited
|
692
|
+
country: GB
|
693
|
+
}
|
694
|
+
company: class NetworkMinimalCompany {
|
695
|
+
name: Packethub S.A.
|
696
|
+
}
|
697
|
+
}
|
698
|
+
timeZone: class TimeZone {
|
699
|
+
name: America/Chicago
|
700
|
+
offset: -6
|
701
|
+
offsetWithDst: -5
|
702
|
+
currentTime: 2025-05-29 08:27:44.939-0500
|
703
|
+
currentTimeUnix: 1748525264.939
|
704
|
+
isDst: true
|
705
|
+
dstSavings: 1
|
706
|
+
dstExists: true
|
707
|
+
dstStart: class TimeZoneDstStart {
|
708
|
+
utcTime: 2025-03-09 TIME 08
|
709
|
+
duration: +1H
|
710
|
+
gap: true
|
711
|
+
dateTimeAfter: 2025-03-09 TIME 03
|
712
|
+
dateTimeBefore: 2025-03-09 TIME 02
|
713
|
+
overlap: false
|
714
|
+
}
|
715
|
+
dstEnd: class TimeZoneDstEnd {
|
716
|
+
utcTime: 2025-11-02 TIME 07
|
717
|
+
duration: -1H
|
718
|
+
gap: false
|
719
|
+
dateTimeAfter: 2025-11-02 TIME 01
|
720
|
+
dateTimeBefore: 2025-11-02 TIME 02
|
721
|
+
overlap: true
|
722
|
+
}
|
723
|
+
}
|
724
|
+
userAgent: class UserAgentData {
|
725
|
+
userAgentString: IPGeolocation/2.0.0/java
|
726
|
+
name: IPGeolocation Java SDK
|
727
|
+
type: Special
|
728
|
+
version: 2.0.0
|
729
|
+
versionMajor: 1
|
730
|
+
device: class UserAgentDataDevice {
|
731
|
+
name: Unknown
|
732
|
+
type: Unknown
|
733
|
+
brand: Unknown
|
734
|
+
cpu: Unknown
|
735
|
+
}
|
736
|
+
engine: class UserAgentDataEngine {
|
737
|
+
name: Unknown
|
738
|
+
type: Unknown
|
739
|
+
version: ??
|
740
|
+
versionMajor: ??
|
741
|
+
}
|
742
|
+
operatingSystem: class UserAgentDataOperatingSystem {
|
743
|
+
name: Unknown
|
744
|
+
type: Unknown
|
745
|
+
version: ??
|
746
|
+
versionMajor: ??
|
747
|
+
build: ??
|
748
|
+
}
|
749
|
+
}
|
750
|
+
countryMetadata: class CountryMetadata {
|
751
|
+
callingCode: +1
|
752
|
+
tld: .us
|
753
|
+
languages: [en-US, es-US, haw, fr]
|
754
|
+
}
|
755
|
+
currency: class Currency {
|
756
|
+
code: USD
|
757
|
+
name: US Dollar
|
758
|
+
symbol: $
|
759
|
+
}
|
760
|
+
}
|
761
|
+
```
|
762
|
+
### Request with Field Filtering
|
763
|
+
|
764
|
+
```ruby
|
765
|
+
get_ip_security_opts = {
|
766
|
+
ip: "195.154.221.54",
|
767
|
+
fields: "security.is_tor,security.is_proxy,security.is_bot,security.is_spam"
|
768
|
+
}
|
769
|
+
security_instance = IpgeolocationSdk::IPSecurityAPI.new
|
770
|
+
begin
|
771
|
+
result = security_instance.get_ip_security_info(get_ip_security_opts)
|
772
|
+
p result
|
773
|
+
rescue IpgeolocationSdk::ApiError => e
|
774
|
+
puts "Error calling SecurityApi: #{e}"
|
775
|
+
end
|
776
|
+
```
|
777
|
+
Sample Response
|
778
|
+
```
|
779
|
+
class SecurityAPIResponse {
|
780
|
+
ip: 195.154.221.54
|
781
|
+
security: class Security {
|
782
|
+
isTor: false
|
783
|
+
isProxy: true
|
784
|
+
isSpam: false
|
785
|
+
isBot: false
|
786
|
+
}
|
787
|
+
}
|
788
|
+
|
789
|
+
```
|
790
|
+
## Bulk IP Security Request
|
791
|
+
The SDK also supports bulk IP Security requests using the `get_bulk_ip_security_info()` method. All parameters like `fields`, `include`, and `excludes` can also be used in bulk requests.
|
792
|
+
|
793
|
+
```ruby
|
794
|
+
post_ip_security_opts = {
|
795
|
+
ips: ["2.56.188.34","2.56.188.35"],
|
796
|
+
include: "location,network",
|
797
|
+
fields: "security.threat_score,location.country_name"
|
798
|
+
}
|
799
|
+
|
800
|
+
security_instance = IpgeolocationSdk::IPSecurityAPI.new
|
801
|
+
begin
|
802
|
+
result = security_instance.get_bulk_ip_security_info(post_ip_security_opts)
|
803
|
+
result.each do |item|
|
804
|
+
if IpgeolocationSdk::BulkIPSecurity.is_success?(item) # SecurityAPIResponse
|
805
|
+
p item.ip
|
806
|
+
elsif IpgeolocationSdk::BulkIPSecurity.is_error?(item) # ErrorResponse
|
807
|
+
p item.message
|
808
|
+
end
|
809
|
+
end
|
810
|
+
rescue IpgeolocationSdk::ApiError => e
|
811
|
+
puts "Error calling SecurityApi: #{e}"
|
812
|
+
end
|
813
|
+
```
|
814
|
+
|
815
|
+
## ASN API Examples
|
816
|
+
|
817
|
+
This section provides usage examples of the `get_asn_info()` method from the SDK. These methods allow developers to retrieve detailed ASN-level network data either by ASN number or by IP address. Note that ASN API is only available in the Advanced subscription plans.
|
818
|
+
|
819
|
+
Refer to the [ASN API documentation](https://ipgeolocation.io/asn-api.html#documentation-overview) for a detailed list of supported fields and behaviors.
|
820
|
+
|
821
|
+
### Get ASN Information by IP Address
|
822
|
+
|
823
|
+
```ruby
|
824
|
+
asn_opts = {
|
825
|
+
ip: '8.8.8.8',
|
826
|
+
}
|
827
|
+
asn_instance = IpgeolocationSdk::ASNLookupApi.new
|
828
|
+
begin
|
829
|
+
result = asn_instance.get_asn_info(asn_opts)
|
830
|
+
p result
|
831
|
+
rescue IpgeolocationSdk::ApiError => e
|
832
|
+
puts "Error calling ASNLookupApi: #{e}"
|
833
|
+
end
|
834
|
+
|
835
|
+
```
|
836
|
+
Sample Response
|
837
|
+
```
|
838
|
+
class ASNResponse {
|
839
|
+
ip: 8.8.8.8
|
840
|
+
asn: class ASNDetails {
|
841
|
+
asNumber: AS15169
|
842
|
+
organization: Google LLC
|
843
|
+
country: US
|
844
|
+
asnName: GOOGLE
|
845
|
+
type: BUSINESS
|
846
|
+
domain: about.google
|
847
|
+
dateAllocated:
|
848
|
+
allocationStatus: assigned
|
849
|
+
numOfIpv4Routes: 983
|
850
|
+
numOfIpv6Routes: 104
|
851
|
+
rir: ARIN
|
852
|
+
}
|
853
|
+
}
|
854
|
+
```
|
855
|
+
### Get ASN Information by ASN Number
|
856
|
+
|
857
|
+
```ruby
|
858
|
+
asn_opts = {
|
859
|
+
asn: 15169,
|
860
|
+
}
|
861
|
+
asn_instance = IpgeolocationSdk::ASNLookupApi.new
|
862
|
+
begin
|
863
|
+
result = asn_instance.get_asn_info(asn_opts)
|
864
|
+
p result
|
865
|
+
rescue IpgeolocationSdk::ApiError => e
|
866
|
+
puts "Error calling ASNLookupApi: #{e}"
|
867
|
+
end
|
868
|
+
```
|
869
|
+
Sample Response
|
870
|
+
```
|
871
|
+
class ASNResponse {
|
872
|
+
asn: class ASNDetails {
|
873
|
+
asNumber: AS15169
|
874
|
+
organization: Google LLC
|
875
|
+
country: US
|
876
|
+
asnName: GOOGLE
|
877
|
+
type: BUSINESS
|
878
|
+
domain: about.google
|
879
|
+
dateAllocated:
|
880
|
+
allocationStatus: assigned
|
881
|
+
numOfIpv4Routes: 983
|
882
|
+
numOfIpv6Routes: 104
|
883
|
+
rir: ARIN
|
884
|
+
}
|
885
|
+
}
|
886
|
+
```
|
887
|
+
|
888
|
+
### Combine All objects using Include
|
889
|
+
```ruby
|
890
|
+
asn_opts = {
|
891
|
+
asn: 12,
|
892
|
+
include: "peers,downstreams,upstreams,routes,whois_response"
|
893
|
+
}
|
894
|
+
asn_instance = IpgeolocationSdk::ASNLookupApi.new
|
895
|
+
begin
|
896
|
+
result = asn_instance.get_asn_info(asn_opts)
|
897
|
+
p result
|
898
|
+
rescue IpgeolocationSdk::ApiError => e
|
899
|
+
puts "Error calling ASNLookupApi: #{e}"
|
900
|
+
end
|
901
|
+
```
|
902
|
+
Sample Response
|
903
|
+
```
|
904
|
+
class ASNResponse {
|
905
|
+
ip: null
|
906
|
+
asn: class ASNDetails {
|
907
|
+
asNumber: AS12
|
908
|
+
organization: New York University
|
909
|
+
country: US
|
910
|
+
asnName: NYU-DOMAIN
|
911
|
+
type: EDUCATION
|
912
|
+
domain: nyu.edu
|
913
|
+
dateAllocated:
|
914
|
+
allocationStatus: assigned
|
915
|
+
numOfIpv4Routes: 11
|
916
|
+
numOfIpv6Routes: 1
|
917
|
+
rir: ARIN
|
918
|
+
routes: [192.76.177.0/24, 216.165.96.0/20, 216.165.89.0/24, 216.165.0.0/18, 216.165.112.0/21, 128.122.0.0/16, 2607:f600::/32, 216.165.102.0/24, 216.165.64.0/19, 216.165.120.0/22, 192.86.139.0/24, 216.165.103.0/24]
|
919
|
+
upstreams: [class ASNConnection {
|
920
|
+
asNumber: AS3269
|
921
|
+
description: Telecom Italia S.p.A.
|
922
|
+
country: IT
|
923
|
+
}, class ASNConnection {
|
924
|
+
asNumber: AS8220
|
925
|
+
description: COLT Technology Services Group Limited
|
926
|
+
country: GB
|
927
|
+
}, class ASNConnection {
|
928
|
+
asNumber: AS286
|
929
|
+
description: GTT Communications Inc.
|
930
|
+
country: US
|
931
|
+
}, class ASNConnection {
|
932
|
+
asNumber: AS3257
|
933
|
+
description: GTT Communications Inc.
|
934
|
+
country: US
|
935
|
+
}, class ASNConnection {
|
936
|
+
asNumber: AS3754
|
937
|
+
description: NYSERNet
|
938
|
+
country: US
|
939
|
+
}, class ASNConnection {
|
940
|
+
asNumber: AS3356
|
941
|
+
description: Level 3 Parent, LLC
|
942
|
+
country: US
|
943
|
+
}, class ASNConnection {
|
944
|
+
asNumber: AS6461
|
945
|
+
description: Zayo Bandwidth
|
946
|
+
country: US
|
947
|
+
}, class ASNConnection {
|
948
|
+
asNumber: AS137
|
949
|
+
description: Consortium GARR
|
950
|
+
country: IT
|
951
|
+
}]
|
952
|
+
downstreams: [class ASNConnection {
|
953
|
+
asNumber: AS394666
|
954
|
+
description: NYU Langone Health
|
955
|
+
country: US
|
956
|
+
}, class ASNConnection {
|
957
|
+
asNumber: AS54965
|
958
|
+
description: Polytechnic Institute of NYU
|
959
|
+
country: US
|
960
|
+
}]
|
961
|
+
peers: [class ASNConnection {
|
962
|
+
asNumber: AS3269
|
963
|
+
description: Telecom Italia S.p.A.
|
964
|
+
country: IT
|
965
|
+
}, class ASNConnection {
|
966
|
+
asNumber: AS8220
|
967
|
+
description: COLT Technology Services Group Limited
|
968
|
+
country: GB
|
969
|
+
}, class ASNConnection {
|
970
|
+
asNumber: AS394666
|
971
|
+
description: NYU Langone Health
|
972
|
+
country: US
|
973
|
+
}, class ASNConnection {
|
974
|
+
asNumber: AS286
|
975
|
+
description: GTT Communications Inc.
|
976
|
+
country: NL
|
977
|
+
}, class ASNConnection {
|
978
|
+
asNumber: AS286
|
979
|
+
description: GTT Communications Inc.
|
980
|
+
country: US
|
981
|
+
}, class ASNConnection {
|
982
|
+
asNumber: AS3257
|
983
|
+
description: GTT Communications Inc.
|
984
|
+
country: US
|
985
|
+
}, class ASNConnection {
|
986
|
+
asNumber: AS3754
|
987
|
+
description: NYSERNet
|
988
|
+
country: US
|
989
|
+
}, class ASNConnection {
|
990
|
+
asNumber: AS3356
|
991
|
+
description: Level 3 Parent, LLC
|
992
|
+
country: US
|
993
|
+
}, class ASNConnection {
|
994
|
+
asNumber: AS6461
|
995
|
+
description: Zayo Bandwidth
|
996
|
+
country: US
|
997
|
+
}, class ASNConnection {
|
998
|
+
asNumber: AS137
|
999
|
+
description: Consortium GARR
|
1000
|
+
country: IT
|
1001
|
+
}, class ASNConnection {
|
1002
|
+
asNumber: AS54965
|
1003
|
+
description: Polytechnic Institute of NYU
|
1004
|
+
country: US
|
1005
|
+
}]
|
1006
|
+
whoisResponse:
|
1007
|
+
|
1008
|
+
|
1009
|
+
ASNumber: 12
|
1010
|
+
ASName: NYU-DOMAIN
|
1011
|
+
ASHandle: AS12
|
1012
|
+
RegDate: 1984-07-05
|
1013
|
+
Updated: 2023-05-25
|
1014
|
+
Ref: https://rdap.arin.net/registry/autnum/12
|
1015
|
+
|
1016
|
+
|
1017
|
+
OrgName: New York University
|
1018
|
+
OrgId: NYU-Z
|
1019
|
+
Address: 726 Broadway, 8th Floor - ITS
|
1020
|
+
City: New York
|
1021
|
+
StateProv: NY
|
1022
|
+
PostalCode: 10003
|
1023
|
+
Country: US
|
1024
|
+
RegDate: 2023-05-15
|
1025
|
+
Updated: 2023-05-15
|
1026
|
+
Ref: https://rdap.arin.net/registry/entity/NYU-Z
|
1027
|
+
|
1028
|
+
|
1029
|
+
OrgAbuseHandle: OIS9-ARIN
|
1030
|
+
OrgAbuseName: Office of Information Security
|
1031
|
+
OrgAbusePhone: +1-212-998-3333
|
1032
|
+
OrgAbuseEmail: abuse@nyu.edu
|
1033
|
+
OrgAbuseRef: https://rdap.arin.net/registry/entity/OIS9-ARIN
|
1034
|
+
|
1035
|
+
OrgNOCHandle: COSI-ARIN
|
1036
|
+
OrgNOCName: Communications Operations Services - ITS
|
1037
|
+
OrgNOCPhone: +1-212-998-3444
|
1038
|
+
OrgNOCEmail: noc-cosi-arin@nyu.edu
|
1039
|
+
OrgNOCRef: https://rdap.arin.net/registry/entity/COSI-ARIN
|
1040
|
+
|
1041
|
+
OrgTechHandle: COSI-ARIN
|
1042
|
+
OrgTechName: Communications Operations Services - ITS
|
1043
|
+
OrgTechPhone: +1-212-998-3444
|
1044
|
+
OrgTechEmail: noc-cosi-arin@nyu.edu
|
1045
|
+
OrgTechRef: https://rdap.arin.net/registry/entity/COSI-ARIN
|
1046
|
+
|
1047
|
+
RTechHandle: COSI-ARIN
|
1048
|
+
RTechName: Communications Operations Services - ITS
|
1049
|
+
RTechPhone: +1-212-998-3444
|
1050
|
+
RTechEmail: noc-cosi-arin@nyu.edu
|
1051
|
+
RTechRef: https://rdap.arin.net/registry/entity/COSI-ARIN
|
1052
|
+
|
1053
|
+
RNOCHandle: COSI-ARIN
|
1054
|
+
RNOCName: Communications Operations Services - ITS
|
1055
|
+
RNOCPhone: +1-212-998-3444
|
1056
|
+
RNOCEmail: noc-cosi-arin@nyu.edu
|
1057
|
+
RNOCRef: https://rdap.arin.net/registry/entity/COSI-ARIN
|
1058
|
+
|
1059
|
+
}
|
1060
|
+
}
|
1061
|
+
```
|
1062
|
+
|
1063
|
+
## Timezone API Examples
|
1064
|
+
|
1065
|
+
This section provides usage examples of the `get_timezone_info()` method from the SDK, showcasing how to fetch timezone and time-related data using different query types — IP address, latitude/longitude, and timezone ID.
|
1066
|
+
|
1067
|
+
For full API specifications, refer to the [Timezone API documentation](https://ipgeolocation.io/timezone-api.html#documentation-overview).
|
1068
|
+
|
1069
|
+
### Get Timezone by IP Address
|
1070
|
+
|
1071
|
+
```ruby
|
1072
|
+
time_zone_opts = {
|
1073
|
+
ip: "8.8.8.8"
|
1074
|
+
}
|
1075
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1076
|
+
begin
|
1077
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1078
|
+
p result
|
1079
|
+
rescue IpgeolocationSdk::ApiError => e
|
1080
|
+
puts "Error calling TimezoneApi: #{e}"
|
1081
|
+
end
|
1082
|
+
```
|
1083
|
+
Sample Response
|
1084
|
+
```
|
1085
|
+
class TimeZoneResponse {
|
1086
|
+
ip: 8.8.8.8
|
1087
|
+
|
1088
|
+
location: class TimezoneLocation {
|
1089
|
+
continentCode: NA
|
1090
|
+
continentName: North America
|
1091
|
+
countryCode2: US
|
1092
|
+
countryCode3: USA
|
1093
|
+
countryName: United States
|
1094
|
+
countryNameOfficial: United States of America
|
1095
|
+
isEu: false
|
1096
|
+
stateProv: California
|
1097
|
+
stateCode: US-CA
|
1098
|
+
district: Santa Clara
|
1099
|
+
city: Mountain View
|
1100
|
+
locality: null
|
1101
|
+
zipcode: 94043-1351
|
1102
|
+
latitude: 37.42240
|
1103
|
+
longitude: -122.08421
|
1104
|
+
}
|
1105
|
+
timeZone: class TimezoneDetails {
|
1106
|
+
name: America/Los_Angeles
|
1107
|
+
offset: -8
|
1108
|
+
offsetWithDst: -7
|
1109
|
+
date: 2025-06-23
|
1110
|
+
dateTime: 2025-06-23 02:15:25
|
1111
|
+
dateTimeTxt: Monday, June 23, 2025 02:15:25
|
1112
|
+
dateTimeWti: Mon, 23 Jun 2025 02:15:25 -0700
|
1113
|
+
dateTimeYmd: 2025-06-23T02:15:25-0700
|
1114
|
+
dateTimeUnix: 1.750670125437E9
|
1115
|
+
time24: 02:15:25
|
1116
|
+
time12: 02:15:25 AM
|
1117
|
+
week: 26
|
1118
|
+
month: 6
|
1119
|
+
year: 2025
|
1120
|
+
yearAbbr: 25
|
1121
|
+
isDst: true
|
1122
|
+
dstSavings: 1
|
1123
|
+
dstExists: true
|
1124
|
+
dstStart: class TimezoneDetailDstStart {
|
1125
|
+
utcTime: 2025-03-09 TIME 10
|
1126
|
+
duration: +1H
|
1127
|
+
gap: true
|
1128
|
+
dateTimeAfter: 2025-03-09 TIME 03
|
1129
|
+
dateTimeBefore: 2025-03-09 TIME 02
|
1130
|
+
overlap: false
|
1131
|
+
}
|
1132
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1133
|
+
utcTime: 2025-11-02 TIME 09
|
1134
|
+
duration: -1H
|
1135
|
+
gap: false
|
1136
|
+
dateTimeAfter: 2025-11-02 TIME 01
|
1137
|
+
dateTimeBefore: 2025-11-02 TIME 02
|
1138
|
+
overlap: true
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
}
|
1142
|
+
```
|
1143
|
+
### Get Timezone by Timezone Name
|
1144
|
+
|
1145
|
+
```ruby
|
1146
|
+
time_zone_opts = {
|
1147
|
+
tz: "Europe/London"
|
1148
|
+
}
|
1149
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1150
|
+
begin
|
1151
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1152
|
+
p result
|
1153
|
+
rescue IpgeolocationSdk::ApiError => e
|
1154
|
+
puts "Error calling TimezoneApi: #{e}"
|
1155
|
+
end
|
1156
|
+
```
|
1157
|
+
Sample Response
|
1158
|
+
```
|
1159
|
+
class TimeZoneResponse {
|
1160
|
+
timeZone: class TimezoneDetails {
|
1161
|
+
name: Europe/London
|
1162
|
+
offset: 0
|
1163
|
+
offsetWithDst: 1
|
1164
|
+
date: 2025-06-23
|
1165
|
+
dateTime: 2025-06-23 10:25:01
|
1166
|
+
dateTimeTxt: Monday, June 23, 2025 10:25:01
|
1167
|
+
dateTimeWti: Mon, 23 Jun 2025 10:25:01 +0100
|
1168
|
+
dateTimeYmd: 2025-06-23T10:25:01+0100
|
1169
|
+
dateTimeUnix: 1.750670701706E9
|
1170
|
+
time24: 10:25:01
|
1171
|
+
time12: 10:25:01 AM
|
1172
|
+
week: 26
|
1173
|
+
month: 6
|
1174
|
+
year: 2025
|
1175
|
+
yearAbbr: 25
|
1176
|
+
isDst: true
|
1177
|
+
dstSavings: 1
|
1178
|
+
dstExists: true
|
1179
|
+
dstStart: class TimezoneDetailDstStart {
|
1180
|
+
utcTime: 2025-03-30 TIME 01
|
1181
|
+
duration: +1H
|
1182
|
+
gap: true
|
1183
|
+
dateTimeAfter: 2025-03-30 TIME 02
|
1184
|
+
dateTimeBefore: 2025-03-30 TIME 01
|
1185
|
+
overlap: false
|
1186
|
+
}
|
1187
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1188
|
+
utcTime: 2025-10-26 TIME 01
|
1189
|
+
duration: -1H
|
1190
|
+
gap: false
|
1191
|
+
dateTimeAfter: 2025-10-26 TIME 01
|
1192
|
+
dateTimeBefore: 2025-10-26 TIME 02
|
1193
|
+
overlap: true
|
1194
|
+
}
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
```
|
1198
|
+
### Get Timezone from Any Address
|
1199
|
+
|
1200
|
+
```ruby
|
1201
|
+
time_zone_opts = {
|
1202
|
+
location: "Munich, Germany"
|
1203
|
+
}
|
1204
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1205
|
+
begin
|
1206
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1207
|
+
p result
|
1208
|
+
rescue IpgeolocationSdk::ApiError => e
|
1209
|
+
puts "Error calling TimezoneApi: #{e}"
|
1210
|
+
end
|
1211
|
+
```
|
1212
|
+
Sample Response
|
1213
|
+
```
|
1214
|
+
class TimeZoneResponse {
|
1215
|
+
location: class TimezoneLocation {
|
1216
|
+
locationString: Munich, Germany
|
1217
|
+
countryName: Germany
|
1218
|
+
stateProv: Bavaria
|
1219
|
+
city: Munich
|
1220
|
+
locality:
|
1221
|
+
latitude: 48.13711
|
1222
|
+
longitude: 11.57538
|
1223
|
+
}
|
1224
|
+
timeZone: class TimezoneDetails {
|
1225
|
+
name: Europe/Berlin
|
1226
|
+
offset: 1
|
1227
|
+
offsetWithDst: 2
|
1228
|
+
date: 2025-06-23
|
1229
|
+
dateTime: 2025-06-23 11:35:23
|
1230
|
+
dateTimeTxt: Monday, June 23, 2025 11:35:23
|
1231
|
+
dateTimeWti: Mon, 23 Jun 2025 11:35:23 +0200
|
1232
|
+
dateTimeYmd: 2025-06-23T11:35:23+0200
|
1233
|
+
dateTimeUnix: 1.750671323755E9
|
1234
|
+
time24: 11:35:23
|
1235
|
+
time12: 11:35:23 AM
|
1236
|
+
week: 26
|
1237
|
+
month: 6
|
1238
|
+
year: 2025
|
1239
|
+
yearAbbr: 25
|
1240
|
+
isDst: true
|
1241
|
+
dstSavings: 1
|
1242
|
+
dstExists: true
|
1243
|
+
dstStart: class TimezoneDetailDstStart {
|
1244
|
+
utcTime: 2025-03-30 TIME 01
|
1245
|
+
duration: +1H
|
1246
|
+
gap: true
|
1247
|
+
dateTimeAfter: 2025-03-30 TIME 03
|
1248
|
+
dateTimeBefore: 2025-03-30 TIME 02
|
1249
|
+
overlap: false
|
1250
|
+
}
|
1251
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1252
|
+
utcTime: 2025-10-26 TIME 01
|
1253
|
+
duration: -1H
|
1254
|
+
gap: false
|
1255
|
+
dateTimeAfter: 2025-10-26 TIME 02
|
1256
|
+
dateTimeBefore: 2025-10-26 TIME 03
|
1257
|
+
overlap: true
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
}
|
1261
|
+
```
|
1262
|
+
### Get Timezone from Location Coordinates
|
1263
|
+
|
1264
|
+
```ruby
|
1265
|
+
time_zone_opts = {
|
1266
|
+
lat: 48.13711,
|
1267
|
+
long: 11.57538
|
1268
|
+
}
|
1269
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1270
|
+
begin
|
1271
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1272
|
+
p result
|
1273
|
+
rescue IpgeolocationSdk::ApiError => e
|
1274
|
+
puts "Error calling TimezoneApi: #{e}"
|
1275
|
+
end
|
1276
|
+
```
|
1277
|
+
Sample Response
|
1278
|
+
```
|
1279
|
+
class TimeZoneResponse {
|
1280
|
+
timeZone: class TimezoneDetails {
|
1281
|
+
name: Europe/Paris
|
1282
|
+
offset: 1
|
1283
|
+
offsetWithDst: 2
|
1284
|
+
date: 2025-06-23
|
1285
|
+
dateTime: 2025-06-23 11:53:31
|
1286
|
+
dateTimeTxt: Monday, June 23, 2025 11:53:31
|
1287
|
+
dateTimeWti: Mon, 23 Jun 2025 11:53:31 +0200
|
1288
|
+
dateTimeYmd: 2025-06-23T11:53:31+0200
|
1289
|
+
dateTimeUnix: 1.750672411295E9
|
1290
|
+
time24: 11:53:31
|
1291
|
+
time12: 11:53:31 AM
|
1292
|
+
week: 26
|
1293
|
+
month: 6
|
1294
|
+
year: 2025
|
1295
|
+
yearAbbr: 25
|
1296
|
+
isDst: true
|
1297
|
+
dstSavings: 1
|
1298
|
+
dstExists: true
|
1299
|
+
dstStart: class TimezoneDetailDstStart {
|
1300
|
+
utcTime: 2025-03-30 TIME 01
|
1301
|
+
duration: +1H
|
1302
|
+
gap: true
|
1303
|
+
dateTimeAfter: 2025-03-30 TIME 03
|
1304
|
+
dateTimeBefore: 2025-03-30 TIME 02
|
1305
|
+
overlap: false
|
1306
|
+
}
|
1307
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1308
|
+
utcTime: 2025-10-26 TIME 01
|
1309
|
+
duration: -1H
|
1310
|
+
gap: false
|
1311
|
+
dateTimeAfter: 2025-10-26 TIME 02
|
1312
|
+
dateTimeBefore: 2025-10-26 TIME 03
|
1313
|
+
overlap: true
|
1314
|
+
}
|
1315
|
+
}
|
1316
|
+
}
|
1317
|
+
```
|
1318
|
+
### Get Timezone and Airport Details from IATA Code
|
1319
|
+
|
1320
|
+
```ruby
|
1321
|
+
time_zone_opts = {
|
1322
|
+
iata_code: "ZRH"
|
1323
|
+
}
|
1324
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1325
|
+
begin
|
1326
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1327
|
+
p result
|
1328
|
+
rescue IpgeolocationSdk::ApiError => e
|
1329
|
+
puts "Error calling TimezoneApi: #{e}"
|
1330
|
+
end
|
1331
|
+
```
|
1332
|
+
Sample Response
|
1333
|
+
```
|
1334
|
+
class TimeZoneResponse {
|
1335
|
+
airportDetails: class TimezoneAirport {
|
1336
|
+
type: large_airport
|
1337
|
+
name: Zurich Airport
|
1338
|
+
latitude: 47.45806
|
1339
|
+
longitude: 8.54806
|
1340
|
+
elevationFt: 1417
|
1341
|
+
continentCode: EU
|
1342
|
+
countryCode: CH
|
1343
|
+
stateCode: CH-ZH
|
1344
|
+
city: Zurich
|
1345
|
+
iataCode: ZRH
|
1346
|
+
icaoCode: LSZH
|
1347
|
+
faaCode:
|
1348
|
+
}
|
1349
|
+
timeZone: class TimezoneDetails {
|
1350
|
+
name: Europe/Zurich
|
1351
|
+
offset: 1
|
1352
|
+
offsetWithDst: 2
|
1353
|
+
date: 2025-06-23
|
1354
|
+
dateTime: 2025-06-23 12:24:08
|
1355
|
+
dateTimeTxt: Monday, June 23, 2025 12:24:08
|
1356
|
+
dateTimeWti: Mon, 23 Jun 2025 12:24:08 +0200
|
1357
|
+
dateTimeYmd: 2025-06-23T12:24:08+0200
|
1358
|
+
dateTimeUnix: 1.750674248242E9
|
1359
|
+
time24: 12:24:08
|
1360
|
+
time12: 12:24:08 PM
|
1361
|
+
week: 26
|
1362
|
+
month: 6
|
1363
|
+
year: 2025
|
1364
|
+
yearAbbr: 25
|
1365
|
+
isDst: true
|
1366
|
+
dstSavings: 1
|
1367
|
+
dstExists: true
|
1368
|
+
dstStart: class TimezoneDetailDstStart {
|
1369
|
+
utcTime: 2025-03-30 TIME 01
|
1370
|
+
duration: +1H
|
1371
|
+
gap: true
|
1372
|
+
dateTimeAfter: 2025-03-30 TIME 03
|
1373
|
+
dateTimeBefore: 2025-03-30 TIME 02
|
1374
|
+
overlap: false
|
1375
|
+
}
|
1376
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1377
|
+
utcTime: 2025-10-26 TIME 01
|
1378
|
+
duration: -1H
|
1379
|
+
gap: false
|
1380
|
+
dateTimeAfter: 2025-10-26 TIME 02
|
1381
|
+
dateTimeBefore: 2025-10-26 TIME 03
|
1382
|
+
overlap: true
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
}
|
1386
|
+
```
|
1387
|
+
Similarly, you can fetch Airport Details and Timezone from using any ICAO code as well
|
1388
|
+
|
1389
|
+
### Get Timezone and City Details from UN/LOCODE
|
1390
|
+
|
1391
|
+
```ruby
|
1392
|
+
time_zone_opts = {
|
1393
|
+
lo_code: "ESBCN"
|
1394
|
+
}
|
1395
|
+
time_zone_instance = IpgeolocationSdk::TimezoneApi.new
|
1396
|
+
begin
|
1397
|
+
result = time_zone_instance.get_timezone_info(time_zone_opts)
|
1398
|
+
p result
|
1399
|
+
rescue IpgeolocationSdk::ApiError => e
|
1400
|
+
puts "Error calling TimezoneApi: #{e}"
|
1401
|
+
end
|
1402
|
+
```
|
1403
|
+
Sample Response
|
1404
|
+
```
|
1405
|
+
class TimeZoneResponse {
|
1406
|
+
loCodeDetails: class TimezoneLocode {
|
1407
|
+
loCode: ESBCN
|
1408
|
+
city: Barcelona
|
1409
|
+
stateCode:
|
1410
|
+
countryCode: ES
|
1411
|
+
countryName:
|
1412
|
+
locationType: Port, Rail Terminal, Road Terminal, Airport, Postal Exchange
|
1413
|
+
latitude: 41.38289
|
1414
|
+
longitude: 2.17743
|
1415
|
+
}
|
1416
|
+
timeZone: class TimezoneDetails {
|
1417
|
+
name: Europe/Madrid
|
1418
|
+
offset: 1
|
1419
|
+
offsetWithDst: 2
|
1420
|
+
date: 2025-06-23
|
1421
|
+
dateTime: 2025-06-23 12:32:55
|
1422
|
+
dateTimeTxt: Monday, June 23, 2025 12:32:55
|
1423
|
+
dateTimeWti: Mon, 23 Jun 2025 12:32:55 +0200
|
1424
|
+
dateTimeYmd: 2025-06-23T12:32:55+0200
|
1425
|
+
dateTimeUnix: 1.750674775033E9
|
1426
|
+
time24: 12:32:55
|
1427
|
+
time12: 12:32:55 PM
|
1428
|
+
week: 26
|
1429
|
+
month: 6
|
1430
|
+
year: 2025
|
1431
|
+
yearAbbr: 25
|
1432
|
+
isDst: true
|
1433
|
+
dstSavings: 1
|
1434
|
+
dstExists: true
|
1435
|
+
dstStart: class TimezoneDetailDstStart {
|
1436
|
+
utcTime: 2025-03-30 TIME 01
|
1437
|
+
duration: +1H
|
1438
|
+
gap: true
|
1439
|
+
dateTimeAfter: 2025-03-30 TIME 03
|
1440
|
+
dateTimeBefore: 2025-03-30 TIME 02
|
1441
|
+
overlap: false
|
1442
|
+
}
|
1443
|
+
dstEnd: class TimezoneDetailDstEnd {
|
1444
|
+
utcTime: 2025-10-26 TIME 01
|
1445
|
+
duration: -1H
|
1446
|
+
gap: false
|
1447
|
+
dateTimeAfter: 2025-10-26 TIME 02
|
1448
|
+
dateTimeBefore: 2025-10-26 TIME 03
|
1449
|
+
overlap: true
|
1450
|
+
}
|
1451
|
+
}
|
1452
|
+
}
|
1453
|
+
```
|
1454
|
+
|
1455
|
+
## Timezone Converter Examples
|
1456
|
+
|
1457
|
+
This section provides usage examples of the `convert_time_between_timezones()` method from the SDK. The Timezone Converter API allows you to convert a specific time from one timezone to another using timezone identifiers and optional date/time inputs.
|
1458
|
+
|
1459
|
+
For more details, refer to official documentation: [Timezone Converter API](https://ipgeolocation.io/timezone-api.html#convert-time-bw-time-zones).
|
1460
|
+
|
1461
|
+
### Convert Current Time from One Timezone to Another
|
1462
|
+
|
1463
|
+
```ruby
|
1464
|
+
time_conversion_opts = {
|
1465
|
+
tz_to: 'Asia/Tokyo',
|
1466
|
+
tz_from: 'America/New_York',
|
1467
|
+
# lat_from: 24.8607,
|
1468
|
+
# long_from: 67.0011,
|
1469
|
+
# lat_to: 40.7128,
|
1470
|
+
# long_to: -74.0060,
|
1471
|
+
# location_from: 'Karachi',
|
1472
|
+
# location_to: 'New York',
|
1473
|
+
# icao_from: 'OPKC',
|
1474
|
+
# icao_to: 'KJFK',
|
1475
|
+
# iata_from: 'KHI',
|
1476
|
+
# iata_to: 'JFK',
|
1477
|
+
# locode_from: 'PKKHI',
|
1478
|
+
# locode_to: 'USNYC'
|
1479
|
+
}
|
1480
|
+
time_conversion_instance = IpgeolocationSdk::TimeConversionApi.new
|
1481
|
+
begin
|
1482
|
+
result = time_conversion_instance.convert_time_between_timezones(time_conversion_opts)
|
1483
|
+
p result
|
1484
|
+
rescue IpgeolocationSdk::ApiError => e
|
1485
|
+
puts "Error calling TimeConversionApi: #{e}"
|
1486
|
+
end
|
1487
|
+
```
|
1488
|
+
Sample Response
|
1489
|
+
```
|
1490
|
+
class TimeConversionResponse {
|
1491
|
+
originalTime: 2024-12-08 11:00
|
1492
|
+
convertedTime: 2024-12-09 01:00:00
|
1493
|
+
diffHour: 14.0
|
1494
|
+
diffMin: 840
|
1495
|
+
}
|
1496
|
+
```
|
1497
|
+
Similarly, you can convert time from any timezone to another timezone using location coordinates (Latitude and Longitude), location addresses, IATA codes, ICAO codes and UN/LOCODE.
|
1498
|
+
|
1499
|
+
## User Agent API Examples
|
1500
|
+
|
1501
|
+
This section provides usage examples of the `get_user_agent_details()` method from the SDK. The User Agent API extracts and classifies information from user agent strings, including browser, engine, device, OS, and type metadata.
|
1502
|
+
|
1503
|
+
For full explanation, visit the [User Agent API documentation](https://ipgeolocation.io/user-agent-api.html#documentation-overview).
|
1504
|
+
|
1505
|
+
### Parse a Basic User Agent String
|
1506
|
+
|
1507
|
+
```ruby
|
1508
|
+
get_user_agent_opts = {
|
1509
|
+
user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/237.84.2.178 Safari/537.36'
|
1510
|
+
}
|
1511
|
+
user_agent_instance = IpgeolocationSdk::UserAgentApi.new
|
1512
|
+
begin
|
1513
|
+
result = user_agent_instance.get_user_agent_details(get_user_agent_opts)
|
1514
|
+
p result
|
1515
|
+
rescue IpgeolocationSdk::ApiError => e
|
1516
|
+
puts "Error calling UserAgentApi: #{e}"
|
1517
|
+
end
|
1518
|
+
```
|
1519
|
+
Sample Response
|
1520
|
+
```
|
1521
|
+
class UserAgentData {
|
1522
|
+
userAgentString: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
|
1523
|
+
name: Chrome
|
1524
|
+
type: Browser
|
1525
|
+
version: 125
|
1526
|
+
versionMajor: 125
|
1527
|
+
device: class UserAgentDataDevice {
|
1528
|
+
name: Desktop
|
1529
|
+
type: Desktop
|
1530
|
+
brand: Unknown
|
1531
|
+
cpu: Intel x86_64
|
1532
|
+
}
|
1533
|
+
engine: class UserAgentDataEngine {
|
1534
|
+
name: Blink
|
1535
|
+
type: Browser
|
1536
|
+
version: 125
|
1537
|
+
versionMajor: 125
|
1538
|
+
}
|
1539
|
+
operatingSystem: class UserAgentDataOperatingSystem {
|
1540
|
+
name: Windows NT
|
1541
|
+
type: Desktop
|
1542
|
+
version: ??
|
1543
|
+
versionMajor: ??
|
1544
|
+
build: ??
|
1545
|
+
}
|
1546
|
+
}
|
1547
|
+
```
|
1548
|
+
If you don't pass any userAgentString, the API will return the data of device's user agent.
|
1549
|
+
|
1550
|
+
## Bulk User Agent Parsing Example
|
1551
|
+
|
1552
|
+
The SDK also supports bulk User Agent parsing using the `parse_bulk_user_agent_strings()` method. This allows parsing multiple user agent strings in a single request. All fields available in single-user-agent parsing are returned per entry.
|
1553
|
+
|
1554
|
+
```ruby
|
1555
|
+
post_user_agent_opts = {
|
1556
|
+
user_agents: ["Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/237.84.2.178 Safari/537.36","Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1"]
|
1557
|
+
}
|
1558
|
+
user_agent_instance = IpgeolocationSdk::UserAgentApi.new
|
1559
|
+
begin
|
1560
|
+
result = user_agent_instance.parse_bulk_user_agent_strings(post_user_agent_opts)
|
1561
|
+
p result
|
1562
|
+
rescue IpgeolocationSdk::ApiError => e
|
1563
|
+
puts "Error calling UserAgentApi: #{e}"
|
1564
|
+
end
|
1565
|
+
```
|
1566
|
+
|
1567
|
+
## Astronomy API Examples
|
1568
|
+
|
1569
|
+
This section provides usage examples of the `get_astronomy_details()` method from the SDK, allowing developers to fetch sun and moon timings and position data based on coordinates, IP, or location string.
|
1570
|
+
|
1571
|
+
Refer to the [official Astronomy API documentation](https://ipgeolocation.io/astronomy-api.html#documentation-overview) for more details.
|
1572
|
+
|
1573
|
+
### Astronomy by Coordinates
|
1574
|
+
|
1575
|
+
```ruby
|
1576
|
+
get_astronomy_opts = {
|
1577
|
+
lat: "40.7128",
|
1578
|
+
long: "-74.0060"
|
1579
|
+
}
|
1580
|
+
astronomy_instance = IpgeolocationSdk::AstronomyApi.new
|
1581
|
+
begin
|
1582
|
+
result = astronomy_instance.get_astronomy_details(get_astronomy_opts)
|
1583
|
+
p result
|
1584
|
+
rescue IpgeolocationSdk::ApiError => e
|
1585
|
+
puts "Error calling AstronomyApi: #{e}"
|
1586
|
+
end
|
1587
|
+
```
|
1588
|
+
Sample Response
|
1589
|
+
```
|
1590
|
+
class AstronomyResponse {
|
1591
|
+
location: class AstronomyLocation {
|
1592
|
+
countryName:
|
1593
|
+
stateProv: New York
|
1594
|
+
city: New York
|
1595
|
+
locality:
|
1596
|
+
latitude: 40.71280
|
1597
|
+
longitude: -74.00600
|
1598
|
+
elevation: 6.0
|
1599
|
+
}
|
1600
|
+
astronomy: class Astronomy {
|
1601
|
+
date: 2025-07-22
|
1602
|
+
currentTime: 05:34:17.046
|
1603
|
+
midNight: 01:02
|
1604
|
+
nightEnd: 03:48
|
1605
|
+
morning: class AstronomyMorning {
|
1606
|
+
astronomicalTwilightBegin: 03:48
|
1607
|
+
astronomicalTwilightEnd: 04:32
|
1608
|
+
nauticalTwilightBegin: 04:32
|
1609
|
+
nauticalTwilightEnd: 05:12
|
1610
|
+
civilTwilightBegin: 05:12
|
1611
|
+
civilTwilightEnd: 05:43
|
1612
|
+
blueHourBegin: 04:59
|
1613
|
+
blueHourEnd: 05:24
|
1614
|
+
goldenHourBegin: 05:24
|
1615
|
+
goldenHourEnd: 06:23
|
1616
|
+
}
|
1617
|
+
sunrise: 05:43
|
1618
|
+
sunset: 20:21
|
1619
|
+
evening: class AstronomyEvening {
|
1620
|
+
goldenHourBegin: 19:41
|
1621
|
+
goldenHourEnd: 20:40
|
1622
|
+
blueHourBegin: 20:40
|
1623
|
+
blueHourEnd: 21:05
|
1624
|
+
civilTwilightBegin: 20:21
|
1625
|
+
civilTwilightEnd: 20:52
|
1626
|
+
nauticalTwilightBegin: 20:52
|
1627
|
+
nauticalTwilightEnd: 21:31
|
1628
|
+
astronomicalTwilightBegin: 21:31
|
1629
|
+
astronomicalTwilightEnd: 22:16
|
1630
|
+
}
|
1631
|
+
nightBegin: 22:16
|
1632
|
+
sunStatus: -
|
1633
|
+
solarNoon: 13:02
|
1634
|
+
dayLength: 14:37
|
1635
|
+
sunAltitude: -2.4240905951150817
|
1636
|
+
sunDistance: 152012050.75662628
|
1637
|
+
sunAzimuth: 60.53270916713848
|
1638
|
+
moonPhase: WANING_CRESCENT
|
1639
|
+
moonrise: 02:48
|
1640
|
+
moonset: 19:10
|
1641
|
+
moonStatus: -
|
1642
|
+
moonAltitude: 26.687264834949556
|
1643
|
+
moonDistance: 369857.6483476412
|
1644
|
+
moonAzimuth: 74.22460131532307
|
1645
|
+
moonParallacticAngle: -56.08124322972331
|
1646
|
+
moonIlluminationPercentage: -7.41
|
1647
|
+
moonAngle: 328.4181377849406
|
1648
|
+
}
|
1649
|
+
}
|
1650
|
+
```
|
1651
|
+
### Astronomy by IP Address
|
1652
|
+
```ruby
|
1653
|
+
get_astronomy_opts = {
|
1654
|
+
ip: "8.8.8.8"
|
1655
|
+
}
|
1656
|
+
astronomy_instance = IpgeolocationSdk::AstronomyApi.new
|
1657
|
+
begin
|
1658
|
+
result = astronomy_instance.get_astronomy_details(get_astronomy_opts)
|
1659
|
+
p result
|
1660
|
+
rescue IpgeolocationSdk::ApiError => e
|
1661
|
+
puts "Error calling AstronomyApi: #{e}"
|
1662
|
+
end
|
1663
|
+
```
|
1664
|
+
Sample Response
|
1665
|
+
```
|
1666
|
+
class AstronomyResponse {
|
1667
|
+
ip: 8.8.8.8
|
1668
|
+
location: class AstronomyLocation {
|
1669
|
+
continentCode: NA
|
1670
|
+
continentName: North America
|
1671
|
+
countryCode2: US
|
1672
|
+
countryCode3: USA
|
1673
|
+
countryName: United States
|
1674
|
+
countryNameOfficial: United States of America
|
1675
|
+
isEu: false
|
1676
|
+
stateProv: California
|
1677
|
+
stateCode: US-CA
|
1678
|
+
district: Santa Clara
|
1679
|
+
city: Mountain View
|
1680
|
+
locality: Charleston Terrace
|
1681
|
+
zipcode: 94043-1351
|
1682
|
+
latitude: 37.42240
|
1683
|
+
longitude: -122.08421
|
1684
|
+
elevation: 3.0
|
1685
|
+
}
|
1686
|
+
astronomy: class Astronomy {
|
1687
|
+
date: 2025-07-22
|
1688
|
+
currentTime: 02:36:01.027
|
1689
|
+
midNight: 01:15
|
1690
|
+
nightEnd: 04:18
|
1691
|
+
morning: class AstronomyMorning {
|
1692
|
+
astronomicalTwilightBegin: 04:18
|
1693
|
+
astronomicalTwilightEnd: 04:58
|
1694
|
+
nauticalTwilightBegin: 04:58
|
1695
|
+
nauticalTwilightEnd: 05:35
|
1696
|
+
civilTwilightBegin: 05:35
|
1697
|
+
civilTwilightEnd: 06:04
|
1698
|
+
blueHourBegin: 05:23
|
1699
|
+
blueHourEnd: 05:47
|
1700
|
+
goldenHourBegin: 05:47
|
1701
|
+
goldenHourEnd: 06:42
|
1702
|
+
}
|
1703
|
+
sunrise: 06:04
|
1704
|
+
sunset: 20:24
|
1705
|
+
evening: class AstronomyEvening {
|
1706
|
+
goldenHourBegin: 19:46
|
1707
|
+
goldenHourEnd: 20:42
|
1708
|
+
blueHourBegin: 20:42
|
1709
|
+
blueHourEnd: 21:05
|
1710
|
+
civilTwilightBegin: 20:24
|
1711
|
+
civilTwilightEnd: 20:54
|
1712
|
+
nauticalTwilightBegin: 20:54
|
1713
|
+
nauticalTwilightEnd: 21:30
|
1714
|
+
astronomicalTwilightBegin: 21:30
|
1715
|
+
astronomicalTwilightEnd: 22:10
|
1716
|
+
}
|
1717
|
+
nightBegin: 22:10
|
1718
|
+
sunStatus: -
|
1719
|
+
solarNoon: 13:14
|
1720
|
+
dayLength: 14:20
|
1721
|
+
sunAltitude: -29.312204242565592
|
1722
|
+
sunDistance: 152012050.7566263
|
1723
|
+
sunAzimuth: 21.915241201213632
|
1724
|
+
moonPhase: WANING_CRESCENT
|
1725
|
+
moonrise: 03:23
|
1726
|
+
moonset: 19:16
|
1727
|
+
moonStatus: -
|
1728
|
+
moonAltitude: -6.780866431657464
|
1729
|
+
moonDistance: 369859.5847016905
|
1730
|
+
moonAzimuth: 45.928379972251605
|
1731
|
+
moonParallacticAngle: -40.47546867785306
|
1732
|
+
moonIlluminationPercentage: -7.40
|
1733
|
+
moonAngle: 328.43423626935555
|
1734
|
+
}
|
1735
|
+
}
|
1736
|
+
```
|
1737
|
+
|
1738
|
+
### Astronomy by Location String
|
1739
|
+
```ruby
|
1740
|
+
get_astronomy_opts = {
|
1741
|
+
location: "Milan, Italy"
|
1742
|
+
}
|
1743
|
+
astronomy_instance = IpgeolocationSdk::AstronomyApi.new
|
1744
|
+
begin
|
1745
|
+
result = astronomy_instance.get_astronomy_details(get_astronomy_opts)
|
1746
|
+
p result
|
1747
|
+
rescue IpgeolocationSdk::ApiError => e
|
1748
|
+
puts "Error calling AstronomyApi: #{e}"
|
1749
|
+
end
|
1750
|
+
```
|
1751
|
+
Sample Response
|
1752
|
+
```
|
1753
|
+
class AstronomyResponse {
|
1754
|
+
location: class AstronomyLocation {
|
1755
|
+
locationString: Milan, Italy
|
1756
|
+
countryName: Italy
|
1757
|
+
stateProv: Lombardy
|
1758
|
+
city: Milan
|
1759
|
+
locality:
|
1760
|
+
latitude: 45.46419
|
1761
|
+
longitude: 9.18963
|
1762
|
+
elevation: 122.0
|
1763
|
+
}
|
1764
|
+
astronomy: class Astronomy {
|
1765
|
+
date: 2025-07-22
|
1766
|
+
currentTime: 11:37:28.787
|
1767
|
+
midNight: 01:29
|
1768
|
+
nightEnd: 03:39
|
1769
|
+
morning: class AstronomyMorning {
|
1770
|
+
astronomicalTwilightBegin: 03:39
|
1771
|
+
astronomicalTwilightEnd: 04:35
|
1772
|
+
nauticalTwilightBegin: 04:35
|
1773
|
+
nauticalTwilightEnd: 05:21
|
1774
|
+
civilTwilightBegin: 05:21
|
1775
|
+
civilTwilightEnd: 05:54
|
1776
|
+
blueHourBegin: 05:06
|
1777
|
+
blueHourEnd: 05:35
|
1778
|
+
goldenHourBegin: 05:35
|
1779
|
+
goldenHourEnd: 06:40
|
1780
|
+
}
|
1781
|
+
sunrise: 05:54
|
1782
|
+
sunset: 21:04
|
1783
|
+
evening: class AstronomyEvening {
|
1784
|
+
goldenHourBegin: 20:19
|
1785
|
+
goldenHourEnd: 21:24
|
1786
|
+
blueHourBegin: 21:24
|
1787
|
+
blueHourEnd: 21:52
|
1788
|
+
civilTwilightBegin: 21:04
|
1789
|
+
civilTwilightEnd: 21:38
|
1790
|
+
nauticalTwilightBegin: 21:38
|
1791
|
+
nauticalTwilightEnd: 22:23
|
1792
|
+
astronomicalTwilightBegin: 22:23
|
1793
|
+
astronomicalTwilightEnd: 23:18
|
1794
|
+
}
|
1795
|
+
nightBegin: 23:18
|
1796
|
+
sunStatus: -
|
1797
|
+
solarNoon: 13:29
|
1798
|
+
dayLength: 15:10
|
1799
|
+
sunAltitude: 55.76507063803926
|
1800
|
+
sunDistance: 152012050.7566263
|
1801
|
+
sunAzimuth: 128.26574664275847
|
1802
|
+
moonPhase: WANING_CRESCENT
|
1803
|
+
moonrise: 02:36
|
1804
|
+
moonset: 19:49
|
1805
|
+
moonStatus: -
|
1806
|
+
moonAltitude: 72.39158071193661
|
1807
|
+
moonDistance: 369861.22005060845
|
1808
|
+
moonAzimuth: 197.31311454833428
|
1809
|
+
moonParallacticAngle: 13.735730743087668
|
1810
|
+
moonIlluminationPercentage: -7.39
|
1811
|
+
moonAngle: 328.44782327106236
|
1812
|
+
}
|
1813
|
+
}
|
1814
|
+
```
|
1815
|
+
### Astronomy for Specific Date
|
1816
|
+
```ruby
|
1817
|
+
get_astronomy_opts = {
|
1818
|
+
date: "2025-01-01",
|
1819
|
+
lat: "-27.47000",
|
1820
|
+
long: "153.02000"
|
1821
|
+
}
|
1822
|
+
astronomy_instance = IpgeolocationSdk::AstronomyApi.new
|
1823
|
+
begin
|
1824
|
+
result = astronomy_instance.get_astronomy_details(get_astronomy_opts)
|
1825
|
+
p result
|
1826
|
+
rescue IpgeolocationSdk::ApiError => e
|
1827
|
+
puts "Error calling AstronomyApi: #{e}"
|
1828
|
+
end
|
1829
|
+
```
|
1830
|
+
Sample Response
|
1831
|
+
```
|
1832
|
+
class AstronomyResponse {
|
1833
|
+
location: class AstronomyLocation {
|
1834
|
+
countryName: Australia
|
1835
|
+
stateProv: Queensland
|
1836
|
+
city: Brisbane
|
1837
|
+
locality: Brisbane
|
1838
|
+
latitude: -27.47000
|
1839
|
+
longitude: 153.02000
|
1840
|
+
elevation:
|
1841
|
+
}
|
1842
|
+
astronomy: class Astronomy {
|
1843
|
+
date: 2025-01-01
|
1844
|
+
currentTime: 19:45:17.561
|
1845
|
+
midNight: 23:51
|
1846
|
+
nightEnd: 03:24
|
1847
|
+
morning: class AstronomyMorning {
|
1848
|
+
astronomicalTwilightBegin: 03:24
|
1849
|
+
astronomicalTwilightEnd: 03:57
|
1850
|
+
nauticalTwilightBegin: 03:57
|
1851
|
+
nauticalTwilightEnd: 04:29
|
1852
|
+
civilTwilightBegin: 04:29
|
1853
|
+
civilTwilightEnd: 04:56
|
1854
|
+
blueHourBegin: 04:19
|
1855
|
+
blueHourEnd: 04:40
|
1856
|
+
goldenHourBegin: 04:40
|
1857
|
+
goldenHourEnd: 05:30
|
1858
|
+
}
|
1859
|
+
sunrise: 04:56
|
1860
|
+
sunset: 18:46
|
1861
|
+
evening: class AstronomyEvening {
|
1862
|
+
goldenHourBegin: 18:12
|
1863
|
+
goldenHourEnd: 19:02
|
1864
|
+
blueHourBegin: 19:02
|
1865
|
+
blueHourEnd: 19:23
|
1866
|
+
civilTwilightBegin: 18:46
|
1867
|
+
civilTwilightEnd: 19:13
|
1868
|
+
nauticalTwilightBegin: 19:13
|
1869
|
+
nauticalTwilightEnd: 19:45
|
1870
|
+
astronomicalTwilightBegin: 19:45
|
1871
|
+
astronomicalTwilightEnd: 20:18
|
1872
|
+
}
|
1873
|
+
nightBegin: 20:18
|
1874
|
+
sunStatus: -
|
1875
|
+
solarNoon: 11:51
|
1876
|
+
dayLength: 13:50
|
1877
|
+
sunAltitude: -12.059617608402677
|
1878
|
+
sunDistance: 147102938.88036567
|
1879
|
+
sunAzimuth: 235.897971324645
|
1880
|
+
moonPhase: NEW_MOON
|
1881
|
+
moonrise: 05:42
|
1882
|
+
moonset: 20:08
|
1883
|
+
moonStatus: -
|
1884
|
+
moonAltitude: 4.6701693782344345
|
1885
|
+
moonDistance: 380596.5823950267
|
1886
|
+
moonAzimuth: 244.56945849604378
|
1887
|
+
moonParallacticAngle: 118.21976701203934
|
1888
|
+
moonIlluminationPercentage: 2.49
|
1889
|
+
moonAngle: 18.156495178599695
|
1890
|
+
}
|
1891
|
+
}
|
1892
|
+
```
|
1893
|
+
|
1894
|
+
### Astronomy in Different Language
|
1895
|
+
You can also get Astronomy Data in other languages as well. Only paid subscriptions can access this feature.
|
1896
|
+
```ruby
|
1897
|
+
get_astronomy_opts = {
|
1898
|
+
ip: "1.1.1.1",
|
1899
|
+
lang: "fr"
|
1900
|
+
}
|
1901
|
+
astronomy_instance = IpgeolocationSdk::AstronomyApi.new
|
1902
|
+
begin
|
1903
|
+
result = astronomy_instance.get_astronomy_details(get_astronomy_opts)
|
1904
|
+
p result
|
1905
|
+
rescue IpgeolocationSdk::ApiError => e
|
1906
|
+
puts "Error calling AstronomyApi: #{e}"
|
1907
|
+
end
|
1908
|
+
```
|
1909
|
+
Sample Response
|
1910
|
+
```
|
1911
|
+
class AstronomyResponse {
|
1912
|
+
ip: 1.1.1.1
|
1913
|
+
location: class AstronomyLocation {
|
1914
|
+
continentCode: OC
|
1915
|
+
continentName: Océanie
|
1916
|
+
countryCode2: AU
|
1917
|
+
countryCode3: AUS
|
1918
|
+
countryName: Australie
|
1919
|
+
countryNameOfficial:
|
1920
|
+
isEu: false
|
1921
|
+
stateProv: Queensland
|
1922
|
+
stateCode: AU-QLD
|
1923
|
+
district: Brisbane
|
1924
|
+
city: Brisbane Sud
|
1925
|
+
locality:
|
1926
|
+
zipcode: 4101
|
1927
|
+
latitude: -27.47306
|
1928
|
+
longitude: 153.01421
|
1929
|
+
elevation:
|
1930
|
+
}
|
1931
|
+
astronomy: class Astronomy {
|
1932
|
+
date: 2025-07-22
|
1933
|
+
currentTime: 19:54:32.920
|
1934
|
+
midNight: 23:54
|
1935
|
+
nightEnd: 05:13
|
1936
|
+
morning: class AstronomyMorning {
|
1937
|
+
astronomicalTwilightBegin: 05:13
|
1938
|
+
astronomicalTwilightEnd: 05:41
|
1939
|
+
nauticalTwilightBegin: 05:41
|
1940
|
+
nauticalTwilightEnd: 06:09
|
1941
|
+
civilTwilightBegin: 06:09
|
1942
|
+
civilTwilightEnd: 06:34
|
1943
|
+
blueHourBegin: 06:00
|
1944
|
+
blueHourEnd: 06:19
|
1945
|
+
goldenHourBegin: 06:19
|
1946
|
+
goldenHourEnd: 07:08
|
1947
|
+
}
|
1948
|
+
sunrise: 06:34
|
1949
|
+
sunset: 17:14
|
1950
|
+
evening: class AstronomyEvening {
|
1951
|
+
goldenHourBegin: 16:40
|
1952
|
+
goldenHourEnd: 17:29
|
1953
|
+
blueHourBegin: 17:29
|
1954
|
+
blueHourEnd: 17:49
|
1955
|
+
civilTwilightBegin: 17:14
|
1956
|
+
civilTwilightEnd: 17:39
|
1957
|
+
nauticalTwilightBegin: 17:39
|
1958
|
+
nauticalTwilightEnd: 18:07
|
1959
|
+
astronomicalTwilightBegin: 18:07
|
1960
|
+
astronomicalTwilightEnd: 18:35
|
1961
|
+
}
|
1962
|
+
nightBegin: 18:35
|
1963
|
+
sunStatus: -
|
1964
|
+
solarNoon: 11:54
|
1965
|
+
dayLength: 10:39
|
1966
|
+
sunAltitude: -35.15165719378359
|
1967
|
+
sunDistance: 152012050.75662628
|
1968
|
+
sunAzimuth: 276.2757088601843
|
1969
|
+
moonPhase: WANING_CRESCENT
|
1970
|
+
moonrise: 04:04
|
1971
|
+
moonset: 14:19
|
1972
|
+
moonStatus: -
|
1973
|
+
moonAltitude: -66.8771626746063
|
1974
|
+
moonDistance: 369880.37618917384
|
1975
|
+
moonAzimuth: 278.66762618741274
|
1976
|
+
moonParallacticAngle: 93.79636599869248
|
1977
|
+
moonIlluminationPercentage: -7.32
|
1978
|
+
moonAngle: 328.6063710418327
|
1979
|
+
}
|
1980
|
+
}
|
1981
|
+
```
|
1982
|
+
## Abuse Contact API Examples
|
1983
|
+
This section demonstrates how to use the `get_abuse_contact_info()` method of the AbuseContact API. This API helps security teams, hosting providers, and compliance professionals quickly identify the correct abuse reporting contacts for any IPv4 or IPv6 address. You can retrieve data like the responsible organization, role, contact emails, phone numbers, and address to take appropriate mitigation action against abusive or malicious activity.
|
1984
|
+
> **Note**: Abuse Contact API is only available in Advanced Plan
|
1985
|
+
|
1986
|
+
Refer to the official [Abuse Contact API documentation](https://ipgeolocation.io/ip-abuse-contact-api.html#documentation-overview) for details on all available fields.
|
1987
|
+
### Lookup Abuse Contact by IP
|
1988
|
+
```ruby
|
1989
|
+
abuse_opts = {
|
1990
|
+
ip: '1.0.0.0',
|
1991
|
+
}
|
1992
|
+
abuse_instance = IpgeolocationSdk::AbuseContactApi.new
|
1993
|
+
begin
|
1994
|
+
result = abuse_instance.get_abuse_contact_info(abuse_opts)
|
1995
|
+
p result
|
1996
|
+
rescue IpgeolocationSdk::ApiError => e
|
1997
|
+
puts "Error calling AbuseContactApi: #{e}"
|
1998
|
+
end
|
1999
|
+
```
|
2000
|
+
Sample Response:
|
2001
|
+
```
|
2002
|
+
class AbuseResponse {
|
2003
|
+
ip: 1.0.0.0
|
2004
|
+
abuse: class Abuse {
|
2005
|
+
route: 1.0.0.0/24
|
2006
|
+
country: AU
|
2007
|
+
handle: IRT-APNICRANDNET-AU
|
2008
|
+
name: IRT-APNICRANDNET-AU
|
2009
|
+
organization:
|
2010
|
+
role: abuse
|
2011
|
+
kind: group
|
2012
|
+
address: PO Box 3646
|
2013
|
+
South Brisbane, QLD 4101
|
2014
|
+
Australia
|
2015
|
+
emails: [helpdesk@apnic.net]
|
2016
|
+
phoneNumbers: [+61 7 3858 3100]
|
2017
|
+
}
|
2018
|
+
}
|
2019
|
+
```
|
2020
|
+
|
2021
|
+
### Lookup Abuse Contact with Specific Fields
|
2022
|
+
```ruby
|
2023
|
+
abuse_opts = {
|
2024
|
+
ip: '1.2.3.4',
|
2025
|
+
fields: 'abuse.role,abuse.emails',
|
2026
|
+
}
|
2027
|
+
abuse_instance = IpgeolocationSdk::AbuseContactApi.new
|
2028
|
+
begin
|
2029
|
+
result = abuse_instance.get_abuse_contact_info(abuse_opts)
|
2030
|
+
p result
|
2031
|
+
rescue IpgeolocationSdk::ApiError => e
|
2032
|
+
puts "Error calling AbuseContactApi: #{e}"
|
2033
|
+
end
|
2034
|
+
```
|
2035
|
+
Sample Response:
|
2036
|
+
```
|
2037
|
+
class AbuseResponse {
|
2038
|
+
ip: 1.2.3.4
|
2039
|
+
abuse: class Abuse {
|
2040
|
+
role: abuse
|
2041
|
+
emails: [helpdesk@apnic.net]
|
2042
|
+
}
|
2043
|
+
}
|
2044
|
+
```
|
2045
|
+
### Lookup Abuse Contact while Excluding Fields
|
2046
|
+
```ruby
|
2047
|
+
abuse_opts = {
|
2048
|
+
ip: '9.9.9.9',
|
2049
|
+
excludes: 'abuse.handle,abuse.emails',
|
2050
|
+
}
|
2051
|
+
abuse_instance = IpgeolocationSdk::AbuseContactApi.new
|
2052
|
+
begin
|
2053
|
+
result = abuse_instance.get_abuse_contact_info(abuse_opts)
|
2054
|
+
p result
|
2055
|
+
rescue IpgeolocationSdk::ApiError => e
|
2056
|
+
puts "Error calling AbuseContactApi: #{e}"
|
2057
|
+
end
|
2058
|
+
```
|
2059
|
+
Sample Response:
|
2060
|
+
```
|
2061
|
+
class AbuseResponse {
|
2062
|
+
ip: 9.9.9.9
|
2063
|
+
abuse: class Abuse {
|
2064
|
+
route: 9.9.9.0/24
|
2065
|
+
country:
|
2066
|
+
name: Quad9 Abuse
|
2067
|
+
organization: Quad9 Abuse
|
2068
|
+
role: abuse
|
2069
|
+
kind: group
|
2070
|
+
address: 1442 A Walnut Street Ste 501
|
2071
|
+
Berkeley
|
2072
|
+
CA
|
2073
|
+
94709
|
2074
|
+
United States
|
2075
|
+
phoneNumbers: [+1-415-831-3129]
|
2076
|
+
}
|
2077
|
+
}
|
2078
|
+
```
|
2079
|
+
|
2080
|
+
## Documentation for Models
|
2081
|
+
|
2082
|
+
- [IpgeolocationSdk::ASNConnection](docs/ASNConnection.md)
|
2083
|
+
- [IpgeolocationSdk::ASNResponse](docs/ASNResponse.md)
|
2084
|
+
- [IpgeolocationSdk::ASNDetails](docs/ASNDetails.md)
|
2085
|
+
- [IpgeolocationSdk::Abuse](docs/Abuse.md)
|
2086
|
+
- [IpgeolocationSdk::AbuseResponse](docs/AbuseResponse.md)
|
2087
|
+
- [IpgeolocationSdk::Astronomy](docs/Astronomy.md)
|
2088
|
+
- [IpgeolocationSdk::AstronomyEvening](docs/AstronomyEvening.md)
|
2089
|
+
- [IpgeolocationSdk::AstronomyLocation](docs/AstronomyLocation.md)
|
2090
|
+
- [IpgeolocationSdk::AstronomyMorning](docs/AstronomyMorning.md)
|
2091
|
+
- [IpgeolocationSdk::AstronomyResponse](docs/AstronomyResponse.md)
|
2092
|
+
- [IpgeolocationSdk::CountryMetadata](docs/CountryMetadata.md)
|
2093
|
+
- [IpgeolocationSdk::Currency](docs/Currency.md)
|
2094
|
+
- [IpgeolocationSdk::ErrorResponse](docs/ErrorResponse.md)
|
2095
|
+
- [IpgeolocationSdk::GeolocationResponse](docs/GeolocationResponse.md)
|
2096
|
+
- [IpgeolocationSdk::BulkIPGeolocation](docs/BulkIPGeolocation.md)
|
2097
|
+
- [IpgeolocationSdk::BulkIPSecurity](docs/BulkIPSecurity.md)
|
2098
|
+
- [IpgeolocationSdk::Location](docs/Location.md)
|
2099
|
+
- [IpgeolocationSdk::LocationMinimal](docs/LocationMinimal.md)
|
2100
|
+
- [IpgeolocationSdk::Network](docs/Network.md)
|
2101
|
+
- [IpgeolocationSdk::NetworkAsn](docs/NetworkAsn.md)
|
2102
|
+
- [IpgeolocationSdk::NetworkCompany](docs/NetworkCompany.md)
|
2103
|
+
- [IpgeolocationSdk::NetworkMinimal](docs/NetworkMinimal.md)
|
2104
|
+
- [IpgeolocationSdk::NetworkMinimalAsn](docs/NetworkMinimalAsn.md)
|
2105
|
+
- [IpgeolocationSdk::NetworkMinimalCompany](docs/NetworkMinimalCompany.md)
|
2106
|
+
- [IpgeolocationSdk::ParseBulkUserAgentStringsRequest](docs/ParseBulkUserAgentStringsRequest.md)
|
2107
|
+
- [IpgeolocationSdk::Security](docs/Security.md)
|
2108
|
+
- [IpgeolocationSdk::SecurityAPIResponse](docs/SecurityAPIResponse.md)
|
2109
|
+
- [IpgeolocationSdk::TimeConversionResponse](docs/TimeConversionResponse.md)
|
2110
|
+
- [IpgeolocationSdk::TimeZone](docs/TimeZone.md)
|
2111
|
+
- [IpgeolocationSdk::TimeZoneDetailedResponse](docs/TimeZoneDetailedResponse.md)
|
2112
|
+
- [IpgeolocationSdk::TimeZoneDstEnd](docs/TimeZoneDstEnd.md)
|
2113
|
+
- [IpgeolocationSdk::TimeZoneDstStart](docs/TimeZoneDstStart.md)
|
2114
|
+
- [IpgeolocationSdk::TimezoneAirport](docs/TimezoneAirport.md)
|
2115
|
+
- [IpgeolocationSdk::TimezoneDetail](docs/TimezoneDetail.md)
|
2116
|
+
- [IpgeolocationSdk::TimezoneDetailDstEnd](docs/TimezoneDetailDstEnd.md)
|
2117
|
+
- [IpgeolocationSdk::TimezoneDetailDstStart](docs/TimezoneDetailDstStart.md)
|
2118
|
+
- [IpgeolocationSdk::TimezoneLocation](docs/TimezoneLocation.md)
|
2119
|
+
- [IpgeolocationSdk::TimezoneLocode](docs/TimezoneLocode.md)
|
2120
|
+
- [IpgeolocationSdk::UserAgentData](docs/UserAgentData.md)
|
2121
|
+
- [IpgeolocationSdk::UserAgentDataDevice](docs/UserAgentDataDevice.md)
|
2122
|
+
- [IpgeolocationSdk::UserAgentDataEngine](docs/UserAgentDataEngine.md)
|
2123
|
+
- [IpgeolocationSdk::UserAgentDataOperatingSystem](docs/UserAgentDataOperatingSystem.md)
|
2124
|
+
|