Code Monkey home page Code Monkey logo

exchange-rates's Introduction

icon exchange-rates

CircleCI

Querying a rate-limited foreign currency exchange API using Redis as a cache.

  • Number of Requests per Hour: 100 (See config file)

Http Endpoints

GET /v1/currencies

Returns a list of the available currencies. Eg:

["USD","EUR","GBP","AUD","CAD","PLN","ARS"]

GET /v1/rates?from=EUR&to=USD

Returns the current exchange rate, if available:

{"to":"USD","from":"EUR","rate":1.139556}

Run it locally

You'll need a Redis instance. The easiest way to get started is by using docker:

docker run -it --rm -p 6379:6379 redis:5.0.0

And then run the web server app using cabal new-run exchange-rates, or using Nix nix-shell --pure shell.nix and cabal new-run exchange-rates. You should see something like:

AppConfig {forex = ForexConfig {host = "https://free.currconv.com/api/v7", apiKey = [SECRET], keyExpiration = 1800}, redis = RedisConfig {redisHost = "127.0.0.1", redisPort = 6379}}
Started server on localhost:8080
Calling web service for: USD -> GBP
Calling web service for: USD -> EUR
Cache hit: USD -> GBP
Calling web service for: USD -> PLN
Cache hit: USD -> PLN

Exchange rates are cached to avoid hitting the (limited) external service many times.

Browse the documentation

The docs are generated at compile time from the API definition. The API serves a swagger.json response that you can visualize in the Swagger UI:

docker run -p 80:8080 swaggerapi/swagger-ui

Go to localhost and enter http://localhost:8080/swagger.json.

docs

exchange-rates's People

Contributors

gvolpe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.