lmikolajczak / goexrates

A foreign exchange rates and currency conversion API. Data from European Central Bank.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Go Report Card

💰 goexrates

A foreign exchange rates and currency conversion API that exposes data published by European Central Bank.

The rates are updated daily around 4PM CET.

Usage

Get the latest foreign exchange reference rates in JSON format.

GET /v1/latest
Host: localhost:3000

Get historical rates for any day since 1999-01-04.

GET /v1/historical/2008-03-18
Host: localhost:3000

Rates are quoted against the Euro by default. Quote against a different currency by setting the base parameter in your request.

GET /v1/latest?base=USD
Host: localhost:3000

Request specific exchange rates by setting the codes parameter.

GET /v1/latest?codes=USD,GBP
Host: localhost:3000

Response format.

{
    "base": "EUR",
    "date": "2021-05-05",
    "rates": {
        "AUD": 1.4832,
        "PLN": 4.2173,
        "MYR": 4.7543,
        "USD": 1.0961,
        [41 world currencies],
    }
}

Run

# Build and start containers:
docker compose up -d
# Enter api container:
docker exec -it api bash
# Apply database migrations:
make db/migrations/up
# Populate database with rates published by ECB (check goexrates-cli --help):
goexrates-cli load historical
# Run the API:
goexrates-api

API's endpoints can be accessed at localhost:3000. Both API (3000) and database (5432) ports are published and can be accessed via localhost:port.

Run make help to see all available commands and goexrates-cli --help to see more informations about additional CLI commands that help to manage common/recurring tasks.

About

A foreign exchange rates and currency conversion API. Data from European Central Bank.

License:MIT License


Languages

Language:Go 95.5%Language:Makefile 3.2%Language:Dockerfile 1.3%