Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Integrating IPinfo.io #22

Open
abdullahdevrel opened this issue Jan 3, 2024 · 0 comments
Open

Feature Request: Integrating IPinfo.io #22

abdullahdevrel opened this issue Jan 3, 2024 · 0 comments

Comments

@abdullahdevrel
Copy link

Hi, I am the DevRel of IPinfo.io.

Currently, the project utilizes a service that requires a mandatory API access token. This creates an impediment for users to get up and running with the gem. I am requesting IPinfo.io as a viable replacement for the existing service.

IPinfo.io provides up to 1,000 requests per day with an access token and 50,000 requests per month with a free tier access token.

The migration could be as simple as IPinfo, which already provides the same level of information through the API.

Request

curl https://ipinfo.io/17.81.126.126

Response

{
    "ip": "17.81.126.126",
    "city": "Cupertino",
    "region": "California",
    "country": "US",
    "loc": "37.3230,-122.0322",
    "org": "AS714 Apple Inc.",
    "postal": "95014",
    "timezone": "America/Los_Angeles"
}

The key differences are as follows:

  • country_name: IPinfo's API does not return the full country name through the API. It only returns the country value, which contains the country code. However, you can retrieve similar information using the Hash as a reference.
  • The latitude and longitude values are not separate: IPinfo's API response provides geographic coordinates within the same string in the loc key. Using latitude, longitude = loc.split(',') is an easy way to extract both data.
  • timezone information: Timezone information is provided in ANA Time Zone Database (often referred to as the Olson Database or TZ database) format. This format is more universally accepted. However, this format can also be converted to the GMT relative timezone information using tzinfo.

[1] country_name reference hash

countries = {'BD' => 'Bangladesh','BE' => 'Belgium','BF' => 'Burkina Faso','BG' => 'Bulgaria','BA' => 'Bosnia and Herzegovina','BB' => 'Barbados','WF' => 'Wallis and Futuna','BL' => 'Saint Barthelemy','BM' => 'Bermuda','BN' => 'Brunei','BO' => 'Bolivia','BH' => 'Bahrain','BI' => 'Burundi','BJ' => 'Benin','BT' => 'Bhutan','JM' => 'Jamaica','BV' => 'Bouvet Island','BW' => 'Botswana','WS' => 'Samoa','BQ' => 'Bonaire, Saint Eustatius and Saba ','BR' => 'Brazil','BS' => 'Bahamas','JE' => 'Jersey','BY' => 'Belarus','BZ' => 'Belize','RU' => 'Russia','RW' => 'Rwanda','RS' => 'Serbia','TL' => 'East Timor','RE' => 'Reunion','TM' => 'Turkmenistan','TJ' => 'Tajikistan','RO' => 'Romania','TK' => 'Tokelau','GW' => 'Guinea-Bissau','GU' => 'Guam','GT' => 'Guatemala','GS' => 'South Georgia and the South Sandwich Islands','GR' => 'Greece','GQ' => 'Equatorial Guinea','GP' => 'Guadeloupe','JP' => 'Japan','GY' => 'Guyana','GG' => 'Guernsey','GF' => 'French Guiana','GE' => 'Georgia','GD' => 'Grenada','GB' => 'United Kingdom','GA' => 'Gabon','SV' => 'El Salvador','GN' => 'Guinea','GM' => 'Gambia','GL' => 'Greenland','GI' => 'Gibraltar','GH' => 'Ghana','OM' => 'Oman','TN' => 'Tunisia','JO' => 'Jordan','HR' => 'Croatia','HT' => 'Haiti','HU' => 'Hungary','HK' => 'Hong Kong','HN' => 'Honduras','HM' => 'Heard Island and McDonald Islands','VE' => 'Venezuela','PR' => 'Puerto Rico','PS' => 'Palestinian Territory','PW' => 'Palau','PT' => 'Portugal','SJ' => 'Svalbard and Jan Mayen','PY' => 'Paraguay','IQ' => 'Iraq','PA' => 'Panama','PF' => 'French Polynesia','PG' => 'Papua New Guinea','PE' => 'Peru','PK' => 'Pakistan','PH' => 'Philippines','PN' => 'Pitcairn','PL' => 'Poland','PM' => 'Saint Pierre and Miquelon','ZM' => 'Zambia','EH' => 'Western Sahara','EE' => 'Estonia','EG' => 'Egypt','ZA' => 'South Africa','EC' => 'Ecuador','IT' => 'Italy','VN' => 'Vietnam','SB' => 'Solomon Islands','ET' => 'Ethiopia','SO' => 'Somalia','ZW' => 'Zimbabwe','SA' => 'Saudi Arabia','ES' => 'Spain','ER' => 'Eritrea','ME' => 'Montenegro','MD' => 'Moldova','MG' => 'Madagascar','MF' => 'Saint Martin','MA' => 'Morocco','MC' => 'Monaco','UZ' => 'Uzbekistan','MM' => 'Myanmar','ML' => 'Mali','MO' => 'Macao','MN' => 'Mongolia','MH' => 'Marshall Islands','MK' => 'Macedonia','MU' => 'Mauritius','MT' => 'Malta','MW' => 'Malawi','MV' => 'Maldives','MQ' => 'Martinique','MP' => 'Northern Mariana Islands','MS' => 'Montserrat','MR' => 'Mauritania','IM' => 'Isle of Man','UG' => 'Uganda','TZ' => 'Tanzania','MY' => 'Malaysia','MX' => 'Mexico','IL' => 'Israel','FR' => 'France','IO' => 'British Indian Ocean Territory','SH' => 'Saint Helena','FI' => 'Finland','FJ' => 'Fiji','FK' => 'Falkland Islands','FM' => 'Micronesia','FO' => 'Faroe Islands','NI' => 'Nicaragua','NL' => 'Netherlands','NO' => 'Norway','NA' => 'Namibia','VU' => 'Vanuatu','NC' => 'New Caledonia','NE' => 'Niger','NF' => 'Norfolk Island','NG' => 'Nigeria','NZ' => 'New Zealand','NP' => 'Nepal','NR' => 'Nauru','NU' => 'Niue','CK' => 'Cook Islands','XK' => 'Kosovo','CI' => 'Ivory Coast','CH' => 'Switzerland','CO' => 'Colombia','CN' => 'China','CM' => 'Cameroon','CL' => 'Chile','CC' => 'Cocos Islands','CA' => 'Canada','CG' => 'Republic of the Congo','CF' => 'Central African Republic','CD' => 'Democratic Republic of the Congo','CZ' => 'Czech Republic','CY' => 'Cyprus','CX' => 'Christmas Island','CR' => 'Costa Rica','CW' => 'Curacao','CV' => 'Cape Verde','CU' => 'Cuba','SZ' => 'Swaziland','SY' => 'Syria','SX' => 'Sint Maarten','KG' => 'Kyrgyzstan','KE' => 'Kenya','SS' => 'South Sudan','SR' => 'Suriname','KI' => 'Kiribati','KH' => 'Cambodia','KN' => 'Saint Kitts and Nevis','KM' => 'Comoros','ST' => 'Sao Tome and Principe','SK' => 'Slovakia','KR' => 'South Korea','SI' => 'Slovenia','KP' => 'North Korea','KW' => 'Kuwait','SN' => 'Senegal','SM' => 'San Marino','SL' => 'Sierra Leone','SC' => 'Seychelles','KZ' => 'Kazakhstan','KY' => 'Cayman Islands','SG' => 'Singapore','SE' => 'Sweden','SD' => 'Sudan','DO' => 'Dominican Republic','DM' => 'Dominica','DJ' => 'Djibouti','DK' => 'Denmark','VG' => 'British Virgin Islands','DE' => 'Germany','YE' => 'Yemen','DZ' => 'Algeria','US' => 'United States','UY' => 'Uruguay','YT' => 'Mayotte','UM' => 'United States Minor Outlying Islands','LB' => 'Lebanon','LC' => 'Saint Lucia','LA' => 'Laos','TV' => 'Tuvalu','TW' => 'Taiwan','TT' => 'Trinidad and Tobago','TR' => 'Turkey','LK' => 'Sri Lanka','LI' => 'Liechtenstein','LV' => 'Latvia','TO' => 'Tonga','LT' => 'Lithuania','LU' => 'Luxembourg','LR' => 'Liberia','LS' => 'Lesotho','TH' => 'Thailand','TF' => 'French Southern Territories','TG' => 'Togo','TD' => 'Chad','TC' => 'Turks and Caicos Islands','LY' => 'Libya','VA' => 'Vatican','VC' => 'Saint Vincent and the Grenadines','AE' => 'United Arab Emirates','AD' => 'Andorra','AG' => 'Antigua and Barbuda','AF' => 'Afghanistan','AI' => 'Anguilla','VI' => 'U.S. Virgin Islands','IS' => 'Iceland','IR' => 'Iran','AM' => 'Armenia','AL' => 'Albania','AO' => 'Angola','AQ' => 'Antarctica','AS' => 'American Samoa','AR' => 'Argentina','AU' => 'Australia','AT' => 'Austria','AW' => 'Aruba','IN' => 'India','AX' => 'Aland Islands','AZ' => 'Azerbaijan','IE' => 'Ireland','ID' => 'Indonesia','UA' => 'Ukraine','QA' => 'Qatar','MZ' => 'Mozambique'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant