npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fxdatapi-js-sdk

v1.0.9

Published

An SDK for interacting with the Currency API by Hori Systems Limited.

Downloads

10

Readme

Currency API SDK

Develop and deploy applications, mobile and web, with popular JavaScript Frameworks using Currency API SDK.

Install

yarn add fxdatapi-js-sdk
# or
npm i fxdatapi-js-sdk

Example of Usage

import {
  login,
  convertCurrency,
  convertAllCurrencies,
  getAllCurrencies,
  getCurrencyById,
  getAllHistoricalRates,
  getHistoricalRateById,
  getDailyAverage,
  getWeeklyAverage,
  getMonthlyAverage,
  getAllMarginsSpreads,
  getMarginsSpreadsById,
  getAllPerformances,
  getPerformancesById,
  getAllSignals,
  getSignalsById,
} from 'fxdatapi-js-sdk';

async function retrieveFxdatapi() {
    try {
      const credentials = {
        username: 'your_username',
        password: 'your_password',
      };
  
      const response = await login(credentials);
      console.log('Login successful:', response);
  
      // Test the convertCurrency function
      const conversionRequest = {
        username: credentials.username,
        date: '2023_04_02',
        base_currency: 'GBP',
        target_currency: 'CAD',
        amount: '500',
      };
  
      const conversionResponse = await convertCurrency(response.token, conversionRequest);
      console.log('Conversion successful:', conversionResponse);
  
      // Test the convertAllCurrencies function
      const convertAllRequest = {
        username: credentials.username,
        base_currency: 'GBP',
        amount: 120,
        date: '2023_04_02',
      };
  
      const convertAllResponse = await convertAllCurrencies(response.token, convertAllRequest);
      console.log('Convert all currencies successful:', convertAllResponse);
  
      // Test the getAllCurrencies function
      const getAllCurrenciesRequest = {
        username: credentials.username,
        day: 2,
        month: 4,
        year: 2023,
      };
  
      const getAllCurrenciesResponse = await getAllCurrencies(response.token, getAllCurrenciesRequest);
      console.log('Get all currencies successful:', getAllCurrenciesResponse);
  
      // Test the getCurrencyById function
      const uuid = 'some-uuid'; // Replace with a valid UUID for a currency
      const getCurrencyByIdRequest = {
        uuid,
        username: credentials.username,
        day: 2,
        month: 4,
        year: 2023,
      };
  
      const currencyByIdResponse = await getCurrencyById(response.token, getCurrencyByIdRequest);
      console.log('Get currency by ID successful:', currencyByIdResponse);

      // Test the getAllHistoricalRates function
      const getAllHistoricalRatesRequest = {
        username: credentials.username,
        date: '2023_04_02',
        day: 2,
        month: 4,
        year: 2023,
       };
    
      const getAllHistoricalRatesResponse = await getAllHistoricalRates(response.token, getAllHistoricalRatesRequest);
      console.log('Get all historical rates successful:', getAllHistoricalRatesResponse);
  
      // Test the getHistoricalRateById function
      const historicalUuid = 'some-uuid'; // Replace with a valid UUID for a historical rate
      const getHistoricalRateByIdRequest = {
        uuid: historicalUuid,
        username: credentials.username,
        day: 2,
        month: 4,
        year: 2023,
        date_string: '2023_04_02',
       };

       const historicalRateByIdResponse = await getHistoricalRateById(response.token, getHistoricalRateByIdRequest);
       console.log('Get historical rate by ID successful:', historicalRateByIdResponse);

      // Test the getDailyAverage function
      const dailyAverageRequest = {
        date: '2023_04_10',
      };

      const dailyAverageResponse = await getDailyAverage(dailyAverageRequest);
      console.log('Get daily average successful:', dailyAverageResponse);

      // Test the getWeeklyAverage function
      const weeklyAverageRequest = {
        from_date: '2023_04_03',
        to_date: '2023_04_07',
      };

      const weeklyAverageResponse = await getWeeklyAverage(weeklyAverageRequest);
      console.log('Get weekly average successful:', weeklyAverageResponse);

      // Test the getMonthlyAverage function
      const monthlyAverageRequest = {
        year: '2023',
        month: '04',
      };

      const monthlyAverageResponse = await getMonthlyAverage(monthlyAverageRequest);
      console.log('Get monthly average successful:', monthlyAverageResponse);

      // Test the getAllMarginsSpreads function
      const getAllMarginsSpreadsRequest = {
        username: credentials.username,
        day: 19,
        month: 4,
        year: 2023,
      };

      const getAllMarginsSpreadsResponse = await getAllMarginsSpreads(response.token, getAllMarginsSpreadsRequest);
      console.log('Get all margins spreads successful:', getAllMarginsSpreadsResponse);

      // Test the getMarginsSpreadsById function
      const marginsSpreadsUuid = 'margins_spreads_uuid'; // Replace with a valid UUID for a margins spread
      const getMarginsSpreadsByIdRequest = {
        username: credentials.username,
        day: 19,
        month: 4,
        year: 2023,
      };

      const marginsSpreadsByIdResponse = await getMarginsSpreadsById(response.token, marginsSpreadsUuid, getMarginsSpreadsByIdRequest);
      console.log('Get margins spreads by ID successful:', marginsSpreadsByIdResponse);

      // Test the getAllPerformances function
      const getAllPerformancesRequest = {
        username: credentials.username,
      };

      const getAllPerformancesResponse = await getAllPerformances(response.token, getAllPerformancesRequest);
      console.log('Get all performances successful:', getAllPerformancesResponse);

      // Test the getPerformancesById function
      const performancesUuid = 'performances_uuid'; // Replace with a valid UUID for a performance
      const getPerformancesByIdRequest = {
        username: credentials.username,
      };

      const performancesByIdResponse = await getPerformancesById(response.token, performancesUuid, getPerformancesByIdRequest);
      console.log('Get performances by ID successful:', performancesByIdResponse);

      // Test the getAllSignals function
      const getAllSignalsRequest = {
        username: credentials.username,
      };

      const getAllSignalsResponse = await getAllSignals(response.token, getAllSignalsRequest);
      console.log('Get all signals successful:', getAllSignalsResponse);

      // Test the getSignalsById function
      const signalsUuid = 'signals_uuid'; // Replace with a valid UUID for a signal
      const getSignalsByIdRequest = {
        username: credentials.username,
      };

      const signalsByIdResponse = await getSignalsById(response.token, signalsUuid, getSignalsByIdRequest);
      console.log('Get signals by ID successful:', signalsByIdResponse);
      } catch (error) {
        if (error instanceof Error) {
          console.error('Error:', error.message);
        } else {
          console.error('An unknown error occurred:', error);
        }
      }
  }
  retrieveFxdatapi();

The Currency API documentation is available here. If you need further assistance, don't hesitate to contact us.

License

This project is licensed under the BSD 3-Clause License.

Copyright

(c) 2023 Hori Systems Limited.