DBnomics.rdb
— Functionrdb(
provider_code::Union{Array, String, Nothing} = nothing,
dataset_code::Union{String, Nothing} = nothing,
mask_arg::Union{String, Nothing} = nothing;
ids::Union{Array, String, Nothing} = nothing,
dimensions::Union{Dict, NamedTuple, String, Nothing} = nothing,
mask::Union{String, Nothing} = nothing,
query::Union{String, Nothing} = nothing,
api_link::Union{String, Nothing} = nothing,
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
filters::Union{Nothing, Dict, Tuple} = DBnomics.filters,
kwargs...
)
rdb
downloads data series from DBnomics using shortcuts like ids
, dimensions
, mask
, query
or using an api_link
.
This function gives you access to hundreds of millions data series from DBnomics. The code of each series is given on the DBnomics website.
In the event that the shortcut ids
is used then the argument name can be dropped and the ids
will be passed through provider_code
.
If only the argument api_link
is provided, then the argument name can be dropped. The string is directly passed to api_link
.
In the same way, if only provider_code
, dataset_code
and mask
are used then the arguments names can be dropped. The mask
will be passed through mask_arg
.
By default, the function returns a DataFrame
.
Arguments
provider_code::Union{Array, String, Nothing} = nothing
: DBnomics code of the provider.dataset_code::Union{String, Nothing} = nothing
: DBnomics code of the dataset.mask_arg::Union{String, Nothing} = nothing
: DBnomics code of one or several masks in the specified provider and dataset. It is used if the arguments names are not given.ids::Union{Array, String, Nothing} = nothing
: DBnomics code of one or several series.dimensions::Union{Dict, NamedTuple, String, Nothing} = nothing
: DBnomics code of one or several dimensions in the specified provider and dataset. If it is aDict
or aNamedTuple
, then then functionjson
(from the package JSON.jl) is applied to generate the json object.mask::Union{String, Nothing} = nothing
: DBnomics code of one or several masks in the specified provider and dataset.query::Union{String, Nothing} = nothing
: A query to filter/select series from a provider's dataset.api_link::Union{String, Nothing} = nothing
: DBnomics API link of the search. It should starts withhttp://
orhttps://
.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
orHTTP.post
of the package HTTP.jl.filters::Union{Nothing, Dict, Tuple} = DBnomics.filters
: (defaultnothing
) This argument must be aDict
for one filter because the functionjson
of the package JSON.jl is used before sending the request to the server. For multiple filters, you have to provide aTuple
of valid filters (see examples). A valid filter is aDict
with a keycode
which value is a character string, and a keyparameters
which value is aDict
with keysfrequency
andmethod
ornothing
.kwargs...
: Keyword arguments to be passed toHTTP.get
orHTTP.post
.
Examples
## By ids
julia> df1 = rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN");
# or
julia> df1 = rdb("AMECO/ZUTN/EA19.1.0.0.0.ZUTN");
julia> df2 = rdb(ids = ["AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "AMECO/ZUTN/DNK.1.0.0.0.ZUTN"]);
julia> df3 = rdb(ids = ["AMECO/ZUTN/EA19.1.0.0.0.ZUTN", "IMF/BOP/A.FR.BCA_BP6_EUR"]);
## By dimensions
julia> df1 = rdb("AMECO", "ZUTN", dimensions = Dict(:geo => "ea12"));
# or
julia> df1 = rdb("AMECO", "ZUTN", dimensions = (geo = "ea12",));
julia> df2 = rdb("AMECO", "ZUTN", dimensions = Dict(:geo => ["ea12", "dnk"]));
# or
julia> df2 = rdb("AMECO", "ZUTN", dimensions = (geo = ["ea12", "dnk"],));
julia> dim = Dict(:country => ["DZ", "PE"], :indicator => ["ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS"]);
julia> df3 = rdb("WB", "DB", dimensions = dim);
# or
julia> dim = (country = ["DZ", "PE"], indicator = ["ENF.CONT.COEN.COST.ZS", "IC.REG.COST.PC.FE.ZS"]);
julia> df3 = rdb("WB", "DB", dimensions = dim);
## By mask
julia> df1 = rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR");
# or
julia> df1 = rdb("IMF", "BOP", "A.FR.BCA_BP6_EUR");
julia> df2 = rdb("IMF", "BOP", mask = "A.FR+ES.BCA_BP6_EUR");
julia> df3 = rdb("IMF", "BOP", mask = "A..BCA_BP6_EUR");
julia> df4 = rdb("IMF", "BOP", mask = "A.FR.BCA_BP6_EUR+IA_BP6_EUR");
## By query
julia> df1 = rdb("IMF", "WEO:2019-10", query = "France current account balance percent");
julia> df2 = rdb("IMF", "WEO:2019-10", query = "current account balance percent");
## By api_link
julia> df1 = rdb(api_link = "https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22indicator%22%3A%5B%22IC.REG.PROC.FE.NO%22%5D%7D&q=Doing%20Business&observations=1&format=json&align_periods=1&offset=0&facets=0");
# or
julia> df2 = rdb("https://api.db.nomics.world/v22/series/WB/DB?dimensions=%7B%22indicator%22%3A%5B%22IC.REG.PROC.FE.NO%22%5D%7D&q=Doing%20Business&observations=1&format=json&align_periods=1&offset=0&facets=0");
## Use proxy with curl
julia> h = Dict(:proxy => "http://<proxy>:<port>");
julia> DBnomics.options("curl_config", h);
julia> df1 = rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN");
# or
julia> df1 = rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", curl_config = h);
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);
## Use readlines and download
julia> DBnomics.options("use_readlines", true);
julia> df1 = rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN");
# or
julia> df1 = rdb(ids = "AMECO/ZUTN/EA19.1.0.0.0.ZUTN", use_readlines = true);
## Apply a filter to the series
# One filter
julia> filters = Dict(:code => "interpolate", :parameters => Dict(:frequency => "daily", :method => "spline"));
julia> df1 = rdb(ids = ["IMF/WEO:2019-10/ABW.BCA.us_dollars", "IMF/WEO:2019-10/ABW.NGDPD.us_dollars"], filters = filters);
# For two filters
julia> filter1 = Dict(:code => "interpolate", :parameters => Dict(:frequency => "quarterly", :method => "spline"));
julia> filter2 = Dict(:code => "aggregate", :parameters => Dict(:frequency => "annual", :method => "average"));
julia> filters = (filter1, filter2);
julia> df1 = rdb(ids = ["IMF/WEO:2019-10/ABW.BCA.us_dollars", "IMF/WEO:2019-10/ABW.NGDPD.us_dollars"], filters = filters);
julia> filter1 = Dict(:code => "interpolate", :parameters => Dict(:frequency => "monthly", :method => "linear"));
julia> filter2 = Dict(:code => "x13", :parameters => nothing);
julia> filters = (filter1, filter2);
julia> df1 = rdb("ECB/EXR/A.AUD.EUR.SP00.A", filters = filters);
DBnomics.rdb_datasets
— Functionrdb_datasets(
provider_code::Union{Nothing, String, Array} = nothing;
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
simplify::Bool = false,
kwargs...
)
rdb_datasets
downloads the list of available datasets for a selection of providers (or all of them) from DBnomics.
By default, the function returns a Dict
of DataFrame
s containing the datasets of the providers from DBnomics.
Arguments
provider_code::Union{Nothing, String, Array} = nothing
: DBnomics code of one or multiple providers. Ifnothing
, the providers are firstly dowloaded with the functionrdb_providers
and then the available datasets are requested.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
of the package HTTP.jl.simplify::Bool = false
: Iftrue
, when the datasets are requested for only one provider then aDataFrame
is returned, not aDict
ofDataFrame
s.kwargs...
: Keyword arguments to be passed toHTTP.get
.
Examples
julia> rdb_datasets("IMF")
julia> rdb_datasets("IMF", simplify = true)
julia> rdb_datasets(["IMF", "BDF"])
julia> using ProgressMeter
julia> rdb_datasets()
julia> rdb_datasets("IMF", use_readlines = true)
julia> rdb_datasets("IMF", curl_config = Dict(:proxy => "http://<proxy>:<port>"))
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);
DBnomics.rdb_dimensions
— Functionrdb_dimensions(
provider_code::Union{Nothing, String, Array} = nothing,
dataset_code::Union{Nothing, String, Array} = nothing;
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
simplify::Bool = false,
kwargs...
)
rdb_dimensions
downloads the list of dimensions (if they exist) for available datasets of a selection of providers from DBnomics.
By default, the function returns a nested Dict
of DataFrame
s containing the dimensions of datasets for providers from DBnomics.
Arguments
provider_code::Union{Nothing, String, Array} = nothing
: DBnomics code of one or multiple providers. Ifnothing
, the providers are firstly dowloaded with the functionrdb_providers
and then the available datasets are requested.dataset_code::Union{Nothing, String, Array} = nothing
: DBnomics code of one or multiple datasets of a provider. Ifnothing
, the datasets codes are dowloaded with the functionrdb_datasets
and then the dimensions are requested.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
of the package HTTP.jl.simplify::Bool = false
: Iftrue
, when the dimensions are requested for only one provider and one dataset then aDict
ofDataFrame
s is returned, not a nestedDict
ofDataFrame
s.kwargs...
: Keyword arguments to be passed toHTTP.get
.
Examples
julia> rdb_dimensions("IMF", "WEO:2019-10")
julia> rdb_dimensions("IMF", "WEO:2019-10", simplify = true)
julia> rdb_dimensions("IMF")
# It is very long !
julia> using ProgressMeter
julia> rdb_dimensions()
julia> rdb_dimensions("IMF", "WEO:2019-10", use_readlines = true)
julia> rdb_dimensions("IMF", "WEO:2019-10", curl_config = Dict(:proxy => "http://<proxy>:<port>"))
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);
DBnomics.rdb_last_updates
— Functionrdb_last_updates(
all_updates::Bool = false;
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
kwargs...
)
rdb_last_updates
downloads informations about the last updates from DBnomics
By default, the function returns a DataFrame
containing the last 100 updates from DBnomics with additional informations.
Arguments
all_updates::Bool = false
: Iftrue
, then the full dataset of the last updates is retrieved.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
of the package HTTP.jl.kwargs...
: Keyword arguments to be passed toHTTP.get
.
Examples
julia> rdb_last_updates();
julia> rdb_last_updates(true);
julia> rdb_last_updates(use_readlines = true);
julia> rdb_last_updates(curl_config = Dict(:proxy => "http://<proxy>:<port>"));
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);
DBnomics.rdb_providers
— Functionrdb_providers(
code::Bool = false;
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
kwargs...
)
rdb_providers
downloads the list of providers from DBnomics.
By default, the function returns a DataFrame
containing the list of providers from DBnomics with additional informations such as the region, the website, etc.
Arguments
code::Bool = false
: Iftrue
, then only the providers are returned in an array.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
of the package HTTP.jl.kwargs...
: Keyword arguments to be passed toHTTP.get
.
Examples
julia> rdb_providers()
julia> rdb_providers(true)
julia> rdb_providers(use_readlines = true)
julia> rdb_providers(curl_config = Dict(:proxy => "http://<proxy>:<port>"))
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);
DBnomics.rdb_series
— Functionrdb_series(
provider_code::Union{Nothing, String, Array} = nothing,
dataset_code::Union{Nothing, String, Array} = nothing;
dimensions::Union{Dict, NamedTuple, String, Nothing} = nothing,
query::Union{String, Nothing} = nothing,
use_readlines::Bool = DBnomics.use_readlines,
curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config,
simplify::Bool = false,
kwargs...
)
rdb_series
downloads the list of series for available datasets of a selection of providers from DBnomics.
We warn the user that this function can be (very) long to execute. We remind that DBnomics requests data from 63 providers to retrieve 21675 datasets for a total of approximately 720 millions series.
By default, the function returns a nested Dict
of DataFrame
s containing the series of datasets for providers from DBnomics.
Arguments
provider_code::Union{Nothing, String, Array} = nothing
: DBnomics code of one or multiple providers. Ifnothing
, the providers are firstly dowloaded with the functionrdb_providers
and then the available datasets are requested.dataset_code::Union{Nothing, String, Array} = nothing
: DBnomics code of one or multiple datasets of a provider. Ifnothing
, the datasets codes are dowloaded with the functionrdb_datasets
and then the series are requested.dimensions::Union{Dict, NamedTuple, String, Nothing} = nothing
: DBnomics code of one or several dimensions in the specified provider and dataset. If it is aDict
or aNamedTuple
, then then functionjson
(from the package JSON.jl) is applied to generate the json object.query::Union{String, Nothing} = nothing
: A query to filter/select series from a provider's dataset.use_readlines::Bool = DBnomics.use_readlines
: (defaultfalse
) Iftrue
, then the data are requested and read with the functionreadlines
.curl_config::Union{Nothing, Dict, NamedTuple} = DBnomics.curl_config
: (defaultnothing
) If notnothing
, it is used to configure a proxy connection. This configuration is passed to the keyword arguments of the functionHTTP.get
of the package HTTP.jl.simplify::Bool = false
: Iftrue
, when the dimensions are requested for only one provider and one dataset then aDict
ofDataFrame
s is returned, not a nestedDict
ofDataFrame
s.kwargs...
: Keyword arguments to be passed toHTTP.get
.
Examples
julia> rdb_series("IMF", "WEO:2019-10")
# With dimensions
julia> rdb_series("IMF", "WEO:2019-10", dimensions = Dict(Symbol("weo-country") => "AGO"))
julia> rdb_series("IMF", "WEO:2019-10", dimensions = Dict(Symbol("weo-subject") => "NGDP_RPCH"), simplify = true)
# With query
julia> rdb_series("IMF", "WEO:2019-10", query = "ARE")
julia> rdb_series("IMF", ["WEO:2019-10", "WEOAGG:2019-10"], query = "NGDP_RPCH")
julia> using ProgressMeter
julia> rdb_series("IMF", "WEO:2019-10")
julia> rdb_series("IMF", "WEO:2019-10", use_readlines = true)
julia> rdb_series("IMF", "WEO:2019-10", curl_config = Dict(:proxy => "http://<proxy>:<port>"))
# Regarding the functioning of HTTP.jl, you might need to modify another option
# It will change the url from https:// to http://
# (https://github.com/JuliaWeb/HTTP.jl/pull/390)
julia> DBnomics.options("secure", false);