クイックスタート
あらゆる言語で始める
FXMacroData API は、標準的な JSON REST API です。HTTP をサポートするあらゆる言語で動作します。フリーミアム・タイムシリーズ・エンドポイントは、キーなしで直近 90 日間分が利用可能です。Individual API キーを追加して、完全な履歴と有料エンドポイントファミリーをアンロックしてください。
基本 URL
https://api.fxmacrodata.com
認証
X-API-キー: YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
レスポンス形式
JSON (Content-Type: application/json)
openapi-generator-cli により、40+ 言語でクライアントを自動生成します。
Accept-Encoding: gzip すべてのリクエストに対して (8–12× より小さなペイロード)、 ETag のレスポンスヘッダー内 If-None-Match 繰り返しのポーリングにおいて (戻り値 304 Not Modified bodyなしで)、および渡す ?limit=50 以下のような単一指標エンドポイントについて: /v1/announcements/usd/inflation または /v1/predictions/usd/inflation 直近の行のみが必要な場合。 完全なリファレンスを見る →
core_pce USD 用には存在しますが、すべての通貨に対して存在するわけではありません。通貨がサポートするすべてのスラッグを以下とともにリストします。 GET /v1/data_catalogue/{currency}, 例えば /v1/data_catalogue/usd. 404(以下) error_code: NO_DATA_IN_REQUESTED_WINDOW は、スラッグが有効であり、要求された日付ウィンドウのみが空であることを意味します — 拡大 start_date/end_date ではなく、URL を変更すること。
data_quality オブジェクト。バックテストおよび機関投資家向けレポートには、以下を検査してください point_in_time_safe, has_announcement_datetime, source_type, および is_stale.
最初の API コール
クイックリクエスト
ライブアナウンスメントエンドポイントから開始してください。認証は api_key ブラウザおよびスクリプトでの直接テスト用のクエリパラメータ。
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Python リクエスト
コピー可能な Python API リクエスト
SDK ラッパーの代わりに生の API リクエストが必要な場合は、これらの直接的な REST 例を使用してください。YOUR_API_KEY は保護されたルートでのみ置き換えてください。
USD インフレ市場コンセンサス
コンセンサス、調査、中央銀行、IMF、およびFXMacroDataの予測を、実現された発表に結合。
import requests
url = "https://api.fxmacrodata.com/v1/predictions/usd/inflation"
response = requests.get(url, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
既知のタイムスタンプによる USD インフレ
ポイントインタイムのバックテスト用の公開 USD インフレ記録。
import requests
url = "https://api.fxmacrodata.com/v1/announcements/usd/inflation"
response = requests.get(url, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
EUR/USD FX スポット履歴
ペアチャート、モデル、およびリリースオーバーレイのための、日次の FX 価格履歴。
import requests
url = "https://api.fxmacrodata.com/v1/forex/eur/usd"
params = {
"api_key": "YOUR_API_KEY",
}
response = requests.get(url, params=params, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
AUD 政策金利履歴
先読みなしのリサーチのための、リリース時期を含む中央銀行の決定履歴。
import requests
url = "https://api.fxmacrodata.com/v1/announcements/aud/policy_rate"
params = {
"api_key": "YOUR_API_KEY",
}
response = requests.get(url, params=params, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
JPY 今後のリリーススケジュール
アラートの計画、モデルの更新、およびトレーディングのレビューのために、UTC、市場ローカル、およびリクエストされたタイムゾーンのフィールドを備えた、今後のマクロイベント。
import requests
url = "https://api.fxmacrodata.com/v1/calendar/jpy"
params = {
"timezone": "Asia/Tokyo",
"api_key": "YOUR_API_KEY",
}
response = requests.get(url, params=params, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
金コモディティ価格
日次値と変化フィールドを備えた、公式の貴金属時系列データ。
import requests
url = "https://api.fxmacrodata.com/v1/commodities/gold"
params = {
"api_key": "YOUR_API_KEY",
}
response = requests.get(url, params=params, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
Python
公式をインストール fxmacrodata PyPI からのパッケージ。同期および非同期クライアント、pandas 対応の出力。
SDK の使用
from fxmacrodata import Client client = Client(api_key="YOUR_API_KEY") # USD inflation — no-key evaluation, up to 100 requests/day data = client.get_indicator("usd", "inflation") # EUR policy rate — requires API key rate = client.get_indicator("eur", "policy_rate") # Forex price data — requires API key fx = client.get_fx_price("usd", "jpy")
REST API を直接使用する
import requests resp = requests.get( "https://api.fxmacrodata.com/v1/announcements/usd/inflation", timeout=30, ) resp.raise_for_status() payload = resp.json() print(payload["data_quality"]["point_in_time_safe"], payload["data"][0])
非同期クライアント
import asyncio from fxmacrodata import AsyncClient async def main(): async with AsyncClient(api_key="YOUR_API_KEY") as client: data = await client.get_indicator("eur", "inflation") print(data) asyncio.run(main())
予測 & 予測
その /v1/predictions/{currency}/{indicator} endpoint は、市場コンセンサス調査、中央銀行の予測、IMF 世界経済見通し、およびプロのフォーキャスターによる調査から予測データを算出します。予測は、以下のような特定の通貨と指標に対してリクエストされます: https://api.fxmacrodata.com/v1/predictions/usd/inflation;通貨のみの予測リクエストはサポートされていません。各予測は、以下を介して発表にリンクされています。 announcement_id, なので、予測と実現された観測値を結合できます。
prediction_type="fxmacrodata" はFXMacroDataが生成した推定値です。真の集計コンセンサスには、以下のようにラベル付けされます: market_consensus. 予測の可用性はリリースによって異なります — 以下を確認してください: カバレッジマトリックス. 先読みのない(look-ahead-free)研究のために、以下に従ってください: ポイントインタイム・バックテストガイド.
Python — 予測を取得して実績値と結合する
import requests # Predictions for USD inflation — no-key evaluation, up to 100 requests/day preds = requests.get( "https://api.fxmacrodata.com/v1/predictions/usd/inflation", timeout=30, ).json() for group in preds["data"]: print(group["announcement_id"], group["date"]) for p in group["predictions"]: print(f" {p['prediction_source_label']}: {p['predicted_value']}") # Filter by prediction type market = requests.get( "https://api.fxmacrodata.com/v1/predictions/usd/inflation", params={"prediction_type": "market_consensus"}, timeout=30, ).json() # Join predictions with actuals using announcement_id actuals = requests.get( "https://api.fxmacrodata.com/v1/announcements/usd/inflation", timeout=30, ).json() actuals_by_id = {row["announcement_id"]: row for row in actuals["data"]} for group in preds["data"]: actual = actuals_by_id.get(group["announcement_id"]) if actual: print(f"{group['date']}: actual={actual['val']}, forecast={group['predictions'][0]['predicted_value']}")
cURL — タイプ別に予測を取得
# All USD inflation predictions — free curl "https://api.fxmacrodata.com/v1/predictions/usd/inflation" # Filter by prediction type: market_consensus, imf_weo, central_bank_forecast, survey curl "https://api.fxmacrodata.com/v1/predictions/usd/inflation?prediction_type=market_consensus" # EUR predictions — requires API key curl "https://api.fxmacrodata.com/v1/predictions/eur/inflation?api_key=YOUR_API_KEY" # USD policy-rate predictions curl "https://api.fxmacrodata.com/v1/predictions/usd/policy_rate"
予測タイプの参照
| prediction_type | 説明 |
|---|---|
| market_consensus | 利用可能な場合、集計された市場またはエコノミストのイベントコンセンサス |
| market_prediction | プロフェッショナル・フォーキャスターによる点予測 |
| model_nowcast | 中央銀行または準備銀行モデルによるナウキャスト |
| 調査 | 中央銀行による専門家予測調査 (例: ECB SPF) |
| central_bank_forecast | 公式の中央銀行予測 (例: RBNZ MPS, BoC MPR) |
| central_bank_projection | 公式の中央銀行予測 |
| imf_weo | IMF 世界経済見通し予測 |
| fxmacrodata | 中央銀行のガイダンス、調査、および歴史的トレンドを組み合わせた FXMacroData 生成の予測 |
cURL
インストール不要。あらゆるターミナルから動作します。
# USD inflation — no-key evaluation, up to 100 requests/day curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation" # EUR policy rate — pass your API key as a query parameter curl "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate?api_key=YOUR_API_KEY" # Release calendar for Australia curl "https://api.fxmacrodata.com/v1/calendar/aud?api_key=YOUR_API_KEY" # Release calendar converted to a requested IANA timezone curl "https://api.fxmacrodata.com/v1/calendar/usd?indicator=gdp&timezone=America/Sao_Paulo" # Forex price history — requires API key curl "https://api.fxmacrodata.com/v1/forex/usd/jpy?api_key=YOUR_API_KEY" # Data catalogue (discover available indicators for USD) curl "https://api.fxmacrodata.com/v1/data_catalogue/usd"
JavaScript / TypeScript
Node.js (18+)、Deno、Bun、および Fetch API を備えたモダンブラウザで動作します。
公式 npm クライアント
import { FXMacroDataClient } from "@fxmacrodata/client"; const client = new FXMacroDataClient({ apiKey: "YOUR_API_KEY", }); // Public endpoint example const usdInflation = await client.announcements("usd", "inflation"); // Non-USD endpoint example (requires paid key) const eurRate = await client.announcements("eur", "policy_rate"); console.log(usdInflation, eurRate);
Fetch を直接使用する
// USD inflation — no-key evaluation, up to 100 requests/day const res = await fetch( "https://api.fxmacrodata.com/v1/announcements/usd/inflation" ); const data = await res.json(); console.log(data); // With API key for non-USD const API_KEY = "YOUR_API_KEY"; const eur = await fetch( `https://api.fxmacrodata.com/v1/announcements/eur/policy_rate?api_key=${API_KEY}` ); console.log(await eur.json());
実行
外部パッケージは不要です — 標準ライブラリですべて処理されます。
package main import ( "encoding/json" "fmt" "net/http" "io" ) func main() { // USD inflation — no-key evaluation, up to 100 requests/day resp, err := http.Get("https://api.fxmacrodata.com/v1/announcements/usd/inflation") if err != nil { panic(err) } defer resp.Body.Close() body, _ := io.ReadAll(resp.Body) var result map[string]interface{} json.Unmarshal(body, &result;) fmt.Println(result) }
R
必要条件 httr および jsonlite.
library(httr) library(jsonlite) # USD inflation — no-key evaluation, up to 100 requests/day res <- GET("https://api.fxmacrodata.com/v1/announcements/usd/inflation") data <- fromJSON(content(res, "text", encoding = "UTF-8")) # Convert to data frame df <- as.data.frame(data$data) head(df) # With API key for non-USD eur <- GET( "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate", query = list(api_key = "YOUR_API_KEY") ) print(fromJSON(content(eur, "text")))
Java
用途 java.net.http (Java 11+)。外部ライブラリは不要です。
import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class FXMacroDataExample { public static void main(String[] args) throws Exception { var client = HttpClient.newHttpClient(); var request = HttpRequest.newBuilder() .uri(URI.create("https://api.fxmacrodata.com/v1/announcements/usd/inflation")) .build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); System.out.println(response.body()); } }
C# / .NET
用途 HttpClient (.NET 6+).
using System.Net.Http; using System.Text.Json; var client = new HttpClient(); // USD inflation — no-key evaluation, up to 100 requests/day var json = await client.GetStringAsync( "https://api.fxmacrodata.com/v1/announcements/usd/inflation" ); var doc = JsonDocument.Parse(json); Console.WriteLine(doc.RootElement);
MATLAB
組み込みのを使用 webread function.
% USD inflation — no-key evaluation, up to 100 requests/day data = webread('https://api.fxmacrodata.com/v1/announcements/usd/inflation'); disp(data); % With API key for non-USD opts = weboptions('Timeout', 30); url = 'https://api.fxmacrodata.com/v1/announcements/eur/policy_rate?api_key=YOUR_API_KEY'; eur = webread(url, opts); disp(eur);
任意の言語の型付きクライアントを生成
FXMacroData API は完全な OpenAPI 3.1 仕様. これを次と共に使用してください: openapi-generator Kotlin、Swift、Rust、Dart、Ruby、PHP、および 40+ のその他の言語向けに、完全に型付けされたクライアントを生成します。
# Install the openapi-generator CLI npm install @openapitools/openapi-generator-cli -g # Generate a Go client openapi-generator-cli generate \ -i https://api.fxmacrodata.com/openapi.json \ -g go \ -o ./fxmacrodata-go-client # Generate a Java client openapi-generator-cli generate \ -i https://api.fxmacrodata.com/openapi.json \ -g java \ -o ./fxmacrodata-java-client
構築の準備はできていますか?
USD エンドポイントは、1日あたり最大 100 リクエストまでのキーなし評価をサポートしています。より高い制限とマルチ通貨アクセスを利用するには、サブスクリプションに登録してください。