A python package for retrieving data from all the countries in the world.
pip install countrydetails
There are 2 modules -
- Retrieving data of all countries (Module Countries)
- Retrieving data of a single country (Module Country)
- countries()
- phone_code()
- currencies()
- capitals()
- continents()
- countries_in_continents()
- regions()
- countries_in_region()
- states()
- info()
- name()
- states()
- cities()
- states_and_cities()
- iso()
- alt_spelling()
- area()
- borders()
- capital()
- calling_codes()
- independence()
- currency()
- capital_latlng()
- demonym()
- flag()
- languages()
- latlang()
- native_name()
- population()
- timezones()
- tld()
- translations()
- continents()
- temperature()
- government()
- expectancy()
- dish()
- symbol()
- desnity()
- region()
- religion()
- total_states()
- total_cities()
- wiki()
- gei_json()
- all()
For the sake of simplicity, I will be showing less data in outputs here.
Returns the list of all available countries in the world
from Countrydetails import countries
data = countries.all_countries()
data.countries()
['Afghanistan', 'Aland Islands', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua And Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas The', 'Vietnam', 'Virgin Islands (British)', 'Virgin Islands (US)', 'Wallis And Futuna Islands', 'Western Sahara', 'Yemen', 'Zambia', 'Zimbabwe']
Returns phone codes of each country in a dictionary
from countrydetails import countries
country = countries.all_countries()
print(country.phone_code())
{'Afghanistan': '93', 'Aland Islands': '+358-18', 'Albania': '355', 'Algeria': '213', 'American Samoa': '+1-684', 'Andorra': '376', 'Angola': '244', 'Anguilla': '+1-264', 'Antarctica': '', 'Antigua And Barbuda': '+1-268', 'Argentina': '54', 'Armenia': '374', 'Aruba': '297', 'Australia': '61', 'Austria': '43', 'Azerbaijan': '994', 'Bahamas The': '+1-242', 'Bahrain': '973', 'Bangladesh': '880',
Returns currencies of each country in a dictionary
from countrydetails import countries
country = countries.all_countries()
print(country.currencies())
{'Afghanistan': 'AFN', 'Aland Islands': 'EUR', 'Albania': 'ALL', 'Algeria': 'DZD', 'American Samoa': 'USD', 'Andorra': 'EUR', 'Angola': 'AOA', 'Anguilla': 'XCD', 'Antarctica': '', 'Antigua And Barbuda': 'XCD', 'Argentina': 'ARS', 'Belgium': 'EUR', 'Belize': 'BZD', 'Benin': 'XOF', 'Bermuda': 'BMD', 'Bhutan': 'BTN', 'Bolivia': 'BOB', 'Bosnia and Herzegovina': 'BAM', 'Botswana': 'BWP',
Returns captial cities of each country in a dictionary
from countrydetails import countries
country = countries.all_countries()
print(country.capitals())
{'Afghanistan': 'Kabul', 'Aland Islands': 'Mariehamn', 'Albania': 'Tirana', 'Algeria': 'Algiers', 'American Samoa': 'Pago Pago', 'Andorra': 'Andorra la Vella', 'Angola': 'Luanda', 'Anguilla': 'The Valley', 'Antarctica': '', 'Antigua And Barbuda': "St. John's", 'Bahamas The': 'Nassau', 'Bahrain': 'Manama', 'Bangladesh': 'Dhaka', 'Barbados': 'Bridgetown', 'Belarus': 'Minsk', 'Belgium': 'Brussels', 'Belize': 'Belmopan',
Returns continents of each country
from countrydetails import countries
country = countries.all_countries()
print(country.continents())
[{'country': 'Afghanistan', 'continent': 'Asia'}, {'country': 'Albania', 'continent': 'Europe'}, {'country': 'Algeria', 'continent': 'Africa'}, {'country': 'American Samoa', 'continent': 'Oceania'}, {'country': 'Andorra', 'continent': 'Europe'}, {'country': 'Angola', 'continent': 'Africa'}, {'country': 'Anguilla', 'continent': 'North America'},{'country': 'Antarctica', 'continent': 'Antarctica'}],
Returns a list of countries present in a continent
from countrydetails import countries
country = countries.all_countries()
print(country.countries_in_continents())
{'Asia': ['Afghanistan', 'Armenia', 'Azerbaijan', 'Bahrain', 'Bangladesh', 'Bhutan', 'Brunei', 'Cambodia', 'China', 'Cyprus', 'East Timor', 'Georgia', 'Hong Kong', 'India', 'Indonesia', 'Iran', 'Iraq', 'Israel', 'Japan', 'Jordan', 'Kazakhstan', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Lebanon', 'Tajikistan', 'Thailand', 'Turkey', 'Turkmenistan', 'United Arab Emirates', 'Uzbekistan', 'Vietnam', 'Yemen']
Returns countries with its region
from countrydetails import countries
country = countries.all_countries()
print(country.regions())
[{'country': 'Afghanistan', 'location': 'Southern and Central Asia'}, {'country': 'Albania', 'location': 'Southern Europe'}, {'country': 'Algeria', 'location': 'Northern Africa'}, {'country': 'American Samoa', 'location': 'Polynesia'}, {'country': 'Andorra', 'location': 'Southern Europe'}, {'country': 'Aruba', 'location': 'Caribbean'}, {'country': 'Australia', 'location': 'Australia and New Zealand'},
Returns list of countries present in its region
from countrydetails import countries
country = countries.all_countries()
print(country.countries_in_region())
{'Antarctica': ['Antarctica', 'Heard Island and McDonald Islands', 'South Georgia and the South Sandwich Islands'], 'Eastern Europe': ['Belarus', 'Hungary', 'Moldova', 'Poland', 'Romania', 'Ukraine'], 'Southern Europe': ['Albania', 'Andorra', 'Italy', 'North Macedonia', 'Yugoslavia'], 'Western Europe': ['Austria', 'Belgium', 'France', 'Germany', 'Liechtenstein', 'Switzerland'], 'North America': ['Bermuda', 'United States'],
Returns all the available states in the world with its state code
from countrydetails import countries
country = countries.all_countries()
print(country.states())
{'id': 1836, 'name': 'Nenets Autonomous Okrug', 'state_code': 'NEN'}, {'id': 1857, 'name': 'Nizhny Novgorod Oblast', 'state_code': 'NIZ'}, {'id': 1834, 'name': 'Novgorod Oblast', 'state_code': 'NGR'}, {'id': 1888, 'name': 'Novosibirsk', 'state_code': 'NVS'}, {'id': 1846, 'name': 'Omsk Oblast', 'state_code': 'OMS'}, {'id': 1886, 'name': 'Orenburg Oblast', 'state_code': 'ORE'}, {'id': 1908, 'name': 'Oryol Oblast', 'state_code': 'ORL'}, {'id': 1909, 'name': 'Penza Oblast', 'state_code': 'PNZ'}, {'id': 1871, 'name': 'Perm Krai', 'state_code': 'PER'}, {'id': 1833, 'name': 'Primorsky Krai', 'state_code': 'PRI'}, {'id': 1863, 'name': 'Pskov Oblast', 'state_code': 'PSK'}, {'id': 1852, 'name': 'Republic of Adygea', 'state_code': 'AD'}
from Countrydetails import country
country = country.country_details('India') #you can give your desired country
print(country.info())
# Returns the data present below in a dict
Returns the name of the country
from Countrydetails import country
country = country.country_details('India')
print(country.name())
India
Returns all available in a states list
from Countrydetails import country
country = country.country_details('India')
print(country.states())
['Andaman and Nicobar Islands', 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Dadra and Nagar Haveli', 'Daman and Diu', 'Delhi', 'Goa', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Ladakh', 'Lakshadweep', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura',
'Uttar Pradesh', 'Uttarakhand', 'West Bengal']
Returns all available cities in a list
from Countrydetails import country
country = country.country_details('India')
print(country.cities())
# I am just displaying just a part of information here due to huge huge data
['Bamboo Flat', 'Nicobar', 'Port Blair', 'South Andaman', 'Addanki', 'Δdoni', 'Akasahebpet', 'AkivΔ«du', 'Akkarampalle', 'AmalΔpuram', 'AmudΔlavalasa', 'AnakΔpalle', 'Anantapur', 'AtmakΕ«r', 'Attili', 'Avanigadda', 'Badvel', 'Banganapalle', 'BΔpatla', 'Betamcherla', 'Bhattiprolu', 'BhΔ«mavaram', 'BhΔ«munipatnam', 'Bobbili', 'Challapalle', 'Chemmumiahpet', 'ChilakalΕ«rupet', 'Chinnachowk', 'ChΔ«purupalle', 'ChΔ«rΔla', 'Chittoor', 'Diguvametta', 'East GodΔvari', 'Elamanchili', 'Puttaparthi', 'PuttΕ«r', 'RΔjahmundry', 'Takdah', 'Taki', 'Tamluk', 'Tarakeswar', 'Titagarh', 'Tufanganj', 'Tulin', 'Uchalan', 'Ula', 'Uluberia', 'Uttar Dinajpur district', 'Uttarpara Kotrung']
Returns states and cities in a dict
from Countrydetails import country
country = country.country_details('India')
print(country.states_and_cities())
# I am just displaying just a part of information here due to huge huge data
[{'id': 142095, 'name': 'South 24 Parganas district', 'latitude': '22.16197000', 'longitude': '88.43170000'}, {'id': 142096, 'name': 'Srikhanda', 'latitude': '23.60000000', 'longitude': '88.08330000'}, {'id': 142097, 'name': 'Srirampur', 'latitude': '23.35000000', 'longitude': '88.12000000'}, {'id': 142098, 'name': 'Suri', 'latitude': '23.91666667', 'longitude': '87.53333333'}, {'id': 142099, 'name': 'Swarupnagar community development block', 'latitude': '22.83330000', 'longitude': '88.86670000'}, {'id': 142100, 'name': 'Takdah', 'latitude': '27.03330000', 'longitude': '88.36670000'}, ]}]
Returns ISO codes for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.iso())
{'alpha2': 'IN', 'alpha3': 'IND'}
Returns alternate spellings for the name of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.alt_spellings())
['IN', 'BhΔrat', 'Republic of India', 'Bharat Ganrajya']
Returns area (kmΒ²) for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.area())
3287590
Returns bordering countries (ISO3) for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.borders())
['AFG', 'BGD', 'BTN', 'MMR', 'CHN', 'NPL', 'PAK', 'LKA']
Returns capital city for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.capital())
New Delhi
from Countrydetails import country
country = country.country_details('India')
print(country.calling_codes())
["91"]
Returns independence year for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.independence())
1947
Returns official currency for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.currency())
['INR']
Returns capital city latitude and longitude for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.capital_latlng())
[28.614179, 77.202266]
Returns the demonyms for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.demonym())
Indian
Returns SVG link of the official flag for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.flag())
Sorry there is no link for indain flag :(
Returns all spoken languages for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.languages())
['Asami', 'Bengali', 'Gujarati', 'Hindi', 'Kannada', 'Malayalam', 'Marathi', 'Odia', 'Punjabi', 'Tamil', 'Telugu', 'Urdu', 'Sanskrit', 'English', 'Konkani', 'Nepali', 'Bodo', 'Kashmiri', 'Maithili', 'Santali', 'Sindhi']
Returns approx latitude and longitude for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.latlng())
[20, 77]
Returns the name of the country in its native tongue
from Countrydetails import country
country = country.country_details('India')
print(country.native_name())
ΰ€ΰ€Ύΰ€°ΰ€€
Returns the population of the specified country
from Countrydetails import country
country = country.country_details('India')
print(country.population())
1263930000
Returns the timezones of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.timezones())
['UTC+05:30']
Returns the domain extension of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.tld())
['.in']
Returns translations of a given country
from Countrydetails import country
country = country.country_details('India')
print(country.translations())
{'de': 'Indien', 'es': 'India', 'fr': 'Inde', 'ja': 'γ€γ³γ', 'it': 'India'}
Returns the continent of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.continent())
Asia
Returns the average temperature for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.temperature())
23.65
Returns the type of government for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.government())
Federal Republic
Returns the life expectancy of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.expectancy())
62.5
Returns the national dish of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.dish())
No officially announced national dish
Returns the national symbol of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.symbol())
animal
Returns the density of a specified country in sq km
from Countrydetails import country
country = country.country_details('India')
print(country.density())
454.9380726
Returns the region of a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.region())
Southern and Central Asia
Returns the religion of the specified country
from Countrydetails import country
country = country.country_details('India')
print(country.religion())
Hinduism
Returns the total number of states for the specified country
from Countrydetails import country
country = country.country_details('India')
print(country.total_states())
37 #including union territories
Return total numnber of cities for the specified country
from Countrydetails import country
country = country.country_details('India')
print(country.total_cities())
3865
Returns the Wikipedia page link for the specified country
from Countrydetails import country
country = country.country_details('India')
print(country.wiki())
http://en.wikipedia.org/wiki/india
Returns the every available data of all the countries in the world
from Countrydetails import country
country = country.country_details()
print(country.all())
# I am not displaying the output here as the data is enormous. You can try it yourself :)
Returns geoJSON for a specified country
from Countrydetails import country
country = country.country_details('India')
print(country.geo_json())
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "IND",
"properties": {
"name": "India"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
77.837451,
35.49401
],
[
78.912269,
34.321936
],
[
78.811086,
33.506198
],
[
77.837451,
35.49401
]
]
]
}
}
]
},
A Passionate Python & Full Stack Developer