Skip to content

Commit faa2a02

Browse files
authored
Merge pull request #456 from bashtage/update-world-bank
CLN: Update WorldBank endpoint
2 parents c8a087d + d5bfd39 commit faa2a02

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pandas_datareader/tests/test_wb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_wdi_get_indicators(self):
210210

211211
for result in [result1, result2, result3, result4]:
212212
exp_col = pd.Index(['id', 'name', 'source', 'sourceNote',
213-
'sourceOrganization', 'topics'])
213+
'sourceOrganization', 'topics', 'unit'])
214214
# assert_index_equal doesn't exists
215215
assert result.columns.equals(exp_col)
216216
assert len(result) > 10000

pandas_datareader/wb.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
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+
1719
country_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

Comments
 (0)