Back to articles
World Bank Has a Free API — GDP, Population, and Economic Data for Every Country

World Bank Has a Free API — GDP, Population, and Economic Data for Every Country

via Dev.to PythonAlex Spinov

Need GDP data for 200+ countries? Population growth rates? Poverty statistics? Inflation trends? The World Bank has been collecting economic data since 1960. And it is all available through a free API. No key. No signup. What Data Is Available? GDP, GNI, inflation for every country since 1960 Population, life expectancy, mortality rates Education, literacy, school enrollment statistics Trade, exports, imports data Poverty headcount ratios 16,000+ indicators across 200+ countries Quick Start import requests # GDP of the United States (last 5 years) response = requests . get ( " https://api.worldbank.org/v2/country/US/indicator/NY.GDP.MKTP.CD " , params = { " format " : " json " , " per_page " : 5 , " date " : " 2019:2023 " } ) data = response . json ()[ 1 ] for entry in data : year = entry [ " date " ] gdp = entry [ " value " ] if gdp : print ( f " { year } : $ { gdp / 1e12 : . 2 f } trillion " ) Output: 2023: $27.36 trillion 2022: $25.46 trillion 2021: $23.32 trillion 2020: $21.06 tril

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
7 views

Related Articles