Open mahmouddraz opened 4 years ago
Hello @mahmouddraz , thanks for reporting this. Indeed I can reproduce the issue.
It looks like the request is not correct.
The URL built by the get_indicator
function is e.g. http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/reporter/usa/year/2017/partner/wld/product/all/indicator/WRLD_GRWTH?format=JSON, but this results in an error
<string>
<wits:error xmlns:wits="http://wits.worldbank.org"> <wits:message id="150" key="Invalid Indicator Code.">The provided Indicator code parameter value is not valid.</wits:message> </wits:error>
</string>
Do you have any idea what should be the correct URL? On my side, I can try to improve the error reporting - it would be more user-friendly if this resulted in an error The provided Indicator code parameter value is not valid rather that what it is currently...
Sorry above I misspelled the indicator, it should have been WRLD-GRWTH
, not WRLD_GRWTH
. So the error in that case was right.
For another indicator NMBR-XPRT-PRTNR
, I can get a similar ConnectionResetError
if we don't put the right partner
. I mean, the first URL below gives, in firefox, an issue The connection was reset while the second one, with partner=999
, works:
So we could have thought that the connection reset was in fact a signal that we don't have the proper value for one or more field in the URL.
In the case of TRD-CMPLMNTRTY-NDX
, a first indication is that the table get_indicators()
states that product should be 999999. But even if we try with this we can't get the URL to work... Below is what I tried:
Method | URL | Status (Firefox) | |
---|---|---|---|
Starting point | http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/reporter/usa/year/2017/partner/wld/product/all/indicator/TRD-CMPLMNTRTY-NDX?format=JSON | The connection was reset | |
product=999999 | http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/reporter/usa/year/2017/partner/wld/product/999999/indicator/TRD-CMPLMNTRTY-NDX?format=JSON | The connection was reset | * |
No product | http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/reporter/usa/year/2017/partner/wld/indicator/TRD-CMPLMNTRTY-NDX?format=JSON | The connection was reset | |
No product, no reporter | http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/year/2017/partner/usa/indicator/TRD-CMPLMNTRTY-NDX?format=JSON | Forbidden (403) | |
Product=999999, Canada to USA | http://wits.worldbank.org/API/V1/SDMX/V21/datasource/tradestats-trade/reporter/can/year/2017/partner/usa/product/999999/indicator/TRD-CMPLMNTRTY-NDX?format=JSON | The connection was reset |
It seems that TRD-CMPLMNTRTY-NDX
is the only indicator with that issue. Maybe what we should do next is to talk with the people that maintain the WITS website and API, don't you think?
I am getting the same error but with different metrics.
wits_nat_code_list =['USA','ALB','DZA','ASM']
count = 0
for code in wits_nat_code_list:
for year in range(1988,2021):
im = wits.get_indicator('XPRT-TRD-VL', reporter=code, year = str(year),partner='All')
ex = wits.get_indicator('MPRT-TRD-VL', reporter=code, year = str(year),partner='All')
If I run get_indicator() outside of the loop, it works more often, but still throws the error some.
Here is the error:
requests.exceptions.ChunkedEncodingError: ("Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
I am trying to use the python package for world trade data posted on your GitHub. When I try to call the function get_indicator() for specific indicator(‘TRD-CMPLMNTRTY-NDX’), it raises an error.
Here is the error,
requests.exceptions.ChunkedEncodingError:
("Connection broken: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)", ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))