Skip to content

small app that allows a user to see a table of rates and create new ones by obtaining FX rates from an API.

License

Notifications You must be signed in to change notification settings

fmlenarduzzi/rates-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rates App

API provider for FX rates.

Small app that allows a user to see a table of rates and create new ones by obtaining FX rates from an API.

High Level Design

This app uses two MongoDB collections:

  • Rates: Stores currency pairs created by user.
  • Currency: Stores all available FX rates obtained from provided API. Currency base is EUR.

API Documentation

GET /prices

Description: Get all currency FX rates
Response [200 OK]:

    [{
        "_id": "604e8d2402833a16dff7f635",
        "name": "AED",
        "updatedAt": "2021-03-15T00:37:24.417Z",
        "price": 4.388777,
        "__v": 0,
        "createdAt": "2021-03-14T22:24:36.515Z"
      },
      {
        "_id": "604e8d2402833a16dff7f636",
        "name": "AFN",
        "updatedAt": "2021-03-15T00:37:24.417Z",
        "price": 93.276043,
        "__v": 0,
        "createdAt": "2021-03-14T22:24:36.516Z"
      },
      {
        "_id": "604e8d2402833a16dff7f637",
        "name": "ALL",
        "updatedAt": "2021-03-15T00:37:24.417Z",
        "price": 123.075194,
        "__v": 0,
        "createdAt": "2021-03-14T22:24:36.516Z"
      }]

POST /rates

Description: Creates new FX rate pair
Body:

  {
      "from": "EUR",
      "to" : "USD", 
      "feePercentage": 10 
  }

Response [200 OK]:

  {
      "_id": "604e916586047d1a54c88e1f",
      "from": "EUR",
      "to": "USD",
      "feePercentage": 10,
      "__v": 0
  }

Take into account feePercentage is an optional data. So, new pair could be created without specified fee. For example...

Body:

  {
      "from": "EUR",
      "to" : "BRL"
  }

Response [200 OK]:

{
    "_id": "604e918f86047d1a54c88e21",
    "from": "EUR",
    "to": "BRL",
    "__v": 0
}

Besides, from and to data should be currencies supported by API: https://fixer.io/
Please, let me share an example using not supported currencies...

Body:

  {
      "from": "AAA",
      "to" : "BRL"
  }

Response [500 Internal Server Error]

    "Invalid Data"

GET /rates

Description: Retrieves all created rates.
Response [200 OK]

[
  {
    "Pair": "EUR-USD",
    "Original Rate": 1.195043,
    "Fee %": 10,
    "Fee Amount": 0.11950430000000001,
    "Rate with fee applied": 1.3145473
  },
  {
    "Pair": "EUR-BRL",
    "Original Rate": 6.596003,
    "Fee %": 0,
    "Fee Amount": 0,
    "Rate with fee applied": 6.596003
  }
]

GET /rates/{from}/{to}

Description: Query for a specific FX rate.
Example: /rates/EUR/BRL
Response [200 OK]

{
    "Pair": "EUR-BRL",
    "Original Rate": 6.596003,
    "Fee %": 0,
    "Fee Amount": 0,
    "Rate with fee applied": 6.596003
}

About

small app that allows a user to see a table of rates and create new ones by obtaining FX rates from an API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published