frankfurter/README.md

82 lines
1.9 KiB
Markdown
Raw Normal View History

# Fixer.io
2015-07-28 17:30:57 +02:00
<img src="http://fixer.io/img/money.png" alt="fixer" width=180 align="middle">
2015-07-28 17:27:10 +02:00
2016-04-11 15:38:28 +02:00
[![Travis](https://travis-ci.org/hakanensari/fixer-io.svg)](https://travis-ci.org/hakanensari/fixer-io)
2015-07-28 17:27:10 +02:00
Fixer.io is a free JSON API for current and historical foreign exchange rates published by the European Central Bank.
The rates are updated daily around 3PM CET.
2016-04-11 15:38:28 +02:00
## Usage
2016-04-11 15:38:28 +02:00
Get the latest foreign exchange reference rates in JSON format.
```http
GET /latest
Host: api.fixer.io
```
Get historical rates for any day since 1999.
```http
GET /2000-01-03
Host: api.fixer.io
```
Rates are quoted against the Euro by default. Quote against a different currency by setting the base parameter in your request.
```http
GET /latest?base=USD
Host: api.fixer.io
```
Request specific exchange rates by setting the symbols or currencies parameter.
2016-04-11 15:38:28 +02:00
```http
GET /latest?symbols=USD,GBP
Host: api.fixer.io
```
Make cross-domain JSONP requests.
```http
GET /latest?callback=?
Host: api.fixer.io
```
An HTTPS endpoint is also available at [https://api.fixer.io](https://api.fixer.io).
Use [money.js](http://openexchangerates.github.io/money.js/) in the browser.
```js
var demo = function(data) {
fx.rates = data.rates
var rate = fx(1).from("GBP").to("USD")
alert("£1 = $" + rate.toFixed(4))
}
2016-04-11 15:38:28 +02:00
$.getJSON("http://api.fixer.io/latest", demo)
```
2016-04-11 15:38:28 +02:00
## Docker
2016-04-12 15:57:20 +02:00
You can run a local instance of the app using Docker.
2016-04-11 15:38:28 +02:00
Bring the stack up.
```bash
docker-compose up -d
2016-04-11 15:38:28 +02:00
```
Initialize the database and seed data.
```bash
docker-compose run web rake db:migrate rates:load
2016-04-12 15:57:20 +02:00
docker-compose restart web
```
## FAQ
### "The API returns data for a date other than the date I asked for!"
If the value of the `date`-property doesn't match the date you requested via query parameters that is due to the European Central Bank only publishing exchange rates **for working days**. In such cases, the exchange rates of the last working day are returned. [#47](https://github.com/hakanensari/fixer-io/issues/47)