frankfurter/README.md

87 lines
1.7 KiB
Markdown
Raw Normal View History

2017-11-04 18:59:51 +01:00
# Fixer
2017-11-04 18:59:51 +01:00
[![Travis](https://travis-ci.org/hakanensari/fixer.svg)](https://travis-ci.org/hakanensari/fixer)
2015-07-28 17:27:10 +02:00
2017-11-04 18:59:51 +01:00
Fixer is a free API for current and historical foreign exchange rates [published by the European Central Bank](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html).
2016-04-11 15:38:28 +02:00
2017-11-04 18:59:51 +01:00
Rates are updated around 4PM CET every working day.
2016-04-11 15:38:28 +02:00
## Usage
2017-11-04 18:59:51 +01:00
Get the latest foreign exchange rates.
2016-04-11 15:38:28 +02:00
```http
GET /latest
```
Get historical rates for any day since 1999.
```http
GET /2000-01-03
```
Rates quote against the Euro by default. Quote against a different currency.
```http
GET /latest?from=USD
```
Request specific exchange rates.
2016-04-11 15:38:28 +02:00
```http
GET /latest?to=GBP
2016-04-11 15:38:28 +02:00
```
Change the amount requested.
2016-04-11 15:38:28 +02:00
```http
GET /latest?amount=100
2016-04-11 15:38:28 +02:00
```
2017-11-10 10:43:26 +01:00
The primary use case is client side. For instance, with [money.js](https://openexchangerates.github.io/money.js/) in the browser
2016-04-11 15:38:28 +02:00
```js
2017-11-04 18:59:51 +01:00
let demo = () => {
let rate = fx(1).from("GBP").to("USD")
2016-04-11 15:38:28 +02:00
alert("£1 = $" + rate.toFixed(4))
}
2018-03-09 13:35:43 +01:00
fetch('https://yourdomain.com/latest')
2017-11-04 18:59:51 +01:00
.then((resp) => resp.json())
.then((data) => fx.rates = data.rates)
.then(demo)
```
2016-04-11 15:38:28 +02:00
2017-11-04 18:59:51 +01:00
## Installation
2016-04-12 15:57:20 +02:00
2018-01-08 13:34:02 +01:00
To build locally, type
2016-04-11 15:38:28 +02:00
```bash
docker-compose up -d
2016-04-11 15:38:28 +02:00
```
2017-11-10 10:43:26 +01:00
Now you can access the API at
2017-11-04 18:59:51 +01:00
```
http://localhost:8080
```
2018-03-09 13:35:43 +01:00
In production, first create a `.env` file based on [`.env.example`](.env.example). Then, run with
2017-11-04 18:59:51 +01:00
```bash
2017-11-13 00:17:18 +01:00
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
2017-11-04 18:59:51 +01:00
```
2018-03-09 13:35:43 +01:00
To update to a newer image
```bash
docker-compose -f docker-compose.yml -f docker-compose.prod.yml pull
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
```
Within a few minutes, you will be able to access the API at
```
https://yourdomain.com:8080
```