Friday, September 5, 2014

Access world bank data with world bank API

1- world bank API  -- python

2- Sample script to retrieve data

from worldbank import WorldBank
#import WorldBank

wb = WorldBank()   
brazil = wb.get_country(code='br')    #gets general data on brazil
brazil_gdp = wb.get_country(code='br', indicator='NY.GDP.MKTP.CD')    #GDP of Brazil in US dollars
indicators = wb.get_indicators()    #a list of all the indicators

print brazil_gdp
print "**" * 10
print indicators

data = wb.get_country(code='all') #gets general data on all country
all_gdp = wb.get_country(code="all") #gets GDP data on all country

print data
print all_gdp

3- save and execute you will get json data

No comments:

Post a Comment