LoginSignup
33
19

More than 3 years have passed since last update.

無料で使える為替取得APIメモ

Last updated at Posted at 2019-11-19

無料でCORS対応してるのが意外と無かったので色々試してみた。

❌OANDA

  • APIキー必要(デモ口座開設=無料)
  • Qiitaで為替APIで検索したらよく出てくるやつ
  • なんかcurl一発みたいなサンプルがググって10秒で出てこなくて面倒になってきてやめた

http://api.aoikujira.com/kawase/json/usd

  • 登録不要
  • CORS非対応

https://www.gaitameonline.com/rateaj/getrate

  • 登録不要
  • CORS非対応

http://data.fixer.io/api/latest?access_key=XXX&symbols=USD,JPY

  • APIキー必要(無料プランあり)
  • CORS対応OK
  • 無料プランだと https 非対応!

→❌https://api.exchangeratesapi.io/latest

  • 登録不要 →2020年08月時点では誰でも使えたが2021年4月現在ではいつの間にかAPIキーが必要
  • CORS対応OK
  • https対応OK → 無料プランでは https 利用不可
  • API提供元の組織は欧州中央銀行(ECB)。正確性/安定性/継続性など色んな意味で理想的。今後も安心して使えそう

こいつが欲しかった! → オワタ(ノД`)シクシク

await fetch("https://api.exchangeratesapi.io/latest", {mode:"cors"}).then(r=>r.json())

2021年4月現在は以下のレスポンスが返ってきており登録が必要な模様

{
  "success": false,
  "error": {
    "code": 101,
    "type": "missing_access_key",
    "info": "You have not supplied an API Access Key. [Required format: access_key=YOUR_ACCESS_KEY]"
  }
}

一応試しに登録してみたがFreeプランだと以下が返ってくる。駄目だコレ…。

{
  "error": {
    "code": "https_access_restricted",
    "message": "Access Restricted - Your current Subscription Plan does not support HTTPS Encryption."
  }
}
33
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
19