Learn R Programming

ip2location.io (version 0.0.0-2)

get_ip_data: Retrieve and Save Data for Multiple IP Addresses

Description

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.

Usage

get_ip_data(ip_addresses, api_key)

Value

A data frame with the extracted data for each IP.

Arguments

ip_addresses

A vector of IP addresses.

api_key

Your IP2Location.io API key in quotation marks.

Details

The function extracts the following fields (some of which may contain NAs depending on the user's API plan) for each IP address:

FieldDescription
ipIP address
country_codeCountry code
country_nameCountry name
region_nameRegion name
districtDistrict
city_nameCity name
latitudeLatitude
longitudeLongitude
zip_codeZip code
time_zoneTime zone
asnAutonomous system number
asAutonomous system
ispInternet service provider
domainDomain
net_speedNetwork speed
idd_codeInternational dialing code
area_codeArea code
weather_station_codeWeather station code
weather_station_nameWeather station name
mccMobile country code
mncMobile network code
mobile_brandMobile brand
elevationElevation
usage_typeUsage type
address_typeAddress type
ads_categoryAds category
ads_category_nameAds category name
continent_nameContinent name
continent_hemisphereContinent hemisphere
country_capitalCountry capital
country_languageCountry language
region_codeRegion code
time_zone_olsonTime zone (Olson format)
time_zone_current_timeCurrent time in the time zone
is_proxyWhether the IP is a proxy (limited to public proxies in the Free and Starter plans)
fraud_scoreFraud score
proxy_last_seenLast seen time of the proxy
proxy_typeProxy type
proxy_threatProxy threat
proxy_providerProxy provider
proxy_is_vpnWhether the proxy is a VPN
proxy_is_torWhether the proxy is Tor
proxy_is_data_centerWhether the proxy is a data center
proxy_is_public_proxyWhether the proxy is a public proxy
proxy_is_web_proxyWhether the proxy is a web proxy
proxy_is_web_crawlerWhether the proxy is a web crawler
proxy_is_residential_proxyWhether the proxy is a residential proxy
proxy_is_consumer_privacy_networkWhether the proxy is a consumer privacy network
proxy_is_enterprise_private_networkWhether the proxy is an enterprise private network
proxy_is_spammerWhether the proxy is a spammer
proxy_is_scannerWhether the proxy is a scanner
proxy_is_botnetWhether the proxy is a botnet

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab