1414# 3-digit ISO 3166-1 alpha-3, codes, with 'all', 'ALL', and 'All' appended ot
1515# the end.
1616
17+ WB_API_URL = 'https://api.worldbank.org/v2'
18+
1719country_codes = ['AD' , 'AE' , 'AF' , 'AG' , 'AI' , 'AL' , 'AM' , 'AO' , 'AQ' , 'AR' ,
1820 'AS' , 'AT' , 'AU' , 'AW' , 'AX' , 'AZ' , 'BA' , 'BB' , 'BD' , 'BE' ,
1921 'BF' , 'BG' , 'BH' , 'BI' , 'BJ' , 'BL' , 'BM' , 'BN' , 'BO' , 'BQ' ,
@@ -158,8 +160,7 @@ def __init__(self, symbols=None, countries=None,
158160 @property
159161 def url (self ):
160162 countries = ';' .join (self .countries )
161- return ("http://api.worldbank.org/countries/" +
162- countries + "/indicators/" )
163+ return WB_API_URL + '/countries/' + countries + '/indicators/'
163164
164165 @property
165166 def params (self ):
@@ -251,7 +252,7 @@ def get_countries(self):
251252 country code, region, income level,
252253 capital city, latitude, and longitude
253254 """
254- url = 'http://api.worldbank.org /countries/?per_page=1000&format=json'
255+ url = WB_API_URL + ' /countries/?per_page=1000&format=json'
255256
256257 resp = self ._get_response (url )
257258 data = resp .json ()[1 ]
@@ -274,7 +275,7 @@ def get_indicators(self):
274275 if isinstance (_cached_series , pd .DataFrame ):
275276 return _cached_series .copy ()
276277
277- url = 'http://api.worldbank.org /indicators?per_page=50000&format=json'
278+ url = WB_API_URL + ' /indicators?per_page=50000&format=json'
278279
279280 resp = self ._get_response (url )
280281 data = resp .json ()[1 ]
0 commit comments