Integrate and Transform an API

How to integrate a currency rate API and make your own euro to dollar conversion endpoint.

Currency conversion is a problem many technology companies encounter. Local prices, costs and profit margins need to be calculated according to the current currency exchange rates. Stock exchanges trade currencies around the clock and the value of currency constantly changes. For simplicity, most businesses work with an hourly or daily rate provided by an institution, such as a national central bank.

To continuously and automatically update your company's currency exchange rate, use Xapix and a free service on the internet like exchangeratesapi.io to request the rates.

Steps
Steps
  1. Create or login to your Xapix account and import the Onboarding Exercises project template.

  2. On your onboarding exercise project’s home screen, click on the endpoint GET /to-usd/{price_eur} and Edit Pipeline to get to your currency converter pipeline dashboard.

  3. Add the "exchangeratesapi.io latest" Connector unit to the pipeline, by either selecting the Add your first unit dialogue or clicking on Add Unit on the upper left corner.

  4. Back on the pipeline dashboard, connect the Request and Endpoint units to the "exchangeratesapi.io latest" Connector unit using the pipeline drag and drop functionality.

  5. Click on the Endpoint unit and on the attribute "price_usd". Then click Set formula to open the formula editor. In the formula editor, take the "price_eur" request parameter value and multiply it with the USD rate from the "exchangeratesapi.io" Connector unit. When working in the editor either click on attributes or type out their path to use them in the formula.

  6. Next, use the Publish button to deploy your project.

  7. Finally, test whether the response matches your expectations by copying the cURL command in the bottom right corner into a new terminal window on your computer.