wbstats
wbstats copied to clipboard
"Error: API call executed successfully, but did not return expected json format" when using wb_stat to download data
Hello,
when trying to download indicators using the command wb_data I receive the following error: Error: API call executed successfully, but did not return expected json format
For instance when I try to reproduce the line of code available in the help:
wb_data("NY.GDP.MKTP.CD")
I am having the same problem when using the package. However I try with the package WDI
and a similar problem happens:
With wbstats
:
library(wbstats)
wb_data(indicator = "NY.GDP.MKTP.CD",
country = "BR",
start_date = 2021,
end_date = 2021)
#> Error: API call executed successfully, but did not return expected json format
Created on 2024-02-18 with reprex v2.1.0
With WDI
library(WDI)
WDI(indicator = "NY.GDP.MKTP.CD",
country = "BR",
start = 2021,
end = 2021)
#> Error in WDI(indicator = "NY.GDP.MKTP.CD", country = "BR", start = 2021, : The following indicators could not be downloaded: NY.GDP.MKTP.CD.
#>
#> Please make sure that you are running the latest version of the `WDI` package, and that the arguments you are using in the `WDI()` function are valid.
#>
#> Sometimes, downloads will suddenly stop working, even if nothing has changed in the R code of the WDI package. ("The same WDI package version worked yesterday!") In those cases, the problem is almost certainly related to the World Bank servers or to your internet connection.
#>
#> You can check if the World Bank web API is currently serving the indicator(s) of interest by typing a URL of this form in your web browser:
#>
#> https://api.worldbank.org/v2/en/country/all/indicator/NY.GDP.MKTP.CD?format=json&date=:&per_page=32500&page=1
Created on 2024-02-18 with reprex v2.1.0
I think the problem is in te API taking into account that a similar problem happens with the package wbgapi
from Python:
import wbgapi as wb
wb.data.DataFrame(series = "NY.GDP.MKTP.CD",
economy = "BRA",
time = range(2021, 2021))
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\Usuario\ANACON~1\Lib\site-packages\wbgapi_init_.py", line 533, in _queryAPI result = response.json() ^^^^^^^^^^^^^^^ File "C:\Users\Usuario\ANACON~1\Lib\site-packages\requests\models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 8 column 1 (char 9)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "
Apparently the problem has been solve. Now the data can be downloaded without problem.