diff --git a/sdmxthon/api/api.py b/sdmxthon/api/api.py index 80a0a70..1cd4a1e 100644 --- a/sdmxthon/api/api.py +++ b/sdmxthon/api/api.py @@ -137,4 +137,8 @@ def get_supported_agencies(): 'BIS': webservices.BisWs, 'ECB': webservices.EcbWs, 'ESTAT': webservices.EuroStatWs, - 'ILO': webservices.IloWs} + 'ILO': webservices.IloWs, + 'OECD': webservices.OecdWs, + 'OECDv2': webservices.OecdWs2, + 'UNICEF': webservices.UnicefWs, + } diff --git a/sdmxthon/webservices/query_builder.py b/sdmxthon/webservices/query_builder.py index 06a1c9f..52607e0 100644 --- a/sdmxthon/webservices/query_builder.py +++ b/sdmxthon/webservices/query_builder.py @@ -97,8 +97,9 @@ def get_data_flows(self, agency_id, resources=None, version=None, references=None, detail=None) -> str: resources = resources if resources else "all" version = version if version else "latest" + agency_id = agency_id if agency_id else "all" - base_query = f"dataflow/{agency_id}/{resources}/{version}" + base_query = f"/structure/dataflow/{agency_id}/{resources}/{version}" params = "" if references: @@ -117,7 +118,8 @@ def get_data(self, dataflow_id, provider=None, version=None, first_n_observations=None, last_n_observations=None, dimension_at_observation=None, detail=None, include_history=None): - base_query = f"/data/dataflow/{provider}/{dataflow_id}/{version}" + base_query = f"/data/dataflow/{provider}/{dataflow_id}" + base_query += f"/{version}" if version else "" base_query += f"/{key}" if key else "" diff --git a/sdmxthon/webservices/webservices.py b/sdmxthon/webservices/webservices.py index 88e9e68..4e22b51 100644 --- a/sdmxthon/webservices/webservices.py +++ b/sdmxthon/webservices/webservices.py @@ -24,7 +24,7 @@ class SdmxWebServiceConnection(ABC): def get_all_dataflows(self): """Returns a list of all dataflows""" url = (f"{self.ENTRY_POINT}" - f"{self.WS_IMPLEMENTATION.get_data_flows(self.AGENCY_ID)}") + f"{self.WS_IMPLEMENTATION.get_data_flows()}") message = read_xml(url, validate=False) dataflows = message['Dataflows'].values() list_dataflows = [] @@ -183,6 +183,10 @@ class OecdWs2(SdmxWebServiceConnection): ENTRY_POINT = 'https://sdmx.oecd.org/public/rest/v2' WS_IMPLEMENTATION = query_builder.QueryBuilder(query_builder.SdmxWs2p0()) + def get_all_dataflows(self): + """Not supported by v2, goes to v1""" + return OecdWs().get_all_dataflows() + class UnicefWs(SdmxWebServiceConnection): """Implements the connection to the ILO SDMX web service""" diff --git a/testApi.py b/testApi.py index f532fde..49e63cb 100644 --- a/testApi.py +++ b/testApi.py @@ -36,7 +36,9 @@ def main(): dataflow_id = 'BRAZIL_CO' agency_id = 'BRAZIL_CO' - print(ws.get_data_url(dataflow_id, last_n_observations=1)) + print(ws.get_all_dataflows()) + + # print(ws.get_data_url(dataflow_id, last_n_observations=1)) # print(ws.get_data_flow(dataflow_id, agency_id=agency_id, references='descendants').content) # data = ws.get_data(dataflow_id, provider=agency_id, version=version, # last_n_observations=1)