| Title: | Batch IP Data Retrieval and Storage Using 'IP2Location.io' |
|---|---|
| Description: | A system for submitting multiple IP information queries to 'IP2Location.io'’s IP Geolocation API and storing the resulting data in a dataframe. You provide a vector of IP addresses and your 'IP2Location.io' API key. The package returns a dataframe with one row per IP address and a column for each available data field (data fields not included in your API plan will contain NAs). This is the second submission of the package to CRAN. |
| Authors: | Oriane Georgeac [aut, cre]
|
| Maintainer: | Oriane Georgeac <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0-2 |
| Built: | 2026-06-05 10:27:22 UTC |
| Source: | https://github.com/cran/ip2location.io |
This function retrieves information for a list of IP addresses using the IP2Location.io API, processes the data, and returns the data as a dataframe. The function also handles missing values by assigning NAs for any data field not provided by the user's API plan.
get_ip_data(ip_addresses, api_key)get_ip_data(ip_addresses, api_key)
ip_addresses |
A vector of IP addresses. |
api_key |
Your IP2Location.io API key in quotation marks. |
The function extracts the following fields (some of which may contain NAs depending on the user's API plan) for each IP address:
| Field | Description |
| ip | IP address |
| country_code | Country code |
| country_name | Country name |
| region_name | Region name |
| district | District |
| city_name | City name |
| latitude | Latitude |
| longitude | Longitude |
| zip_code | Zip code |
| time_zone | Time zone |
| asn | Autonomous system number |
| as | Autonomous system |
| isp | Internet service provider |
| domain | Domain |
| net_speed | Network speed |
| idd_code | International dialing code |
| area_code | Area code |
| weather_station_code | Weather station code |
| weather_station_name | Weather station name |
| mcc | Mobile country code |
| mnc | Mobile network code |
| mobile_brand | Mobile brand |
| elevation | Elevation |
| usage_type | Usage type |
| address_type | Address type |
| ads_category | Ads category |
| ads_category_name | Ads category name |
| continent_name | Continent name |
| continent_hemisphere | Continent hemisphere |
| country_capital | Country capital |
| country_language | Country language |
| region_code | Region code |
| time_zone_olson | Time zone (Olson format) |
| time_zone_current_time | Current time in the time zone |
| is_proxy | Whether the IP is a proxy (limited to public proxies in the Free and Starter plans) |
| fraud_score | Fraud score |
| proxy_last_seen | Last seen time of the proxy |
| proxy_type | Proxy type |
| proxy_threat | Proxy threat |
| proxy_provider | Proxy provider |
| proxy_is_vpn | Whether the proxy is a VPN |
| proxy_is_tor | Whether the proxy is Tor |
| proxy_is_data_center | Whether the proxy is a data center |
| proxy_is_public_proxy | Whether the proxy is a public proxy |
| proxy_is_web_proxy | Whether the proxy is a web proxy |
| proxy_is_web_crawler | Whether the proxy is a web crawler |
| proxy_is_residential_proxy | Whether the proxy is a residential proxy |
| proxy_is_consumer_privacy_network | Whether the proxy is a consumer privacy network |
| proxy_is_enterprise_private_network | Whether the proxy is an enterprise private network |
| proxy_is_spammer | Whether the proxy is a spammer |
| proxy_is_scanner | Whether the proxy is a scanner |
| proxy_is_botnet | Whether the proxy is a botnet |
A data frame with the extracted data for each IP.
This function uses the IP2Location.io API. Make sure you have a valid API key. https://www.ip2location.io/pricing
## Not run: # Example usage ip_addresses <- c("8.8.8.8", "1.1.1.1") # Example IP addresses api_key <- "your_api_key_here" # Replace with your API key ip_data <- get_ip_data(ip_addresses, api_key) # Returns a dataframe # If the user wants to save the dataframe as a CSV, they can do so: write.csv(ip_data, "IP2location.csv", row.names = FALSE) ## End(Not run)## Not run: # Example usage ip_addresses <- c("8.8.8.8", "1.1.1.1") # Example IP addresses api_key <- "your_api_key_here" # Replace with your API key ip_data <- get_ip_data(ip_addresses, api_key) # Returns a dataframe # If the user wants to save the dataframe as a CSV, they can do so: write.csv(ip_data, "IP2location.csv", row.names = FALSE) ## End(Not run)
This function extracts the value of a given field from the parsed API response. It handles missing or empty data gracefully by returning NA if the field is missing.
safe_extract(x, field)safe_extract(x, field)
x |
The parsed JSON response (usually a list). |
field |
The name of the field to extract (as a string). |
The extracted field value, or NA if missing or empty.