ipgeolocation_sdk 1.0.0 → 2.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +288 -2003
- data/lib/ipgeolocation_sdk/client.rb +223 -0
- data/lib/ipgeolocation_sdk/client_config.rb +102 -0
- data/lib/ipgeolocation_sdk/enums.rb +110 -0
- data/lib/ipgeolocation_sdk/errors.rb +38 -0
- data/lib/ipgeolocation_sdk/json_output.rb +30 -0
- data/lib/ipgeolocation_sdk/models.rb +186 -0
- data/lib/ipgeolocation_sdk/request_models.rb +175 -0
- data/lib/ipgeolocation_sdk/serde.rb +433 -0
- data/lib/ipgeolocation_sdk/transport.rb +109 -0
- data/lib/ipgeolocation_sdk/value_object.rb +60 -0
- data/lib/ipgeolocation_sdk/version.rb +1 -13
- data/lib/ipgeolocation_sdk.rb +19 -101
- metadata +29 -310
- data/Gemfile +0 -9
- data/Rakefile +0 -10
- data/docs/ASNConnection.md +0 -22
- data/docs/ASNDetails.md +0 -48
- data/docs/ASNLookupApi.md +0 -89
- data/docs/ASNResponse.md +0 -20
- data/docs/ASNResponseXML.md +0 -20
- data/docs/ASNResponseXMLAsn.md +0 -48
- data/docs/Abuse.md +0 -40
- data/docs/AbuseContactApi.md +0 -85
- data/docs/AbuseResponse.md +0 -20
- data/docs/AbuseResponseXML.md +0 -20
- data/docs/Astronomy.md +0 -68
- data/docs/AstronomyApi.md +0 -97
- data/docs/AstronomyEvening.md +0 -36
- data/docs/AstronomyLocation.md +0 -50
- data/docs/AstronomyMorning.md +0 -36
- data/docs/AstronomyResponse.md +0 -22
- data/docs/AstronomyXMLResponse.md +0 -22
- data/docs/BulkIPGeolocation.md +0 -42
- data/docs/BulkIPSecurity.md +0 -42
- data/docs/CountryMetadata.md +0 -22
- data/docs/Currency.md +0 -22
- data/docs/ErrorResponse.md +0 -18
- data/docs/ErrorXMLResponse.md +0 -18
- data/docs/ErrorXMLResponseArray.md +0 -18
- data/docs/GeolocationResponse.md +0 -38
- data/docs/GeolocationXMLResponse.md +0 -38
- data/docs/GeolocationXMLResponseArray.md +0 -38
- data/docs/GetBulkIpGeolocation200ResponseInner1.md +0 -49
- data/docs/GetBulkIpGeolocationRequest.md +0 -18
- data/docs/GetBulkIpSecurityInfo200ResponseInner1.md +0 -49
- data/docs/IPLocationApi.md +0 -175
- data/docs/Location.md +0 -58
- data/docs/LocationMinimal.md +0 -52
- data/docs/Network.md +0 -22
- data/docs/NetworkAsn.md +0 -38
- data/docs/NetworkCompany.md +0 -22
- data/docs/NetworkMinimal.md +0 -20
- data/docs/NetworkMinimalAsn.md +0 -22
- data/docs/NetworkMinimalCompany.md +0 -18
- data/docs/ParseBulkUserAgentStringsRequest.md +0 -18
- data/docs/ParseUserAgentStringRequest.md +0 -18
- data/docs/Security.md +0 -38
- data/docs/SecurityAPIResponse.md +0 -34
- data/docs/SecurityAPIXMLResponse.md +0 -34
- data/docs/SecurityAPIXMLResponseArray.md +0 -34
- data/docs/SecurityApi.md +0 -175
- data/docs/TimeConversionApi.md +0 -109
- data/docs/TimeConversionResponse.md +0 -24
- data/docs/TimeConversionXMLResponse.md +0 -24
- data/docs/TimeZone.md +0 -36
- data/docs/TimeZoneDetailedResponse.md +0 -26
- data/docs/TimeZoneDetailedXMLResponse.md +0 -26
- data/docs/TimeZoneDstEnd.md +0 -28
- data/docs/TimeZoneDstStart.md +0 -28
- data/docs/TimezoneAirport.md +0 -40
- data/docs/TimezoneApi.md +0 -99
- data/docs/TimezoneDetail.md +0 -56
- data/docs/TimezoneDetailDstEnd.md +0 -28
- data/docs/TimezoneDetailDstStart.md +0 -28
- data/docs/TimezoneLocation.md +0 -48
- data/docs/TimezoneLocode.md +0 -32
- data/docs/UserAgentApi.md +0 -235
- data/docs/UserAgentData.md +0 -32
- data/docs/UserAgentDataDevice.md +0 -24
- data/docs/UserAgentDataEngine.md +0 -24
- data/docs/UserAgentDataOperatingSystem.md +0 -26
- data/docs/UserAgentXMLData.md +0 -32
- data/docs/UserAgentXMLDataArray.md +0 -32
- data/git_push.sh +0 -57
- data/ipgeolocation_sdk.gemspec +0 -29
- data/lib/ipgeolocation_sdk/api/abuse_contact_api.rb +0 -86
- data/lib/ipgeolocation_sdk/api/asn_lookup_api.rb +0 -92
- data/lib/ipgeolocation_sdk/api/astronomy_api.rb +0 -116
- data/lib/ipgeolocation_sdk/api/ip_geolocation_api.rb +0 -186
- data/lib/ipgeolocation_sdk/api/ip_security_api.rb +0 -184
- data/lib/ipgeolocation_sdk/api/time_conversion_api.rb +0 -122
- data/lib/ipgeolocation_sdk/api/timezone_api.rb +0 -113
- data/lib/ipgeolocation_sdk/api/user_agent_api.rb +0 -158
- data/lib/ipgeolocation_sdk/api_client.rb +0 -393
- data/lib/ipgeolocation_sdk/api_error.rb +0 -58
- data/lib/ipgeolocation_sdk/configuration.rb +0 -308
- data/lib/ipgeolocation_sdk/models/abuse.rb +0 -305
- data/lib/ipgeolocation_sdk/models/abuse_response.rb +0 -229
- data/lib/ipgeolocation_sdk/models/abuse_response_xml.rb +0 -229
- data/lib/ipgeolocation_sdk/models/asn_connection.rb +0 -238
- data/lib/ipgeolocation_sdk/models/asn_response.rb +0 -230
- data/lib/ipgeolocation_sdk/models/asn_response_asn.rb +0 -368
- data/lib/ipgeolocation_sdk/models/asn_response_xml.rb +0 -229
- data/lib/ipgeolocation_sdk/models/asn_response_xml_asn.rb +0 -364
- data/lib/ipgeolocation_sdk/models/astronomy.rb +0 -445
- data/lib/ipgeolocation_sdk/models/astronomy_evening.rb +0 -301
- data/lib/ipgeolocation_sdk/models/astronomy_location.rb +0 -364
- data/lib/ipgeolocation_sdk/models/astronomy_morning.rb +0 -301
- data/lib/ipgeolocation_sdk/models/astronomy_response.rb +0 -238
- data/lib/ipgeolocation_sdk/models/astronomy_xml_response.rb +0 -238
- data/lib/ipgeolocation_sdk/models/bulk_ip_geolocation.rb +0 -113
- data/lib/ipgeolocation_sdk/models/bulk_ip_security.rb +0 -113
- data/lib/ipgeolocation_sdk/models/country_metadata.rb +0 -240
- data/lib/ipgeolocation_sdk/models/currency.rb +0 -238
- data/lib/ipgeolocation_sdk/models/error_response.rb +0 -220
- data/lib/ipgeolocation_sdk/models/error_xml_response.rb +0 -220
- data/lib/ipgeolocation_sdk/models/error_xml_response_array.rb +0 -220
- data/lib/ipgeolocation_sdk/models/geolocation_response.rb +0 -310
- data/lib/ipgeolocation_sdk/models/geolocation_xml_response.rb +0 -310
- data/lib/ipgeolocation_sdk/models/geolocation_xml_response_array.rb +0 -310
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_geolocation200_response_inner1.rb +0 -105
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_geolocation_request.rb +0 -241
- data/lib/ipgeolocation_sdk/models/get_bulk_ip_security_info200_response_inner1.rb +0 -105
- data/lib/ipgeolocation_sdk/models/location.rb +0 -400
- data/lib/ipgeolocation_sdk/models/location_minimal.rb +0 -373
- data/lib/ipgeolocation_sdk/models/network.rb +0 -238
- data/lib/ipgeolocation_sdk/models/network_asn.rb +0 -310
- data/lib/ipgeolocation_sdk/models/network_company.rb +0 -238
- data/lib/ipgeolocation_sdk/models/network_minimal.rb +0 -229
- data/lib/ipgeolocation_sdk/models/network_minimal_asn.rb +0 -238
- data/lib/ipgeolocation_sdk/models/network_minimal_company.rb +0 -220
- data/lib/ipgeolocation_sdk/models/parse_bulk_user_agent_strings_request.rb +0 -222
- data/lib/ipgeolocation_sdk/models/parse_user_agent_string_request.rb +0 -220
- data/lib/ipgeolocation_sdk/models/security.rb +0 -310
- data/lib/ipgeolocation_sdk/models/security_api_response.rb +0 -292
- data/lib/ipgeolocation_sdk/models/security_apixml_response.rb +0 -292
- data/lib/ipgeolocation_sdk/models/security_apixml_response_array.rb +0 -292
- data/lib/ipgeolocation_sdk/models/time_conversion_response.rb +0 -247
- data/lib/ipgeolocation_sdk/models/time_conversion_xml_response.rb +0 -247
- data/lib/ipgeolocation_sdk/models/time_zone.rb +0 -301
- data/lib/ipgeolocation_sdk/models/time_zone_detailed_response.rb +0 -256
- data/lib/ipgeolocation_sdk/models/time_zone_detailed_xml_response.rb +0 -256
- data/lib/ipgeolocation_sdk/models/time_zone_dst_end.rb +0 -265
- data/lib/ipgeolocation_sdk/models/time_zone_dst_start.rb +0 -265
- data/lib/ipgeolocation_sdk/models/timezone_airport.rb +0 -319
- data/lib/ipgeolocation_sdk/models/timezone_detail.rb +0 -391
- data/lib/ipgeolocation_sdk/models/timezone_detail_dst_end.rb +0 -265
- data/lib/ipgeolocation_sdk/models/timezone_detail_dst_start.rb +0 -265
- data/lib/ipgeolocation_sdk/models/timezone_location.rb +0 -355
- data/lib/ipgeolocation_sdk/models/timezone_locode.rb +0 -283
- data/lib/ipgeolocation_sdk/models/user_agent_data.rb +0 -283
- data/lib/ipgeolocation_sdk/models/user_agent_data_device.rb +0 -247
- data/lib/ipgeolocation_sdk/models/user_agent_data_engine.rb +0 -247
- data/lib/ipgeolocation_sdk/models/user_agent_data_operating_system.rb +0 -256
- data/lib/ipgeolocation_sdk/models/user_agent_xml_data.rb +0 -283
- data/lib/ipgeolocation_sdk/models/user_agent_xml_data_array.rb +0 -283
- data/spec/api/abuse_contact_api_spec.rb +0 -48
- data/spec/api/asn_lookup_api_spec.rb +0 -50
- data/spec/api/astronomy_api_spec.rb +0 -54
- data/spec/api/ip_location_api_spec.rb +0 -67
- data/spec/api/security_api_spec.rb +0 -67
- data/spec/api/time_conversion_api_spec.rb +0 -60
- data/spec/api/timezone_api_spec.rb +0 -56
- data/spec/api/user_agent_api_spec.rb +0 -74
- data/spec/models/abuse_response_spec.rb +0 -42
- data/spec/models/abuse_response_xml_spec.rb +0 -42
- data/spec/models/abuse_spec.rb +0 -90
- data/spec/models/asn_connection_spec.rb +0 -48
- data/spec/models/asn_response_asn_spec.rb +0 -126
- data/spec/models/asn_response_spec.rb +0 -42
- data/spec/models/asn_response_xml_asn_spec.rb +0 -126
- data/spec/models/asn_response_xml_spec.rb +0 -42
- data/spec/models/astronomy_evening_spec.rb +0 -90
- data/spec/models/astronomy_location_spec.rb +0 -132
- data/spec/models/astronomy_morning_spec.rb +0 -90
- data/spec/models/astronomy_response_spec.rb +0 -48
- data/spec/models/astronomy_spec.rb +0 -186
- data/spec/models/astronomy_xml_response_spec.rb +0 -48
- data/spec/models/country_metadata_spec.rb +0 -48
- data/spec/models/currency_spec.rb +0 -48
- data/spec/models/error_response_spec.rb +0 -36
- data/spec/models/error_xml_response_array_spec.rb +0 -36
- data/spec/models/error_xml_response_spec.rb +0 -36
- data/spec/models/geolocation_response_spec.rb +0 -96
- data/spec/models/geolocation_xml_response_array_spec.rb +0 -96
- data/spec/models/geolocation_xml_response_spec.rb +0 -96
- data/spec/models/get_bulk_ip_geolocation200_response_inner1_spec.rb +0 -32
- data/spec/models/get_bulk_ip_geolocation200_response_inner_spec.rb +0 -32
- data/spec/models/get_bulk_ip_geolocation_request_spec.rb +0 -36
- data/spec/models/get_bulk_ip_security_info200_response_inner1_spec.rb +0 -32
- data/spec/models/get_bulk_ip_security_info200_response_inner_spec.rb +0 -32
- data/spec/models/location_minimal_spec.rb +0 -138
- data/spec/models/location_spec.rb +0 -156
- data/spec/models/network_asn_spec.rb +0 -96
- data/spec/models/network_company_spec.rb +0 -48
- data/spec/models/network_minimal_asn_spec.rb +0 -48
- data/spec/models/network_minimal_company_spec.rb +0 -36
- data/spec/models/network_minimal_spec.rb +0 -42
- data/spec/models/network_spec.rb +0 -48
- data/spec/models/parse_bulk_user_agent_strings_request_spec.rb +0 -36
- data/spec/models/parse_user_agent_string_request_spec.rb +0 -36
- data/spec/models/security_api_response_spec.rb +0 -84
- data/spec/models/security_apixml_response_array_spec.rb +0 -84
- data/spec/models/security_apixml_response_spec.rb +0 -84
- data/spec/models/security_spec.rb +0 -96
- data/spec/models/time_conversion_response_spec.rb +0 -54
- data/spec/models/time_conversion_xml_response_spec.rb +0 -54
- data/spec/models/time_zone_detailed_response_spec.rb +0 -60
- data/spec/models/time_zone_detailed_xml_response_spec.rb +0 -60
- data/spec/models/time_zone_dst_end_spec.rb +0 -66
- data/spec/models/time_zone_dst_start_spec.rb +0 -66
- data/spec/models/time_zone_spec.rb +0 -90
- data/spec/models/timezone_airport_spec.rb +0 -102
- data/spec/models/timezone_detail_dst_end_spec.rb +0 -66
- data/spec/models/timezone_detail_dst_start_spec.rb +0 -66
- data/spec/models/timezone_detail_spec.rb +0 -150
- data/spec/models/timezone_location_spec.rb +0 -126
- data/spec/models/timezone_locode_spec.rb +0 -78
- data/spec/models/user_agent_data_device_spec.rb +0 -54
- data/spec/models/user_agent_data_engine_spec.rb +0 -54
- data/spec/models/user_agent_data_operating_system_spec.rb +0 -60
- data/spec/models/user_agent_data_spec.rb +0 -78
- data/spec/models/user_agent_xml_data_array_spec.rb +0 -78
- data/spec/models/user_agent_xml_data_spec.rb +0 -78
- data/spec/spec_helper.rb +0 -111
data/README.md
CHANGED
|
@@ -1,69 +1,42 @@
|
|
|
1
|
-
# IPGeolocation SDK
|
|
1
|
+
# IPGeolocation Ruby SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official Ruby SDK for the IPGeolocation.io IP Location API.
|
|
4
4
|
|
|
5
|
+
Look up IPv4, IPv6, and domains with `/v3/ipgeo` and `/v3/ipgeo-bulk`. Get geolocation, company, ASN, timezone, network, hostname, abuse, user-agent, and security data from one API.
|
|
5
6
|
|
|
6
|
-
-
|
|
7
|
-
-
|
|
7
|
+
- Ruby 2.7+
|
|
8
|
+
- Sync client built on `Net::HTTP`
|
|
9
|
+
- Typed responses plus raw JSON and XML methods
|
|
8
10
|
|
|
9
11
|
## Table of Contents
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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:
|
|
13
|
+
- [Install](#install)
|
|
14
|
+
- [Quick Start](#quick-start)
|
|
15
|
+
- [At a Glance](#at-a-glance)
|
|
16
|
+
- [Get Your API Key](#get-your-api-key)
|
|
17
|
+
- [Authentication](#authentication)
|
|
18
|
+
- [Plan Behavior](#plan-behavior)
|
|
19
|
+
- [Client Configuration](#client-configuration)
|
|
20
|
+
- [Available Methods](#available-methods)
|
|
21
|
+
- [Request Options](#request-options)
|
|
22
|
+
- [Examples](#examples)
|
|
23
|
+
- [Response Metadata](#response-metadata)
|
|
24
|
+
- [JSON Helpers](#json-helpers)
|
|
25
|
+
- [Errors](#errors)
|
|
26
|
+
- [Troubleshooting](#troubleshooting)
|
|
27
|
+
- [Frequently Asked Questions](#frequently-asked-questions)
|
|
28
|
+
- [Links](#links)
|
|
29
|
+
|
|
30
|
+
## Install
|
|
58
31
|
|
|
59
32
|
```bash
|
|
60
|
-
gem install
|
|
33
|
+
gem install ipgeolocation_sdk
|
|
61
34
|
```
|
|
62
35
|
|
|
63
|
-
Or add to your `Gemfile`:
|
|
36
|
+
Or add it to your `Gemfile`:
|
|
64
37
|
|
|
65
38
|
```ruby
|
|
66
|
-
gem
|
|
39
|
+
gem "ipgeolocation_sdk", "~> 2.0"
|
|
67
40
|
```
|
|
68
41
|
|
|
69
42
|
Then run:
|
|
@@ -72,2053 +45,365 @@ Then run:
|
|
|
72
45
|
bundle install
|
|
73
46
|
```
|
|
74
47
|
|
|
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
|
|
48
|
+
```ruby
|
|
49
|
+
require "ipgeolocation_sdk"
|
|
84
50
|
```
|
|
85
51
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
52
|
+
RubyGems package: `ipgeolocation_sdk`
|
|
53
|
+
Package page: <https://rubygems.org/gems/ipgeolocation_sdk>
|
|
54
|
+
GitHub repository: <https://github.com/IPGeolocation/ip-geolocation-ruby-sdk>
|
|
89
55
|
|
|
90
|
-
|
|
56
|
+
## Quick Start
|
|
91
57
|
|
|
92
58
|
```ruby
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Authentication
|
|
59
|
+
require "ipgeolocation_sdk"
|
|
97
60
|
|
|
98
|
-
|
|
61
|
+
client = IpgeolocationSdk::IpGeolocationClient.new(
|
|
62
|
+
api_key: ENV.fetch("IPGEO_API_KEY")
|
|
63
|
+
)
|
|
99
64
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
require 'ipgeolocation_sdk'
|
|
65
|
+
begin
|
|
66
|
+
response = client.lookup_ip_geolocation(ip: "8.8.8.8")
|
|
103
67
|
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
68
|
+
puts response.data.ip # 8.8.8.8
|
|
69
|
+
puts response.data.location&.country_name # United States
|
|
70
|
+
puts response.data.location&.city
|
|
71
|
+
puts response.data.time_zone&.name
|
|
72
|
+
puts response.metadata.credits_charged
|
|
73
|
+
ensure
|
|
74
|
+
client.close
|
|
107
75
|
end
|
|
108
76
|
```
|
|
109
77
|
|
|
110
|
-
|
|
78
|
+
You can also pass `LookupIpGeolocationRequest` and `BulkLookupIpGeolocationRequest` objects if you want validation before the request is sent.
|
|
111
79
|
|
|
112
|
-
|
|
80
|
+
## At a Glance
|
|
113
81
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
|
82
|
+
| Item | Value |
|
|
83
|
+
|------|-------|
|
|
84
|
+
| Gem | `ipgeolocation_sdk` |
|
|
85
|
+
| Module | `IpgeolocationSdk` |
|
|
86
|
+
| Supported Endpoints | `/v3/ipgeo`, `/v3/ipgeo-bulk` |
|
|
87
|
+
| Supported Inputs | IPv4, IPv6, domain |
|
|
88
|
+
| Main Data Returned | Geolocation, company, ASN, timezone, network, hostname, abuse, user-agent, currency, security |
|
|
89
|
+
| Authentication | API key, request-origin auth for `/v3/ipgeo` only |
|
|
90
|
+
| Response Formats | Structured JSON, raw JSON, raw XML |
|
|
91
|
+
| Bulk Limit | Up to 50,000 IPs or domains per request |
|
|
92
|
+
| Transport | `Net::HTTP` |
|
|
127
93
|
|
|
94
|
+
## Get Your API Key
|
|
128
95
|
|
|
129
|
-
|
|
96
|
+
To use most SDK features, create or access your IPGeolocation account and copy an API key from your dashboard.
|
|
130
97
|
|
|
131
|
-
|
|
98
|
+
1. Sign up: <https://app.ipgeolocation.io/signup>
|
|
99
|
+
2. Verify your email if prompted
|
|
100
|
+
3. Sign in: <https://app.ipgeolocation.io/login>
|
|
101
|
+
4. Open your dashboard: <https://app.ipgeolocation.io/dashboard>
|
|
102
|
+
5. Copy an API key from the `API Keys` section
|
|
132
103
|
|
|
133
|
-
|
|
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.
|
|
104
|
+
For server-side code, keep the API key in an environment variable or secret manager. For browser-based single lookups on paid plans, use request-origin auth instead of exposing an API key in frontend code.
|
|
158
105
|
|
|
106
|
+
## Authentication
|
|
159
107
|
|
|
160
|
-
###
|
|
161
|
-
#### Default Fields
|
|
108
|
+
### API Key
|
|
162
109
|
|
|
163
110
|
```ruby
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
}
|
|
111
|
+
client = IpgeolocationSdk::IpGeolocationClient.new(
|
|
112
|
+
api_key: ENV.fetch("IPGEO_API_KEY")
|
|
113
|
+
)
|
|
249
114
|
```
|
|
250
|
-
|
|
251
|
-
|
|
115
|
+
|
|
116
|
+
### Request-Origin Auth
|
|
252
117
|
|
|
253
118
|
```ruby
|
|
254
|
-
|
|
255
|
-
|
|
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
|
|
119
|
+
client = IpgeolocationSdk::IpGeolocationClient.new(
|
|
120
|
+
request_origin: "https://app.example.com"
|
|
121
|
+
)
|
|
325
122
|
```
|
|
326
123
|
|
|
327
|
-
|
|
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
|
-
```
|
|
124
|
+
`request_origin` must be an absolute `http` or `https` origin with no path, query string, fragment, or userinfo.
|
|
373
125
|
|
|
374
|
-
|
|
375
|
-
|
|
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**
|
|
126
|
+
> [!IMPORTANT]
|
|
127
|
+
> Request-origin auth does not work with `/v3/ipgeo-bulk`. Bulk lookup always requires `api_key`.
|
|
452
128
|
|
|
453
|
-
|
|
129
|
+
> [!NOTE]
|
|
130
|
+
> If you set both `api_key` and `request_origin`, single lookup still uses the API key. The API key is sent as the `apiKey` query parameter, so avoid logging full request URLs.
|
|
454
131
|
|
|
455
|
-
|
|
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.
|
|
132
|
+
## Plan Behavior
|
|
458
133
|
|
|
459
|
-
|
|
460
|
-
#### Include DMA, Abuse and Security
|
|
134
|
+
Feature availability depends on your plan and request parameters.
|
|
461
135
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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.
|
|
136
|
+
| Capability | Free | Paid |
|
|
137
|
+
|------------|------|------|
|
|
138
|
+
| Single IPv4 and IPv6 lookup | Supported | Supported |
|
|
139
|
+
| Domain lookup | Not supported | Supported |
|
|
140
|
+
| Bulk lookup | Not supported | Supported |
|
|
141
|
+
| Non-English `lang` | Not supported | Supported |
|
|
142
|
+
| Request-origin auth | Not supported | Supported for `/v3/ipgeo` only |
|
|
143
|
+
| Optional modules via `include` | Not supported | Supported |
|
|
144
|
+
| `include: ["*"]` | Base response only | All plan-available modules |
|
|
566
145
|
|
|
567
|
-
|
|
146
|
+
Paid plans still need `include` for optional modules. `fields` and `excludes` only trim the response. They do not turn modules on or unlock paid data.
|
|
568
147
|
|
|
569
|
-
##
|
|
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.
|
|
148
|
+
## Client Configuration
|
|
571
149
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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
|
-
```
|
|
150
|
+
| Field | Type | Default | Notes |
|
|
151
|
+
|-------|------|---------|-------|
|
|
152
|
+
| `api_key` | `String` | unset | Required for bulk lookup. Optional for single lookup if `request_origin` is set. |
|
|
153
|
+
| `request_origin` | `String` | unset | Must be an absolute `http` or `https` origin. |
|
|
154
|
+
| `base_url` | `String` | `https://api.ipgeolocation.io` | Override the API base URL. |
|
|
155
|
+
| `connect_timeout` | `Numeric` | `10.0` | Time to open the connection, in seconds. |
|
|
156
|
+
| `read_timeout` | `Numeric` | `30.0` | Time to wait while reading the response body, in seconds. |
|
|
592
157
|
|
|
593
|
-
|
|
158
|
+
The client constructor accepts either an `IpGeolocationClientConfig` or a hash with the same keys.
|
|
594
159
|
|
|
595
|
-
|
|
160
|
+
## Available Methods
|
|
596
161
|
|
|
597
|
-
|
|
162
|
+
| Method | Returns | Notes |
|
|
163
|
+
|--------|---------|-------|
|
|
164
|
+
| `lookup_ip_geolocation(request = nil)` | `ApiResponse` with typed `data` | Single lookup. Typed JSON response. |
|
|
165
|
+
| `lookup_ip_geolocation_raw(request = nil)` | `ApiResponse` with `String` `data` | Single lookup. Raw JSON or XML string. |
|
|
166
|
+
| `bulk_lookup_ip_geolocation(request)` | `ApiResponse` with bulk result array | Bulk lookup. Typed JSON response. |
|
|
167
|
+
| `bulk_lookup_ip_geolocation_raw(request)` | `ApiResponse` with `String` `data` | Bulk lookup. Raw JSON or XML string. |
|
|
168
|
+
| `close` | `nil` | Closes the client. Do not reuse the client after this. |
|
|
598
169
|
|
|
599
|
-
|
|
170
|
+
> [!NOTE]
|
|
171
|
+
> Typed methods support JSON only. Use the raw methods when you need XML output.
|
|
600
172
|
|
|
601
|
-
|
|
173
|
+
## Request Options
|
|
602
174
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
```
|
|
175
|
+
| Field | Applies To | Notes |
|
|
176
|
+
|-------|------------|-------|
|
|
177
|
+
| `ip` | Single lookup | IPv4, IPv6, or domain. Omit it for caller IP lookup. |
|
|
178
|
+
| `ips` | Bulk lookup | Array of 1 to 50,000 IPs or domains. |
|
|
179
|
+
| `lang` | Single and bulk | One of `en`, `de`, `ru`, `ja`, `fr`, `cn`, `es`, `cs`, `it`, `ko`, `fa`, `pt`. |
|
|
180
|
+
| `include` | Single and bulk | Array of module names such as `security`, `abuse`, `user_agent`, `hostname`, `liveHostname`, `hostnameFallbackLive`, `geo_accuracy`, `dma_code`, or `*`. |
|
|
181
|
+
| `fields` | Single and bulk | Array of field paths to keep, for example `["location.country_name", "security.threat_score"]`. |
|
|
182
|
+
| `excludes` | Single and bulk | Array of field paths to remove from the response. |
|
|
183
|
+
| `user_agent` | Single and bulk | Overrides the outbound `User-Agent` header. |
|
|
184
|
+
| `headers` | Single and bulk | Extra request headers. Use a hash where each value is a string or an array of strings. |
|
|
185
|
+
| `output` | Single and bulk | `"json"` or `"xml"`. Typed methods require JSON. |
|
|
615
186
|
|
|
616
|
-
|
|
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
|
-
```
|
|
187
|
+
## Examples
|
|
649
188
|
|
|
650
|
-
|
|
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
|
|
189
|
+
The examples below assume you already have a configured client in scope:
|
|
763
190
|
|
|
764
191
|
```ruby
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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
|
|
192
|
+
client = IpgeolocationSdk::IpGeolocationClient.new(
|
|
193
|
+
api_key: ENV.fetch("IPGEO_API_KEY")
|
|
194
|
+
)
|
|
776
195
|
```
|
|
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
196
|
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
197
|
+
### Caller IP
|
|
198
|
+
|
|
199
|
+
Omit `ip` to look up the public IP of the machine making the request.
|
|
792
200
|
|
|
793
201
|
```ruby
|
|
794
|
-
|
|
795
|
-
|
|
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
|
|
202
|
+
response = client.lookup_ip_geolocation
|
|
203
|
+
puts response.data.ip
|
|
813
204
|
```
|
|
814
205
|
|
|
815
|
-
|
|
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.
|
|
206
|
+
### Domain Lookup
|
|
818
207
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
### Get ASN Information by IP Address
|
|
208
|
+
Domain lookup is a paid-plan feature.
|
|
822
209
|
|
|
823
210
|
```ruby
|
|
824
|
-
|
|
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
|
|
211
|
+
response = client.lookup_ip_geolocation(ip: "ipgeolocation.io")
|
|
834
212
|
|
|
213
|
+
puts response.data.ip
|
|
214
|
+
puts response.data.domain # ipgeolocation.io
|
|
215
|
+
puts response.data.location&.country_name
|
|
835
216
|
```
|
|
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
217
|
|
|
857
|
-
|
|
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
|
-
```
|
|
218
|
+
### Security and Abuse
|
|
887
219
|
|
|
888
|
-
### Combine All objects using Include
|
|
889
220
|
```ruby
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
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
|
-
}
|
|
221
|
+
response = client.lookup_ip_geolocation(
|
|
222
|
+
ip: "9.9.9.9",
|
|
223
|
+
include: ["security", "abuse"]
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
puts response.data.security&.threat_score
|
|
227
|
+
puts response.data.abuse&.emails&.first
|
|
1061
228
|
```
|
|
1062
229
|
|
|
1063
|
-
|
|
230
|
+
### User-Agent Parsing
|
|
1064
231
|
|
|
1065
|
-
|
|
232
|
+
To parse a visitor user-agent string, pass `include: ["user_agent"]` and send the visitor string in the request `User-Agent` header.
|
|
1066
233
|
|
|
1067
|
-
|
|
234
|
+
```ruby
|
|
235
|
+
visitor_ua = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/601.3.9 (KHTML, like Gecko) Version/9.0.2 Safari/601.3.9"
|
|
1068
236
|
|
|
1069
|
-
|
|
237
|
+
response = client.lookup_ip_geolocation(
|
|
238
|
+
ip: "115.240.90.163",
|
|
239
|
+
include: ["user_agent"],
|
|
240
|
+
headers: { "User-Agent" => visitor_ua }
|
|
241
|
+
)
|
|
1070
242
|
|
|
1071
|
-
|
|
1072
|
-
|
|
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
|
-
}
|
|
243
|
+
puts response.data.user_agent&.name
|
|
244
|
+
puts response.data.user_agent&.operating_system&.name
|
|
1142
245
|
```
|
|
1143
|
-
### Get Timezone by Timezone Name
|
|
1144
246
|
|
|
1145
|
-
|
|
1146
|
-
|
|
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
|
|
247
|
+
> [!NOTE]
|
|
248
|
+
> The `user_agent` request field overrides the SDK's default outbound `User-Agent` header. It takes precedence over `headers["User-Agent"]`.
|
|
1199
249
|
|
|
1200
|
-
|
|
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
|
|
250
|
+
### Filtered Response
|
|
1263
251
|
|
|
1264
252
|
```ruby
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
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
|
|
253
|
+
response = client.lookup_ip_geolocation(
|
|
254
|
+
ip: "8.8.8.8",
|
|
255
|
+
include: ["security"],
|
|
256
|
+
fields: ["location.country_name", "security.threat_score", "security.is_vpn"],
|
|
257
|
+
excludes: ["currency"]
|
|
258
|
+
)
|
|
1319
259
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
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
|
-
}
|
|
260
|
+
puts response.data.location&.country_name
|
|
261
|
+
puts response.data.security&.threat_score
|
|
262
|
+
puts response.data.security&.is_vpn
|
|
1386
263
|
```
|
|
1387
|
-
Similarly, you can fetch Airport Details and Timezone from using any ICAO code as well
|
|
1388
264
|
|
|
1389
|
-
###
|
|
265
|
+
### Raw XML
|
|
1390
266
|
|
|
1391
267
|
```ruby
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
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
|
-
```
|
|
268
|
+
response = client.lookup_ip_geolocation_raw(
|
|
269
|
+
ip: "8.8.8.8",
|
|
270
|
+
output: IpgeolocationSdk::ResponseFormat::XML
|
|
271
|
+
)
|
|
1454
272
|
|
|
1455
|
-
|
|
273
|
+
puts response.data
|
|
274
|
+
```
|
|
1456
275
|
|
|
1457
|
-
|
|
276
|
+
### Bulk Lookup
|
|
1458
277
|
|
|
1459
|
-
|
|
278
|
+
Bulk lookup is a paid-plan feature and always requires `api_key`.
|
|
1460
279
|
|
|
1461
|
-
|
|
280
|
+
Each bulk result is either a success or an error.
|
|
1462
281
|
|
|
1463
282
|
```ruby
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
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.
|
|
283
|
+
response = client.bulk_lookup_ip_geolocation(
|
|
284
|
+
ips: ["8.8.8.8", "invalid-ip", "1.1.1.1"],
|
|
285
|
+
include: ["security"]
|
|
286
|
+
)
|
|
1498
287
|
|
|
1499
|
-
|
|
288
|
+
response.data.each do |result|
|
|
289
|
+
if result.success?
|
|
290
|
+
puts result.data.ip
|
|
291
|
+
puts result.data.security&.threat_score
|
|
292
|
+
next
|
|
293
|
+
end
|
|
1500
294
|
|
|
1501
|
-
|
|
295
|
+
puts result.error.message
|
|
296
|
+
end
|
|
297
|
+
```
|
|
1502
298
|
|
|
1503
|
-
|
|
299
|
+
## Response Metadata
|
|
1504
300
|
|
|
1505
|
-
|
|
301
|
+
Each method returns an `ApiResponse` with `data` and `metadata`.
|
|
1506
302
|
|
|
1507
|
-
|
|
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.
|
|
303
|
+
`metadata` includes:
|
|
1549
304
|
|
|
1550
|
-
|
|
305
|
+
| Field | Meaning |
|
|
306
|
+
|-------|---------|
|
|
307
|
+
| `credits_charged` | Credits charged for the request when the API returns that header |
|
|
308
|
+
| `successful_records` | Number of successful bulk records when the API returns that header |
|
|
309
|
+
| `status_code` | HTTP status code |
|
|
310
|
+
| `duration_ms` | Client-side request time in milliseconds |
|
|
311
|
+
| `raw_headers` | Response headers as `Hash<String, Array<String>>` |
|
|
1551
312
|
|
|
1552
|
-
|
|
313
|
+
Helper methods:
|
|
1553
314
|
|
|
1554
315
|
```ruby
|
|
1555
|
-
|
|
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
|
-
```
|
|
316
|
+
metadata = response.metadata
|
|
1566
317
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
318
|
+
puts metadata.status_code
|
|
319
|
+
puts metadata.duration_ms
|
|
320
|
+
puts metadata.header_values("X-Credits-Charged").inspect
|
|
321
|
+
puts metadata.first_header_value("Content-Type")
|
|
322
|
+
```
|
|
1570
323
|
|
|
1571
|
-
|
|
324
|
+
## JSON Helpers
|
|
1572
325
|
|
|
1573
|
-
|
|
326
|
+
Use these helpers to turn SDK objects into JSON:
|
|
1574
327
|
|
|
1575
328
|
```ruby
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
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
|
-
}
|
|
329
|
+
puts IpgeolocationSdk.to_json(response.data)
|
|
330
|
+
puts IpgeolocationSdk.to_pretty_json(response.data)
|
|
331
|
+
puts IpgeolocationSdk.to_pretty_json(response.data, :full)
|
|
1736
332
|
```
|
|
1737
333
|
|
|
1738
|
-
|
|
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
|
-
```
|
|
334
|
+
Compact mode omits `nil` fields. Full mode keeps them.
|
|
1893
335
|
|
|
1894
|
-
|
|
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
|
|
336
|
+
## Errors
|
|
1985
337
|
|
|
1986
|
-
|
|
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
|
-
```
|
|
338
|
+
The SDK raises these exception classes:
|
|
2020
339
|
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
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
|
-
```
|
|
340
|
+
- `IpgeolocationSdk::ValidationError`
|
|
341
|
+
- `IpgeolocationSdk::SerializationError`
|
|
342
|
+
- `IpgeolocationSdk::TransportError`
|
|
343
|
+
- `IpgeolocationSdk::RequestTimeoutError`
|
|
344
|
+
- `IpgeolocationSdk::ApiError`
|
|
345
|
+
- `IpgeolocationSdk::BadRequestError`
|
|
346
|
+
- `IpgeolocationSdk::UnauthorizedError`
|
|
347
|
+
- `IpgeolocationSdk::NotFoundError`
|
|
348
|
+
- `IpgeolocationSdk::MethodNotAllowedError`
|
|
349
|
+
- `IpgeolocationSdk::PayloadTooLargeError`
|
|
350
|
+
- `IpgeolocationSdk::UnsupportedMediaTypeError`
|
|
351
|
+
- `IpgeolocationSdk::LockedError`
|
|
352
|
+
- `IpgeolocationSdk::RateLimitError`
|
|
353
|
+
- `IpgeolocationSdk::ClientClosedRequestError`
|
|
354
|
+
- `IpgeolocationSdk::ServerError`
|
|
2079
355
|
|
|
2080
|
-
|
|
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)
|
|
356
|
+
Example:
|
|
2124
357
|
|
|
358
|
+
```ruby
|
|
359
|
+
begin
|
|
360
|
+
client.lookup_ip_geolocation(ip: "8.8.8.8")
|
|
361
|
+
rescue IpgeolocationSdk::ApiError => error
|
|
362
|
+
puts error.status_code
|
|
363
|
+
puts error.api_message
|
|
364
|
+
puts error.message
|
|
365
|
+
end
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Troubleshooting
|
|
369
|
+
|
|
370
|
+
- `bulk lookup requires api_key in client config`
|
|
371
|
+
Bulk lookup does not support request-origin auth on its own.
|
|
372
|
+
- `single lookup requires api_key or request_origin in client config`
|
|
373
|
+
Set at least one authentication option before calling the single lookup methods.
|
|
374
|
+
- `XML output is not supported by typed methods`
|
|
375
|
+
Use `lookup_ip_geolocation_raw` or `bulk_lookup_ip_geolocation_raw` for XML output.
|
|
376
|
+
- `client is closed`
|
|
377
|
+
Create a new client after calling `close`.
|
|
378
|
+
- `TransportError` or `RequestTimeoutError`
|
|
379
|
+
Increase `connect_timeout` or `read_timeout`, or add your own retry logic.
|
|
380
|
+
|
|
381
|
+
## Frequently Asked Questions
|
|
382
|
+
|
|
383
|
+
<details>
|
|
384
|
+
<summary><strong>Can I pass a plain hash instead of a request object?</strong></summary>
|
|
385
|
+
Yes. All client methods accept either the typed request object or a plain hash with the same keys.
|
|
386
|
+
</details>
|
|
387
|
+
|
|
388
|
+
<details>
|
|
389
|
+
<summary><strong>How do I look up my own public IP?</strong></summary>
|
|
390
|
+
Call <code>lookup_ip_geolocation</code> with no <code>ip</code> value.
|
|
391
|
+
</details>
|
|
392
|
+
|
|
393
|
+
<details>
|
|
394
|
+
<summary><strong>How do I get XML?</strong></summary>
|
|
395
|
+
Use the raw methods with <code>output: IpgeolocationSdk::ResponseFormat::XML</code>.
|
|
396
|
+
</details>
|
|
397
|
+
|
|
398
|
+
<details>
|
|
399
|
+
<summary><strong>How do I read bulk errors?</strong></summary>
|
|
400
|
+
Check <code>result.success?</code>. Success items use <code>result.data</code>. Error items use <code>result.error.message</code>.
|
|
401
|
+
</details>
|
|
402
|
+
|
|
403
|
+
## Links
|
|
404
|
+
|
|
405
|
+
- API docs: <https://ipgeolocation.io/documentation/ip-location-api.html>
|
|
406
|
+
- Dashboard: <https://app.ipgeolocation.io/dashboard>
|
|
407
|
+
- Pricing: <https://ipgeolocation.io/pricing.html>
|
|
408
|
+
- RubyGems package: <https://rubygems.org/gems/ipgeolocation_sdk>
|
|
409
|
+
- GitHub repo: <https://github.com/IPGeolocation/ip-geolocation-ruby-sdk>
|