You can translate the question and the replies:

Obtaining Data from API

Hello. I would like to obtain data from this API: https://www.bankofcanada.ca/valet/ What type of data source do I need to create, please? Thank you.
user
19-01-2023 10:21:39 -0500
code

3 Answers

Hi, In order to obtain data from an API in a Virtual DataPort, you could make use of the **JSON** or a **XML** data source based on the format of your API. In order to achieve this, you could follow the below steps, * Navigate to the **File**> **New** > **Data Source** section of the Virtual DataPort Administration Tool and select the JSON/XML data source based on your API format. * Then, select the Data Route as [HTTP Client](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/creating_data_sources_and_base_views/path_types_in_virtual_dataport/http_path#http-path) and specify the base URL of your API in the GET HTTP method configuration. * Under the **Authentication** tab, you could choose the Authentication that is applicable for your API. * Do a Test Connection and then Save the data source. * Then create a base view to obtain the data. Further, you could configure **pagination** and **filters** to the API being used. You could refer to this [JSON Sources](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/creating_data_sources_and_base_views/json_sources/json_sources) and [XML Sources](https://community.denodo.com/docs/html/browse/8.0/en/vdp/administration/creating_data_sources_and_base_views/xml_sources/xml_sources) section of the Virtual DataPort Administration Guide for more information. Hope this helps!
Denodo Team
20-01-2023 10:00:41 -0500
code
Thank you very much. This information is very helpful. I followed the instructions. I created a json data source. I specified as base url the following: https://www.bankofcanada.ca/valet I then created a base view. As relative url I used the following: /observations/FXCADUSD/json I got the data in json format. The data contains 3 columns. The column ''observations'' containes contains the foreign exhange data in json format. My goal is to have a new view with 2 columns: ''Date'' and ''Exch_rate'' with values like these: Date Exch_rate 2023-01-01 1.30 2023-01-02 1.29 To obtain my goal I need to parse the json data. created a derived view based on the base view. And I kept only the ''observations'' column, which contains the foreign exchange data I am interested in. Then I created a flattened view based on the derived view. I selected the ''observations'' column as the column to be parsed. However, I noticed that the data gets only partially parsed. That is I get one column containing the dates and another column containing still a key-value pair, the value being the foreign exchange rate. I thus need to parse this newly created column (the one that still has a key-value) pair. I tried to create a new flattened view based on the original flattened view to see if I could parse the remaining column containing a key-value pair but the option to select this last column is not available. Any help would be appreciated. Thank you. Then I created a flattened view and chose the ''observations'' column as the column to be flattened. My goal is to h
user
20-01-2023 21:55:10 -0500
Hi, I followed the below steps and I was able to achieve the final results which contains a new view with only 2 columns namely date and exchange rate, * Created a base view with the relative URL accordingly. * Then, created a derived view with only the observations columns. * Next, created a flattened view over the derived view and selected the **observations** column to be flattened. After this, I have a column named **date** and another column with the [register](https://community.denodo.com/tutorials/browse/basics/3adv2flatten#:~:text=complex%20data%20types%3A-,Registers,-or%20Records%3A%20a) data type. * Followed by this, I created a **selection view** over the flattened view. Under the Output tab, right click on the exchange rate column(register data type) and then projected it to separate it as two columns. Refer to this [creating flatten views](https://community.denodo.com/docs/html/browse/latest/en/vdp/administration/creating_derived_views/creating_flatten_views/creating_flatten_views#:~:text=If%20you%20need%20to%20%E2%80%9Cflatten%E2%80%9D%20the%20fields%20of%20a%20register%20and%20not%20an%20array%2C%20do%20not%20create%20a%20Flatten%20view.%20Instead%2C%20create%20a%20Selection%20view%20and%20in%20the%20%E2%80%9COutput%E2%80%9D%20tab%20of%20the%20view%2C%20right%2Dclick%20on%20the%20register%20and%20click%20Project%20subfields%20of%E2%80%A6) section to know about how to project the registers. * Upon executing the final view, I was able to get the expected results. Hope this helps!
Denodo Team
23-01-2023 09:01:16 -0500
code
You must sign in to add an answer. If you do not have an account, you can register here