Quickstart
Erste Schritte in jeder Sprache
Der FXMacroData API ist ein standardmäßiger JSON REST API für die serverseitige Nutzung. Jede Sprache mit HTTP-Unterstützung funktioniert. USD Ankündigungsdaten, der USD Veröffentlichungskalender und der Datenkatalog sind ohne Schlüssel kostenlos: die letzten 90 Tage, mit einer Veröffentlichungsverzögerung von 15 Minuten, bis zu 100 Anfragen pro Tag. Prognosewerte (USD inbegriffen), jede andere Währung, Echtzeit-Veröffentlichungen und die vollständige Historie erfordern einen API-Schlüssel, gesendet im X-API-Key header. Siehe, was kostenlos ist
Basis URL
https://api.fxmacrodata.com
Authentifizierung
X-API-Schlüssel: YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY
Das alte ?api_key= Abfrageparameter ist veraltet: Schlüssel in URLs landen in Protokollen.
Antwortformat
JSON (Content-Type: application/json)
openapi-generator-cli um Clients in 40+ Sprachen automatisch zu generieren.
Accept-Encoding: gzip bei jeder Anfrage (8–12× kleinere Payloads), verwenden Sie den ETag Response-Header in If-None-Match bei wiederholten Abfragen (gibt zurück 304 Not Modified ohne Body), und übergeben ?limit=50 auf Single-Indikator-Endpoints wie /v1/announcements/usd/inflation oder /v1/predictions/usd/inflation wenn Sie nur aktuelle Zeilen benötigen. Vollständige Referenz ansehen →
limit akzeptiert bis zu 100.. Um einen vollständigen Bereich zu erfassen, wiederholen Sie die Anfrage mit offset festgelegt auf pagination.next_offset until pagination.has_more is false. Siehe die Python-Schleife ↓
fetch() von einer Webseite wird vom Browser blockiert. Rufen Sie FXMacroData von Ihrem Backend aus auf und halten Sie den API-Schlüssel aus dem clientseitigen Code heraus.
core_pce existiert für USD, aber nicht für jede Währung. Listen Sie jeden Slug auf, den eine Währung unterstützt, mit GET /v1/data_catalogue/{currency}, zum Beispiel /v1/data_catalogue/usd. Ein 200, dessen data Array ist leer und welches trägt no_data.error_code: NO_DATA_IN_REQUESTED_WINDOW bedeutet, dass der Slug gültig ist und nur das angeforderte Zeitfenster leer ist — erweitern start_date/end_date anstatt den URL zu ändern oder es erneut zu versuchen. Ein 404 bedeutet, dass der Währungs- oder Indikator-Slug falsch ist.
data_quality Objekt. Für Backtests und institutionelles Reporting, untersuchen Sie point_in_time_safe, has_announcement_datetime, source_type, und is_stale. point_in_time_safe ist False, wann immer eine Zeile im Fenster eine Veröffentlichungszeit aufweist, die aus der gemessenen Veröffentlichungsverzögerung der Serie abgeleitet ist, also prüfen Sie assumed_release_time_count und der pro-Zeile release_time_assumed Kennzeichen, bevor ein False als unbrauchbar behandelt wird.
Marktplatz-Zugang
Nutzen Sie FXMacroData über RapidAPI
RapidAPI ist ein optionaler Marktplatz-Kanal für den FXMacroData REST API. FXMacroData liefert die Daten; RapidAPI verwaltet Ihr Marktplatz-Abonnement, den API Schlüssel, das Anfragekontingent und die Abrechnung. Kein separates FXMacroData Konto oder Schlüssel ist für Anfragen über diesen Kanal erforderlich.
- Öffnen Sie die offizielle FXMacroData Auflistung und wählen Sie einen Plan. Überprüfen Sie den Preis-Tab für die aktuelle Abdeckung, Kontingente und Ratenlimits.
- Kopieren Sie Ihren RapidAPI-Schlüssel aus dem Endpoint-Playground und speichern Sie ihn in Ihrer Serverumgebung als
RAPIDAPI_KEY. - Anfragen senden an
https://fxmacrodata1.p.rapidapi.commit beiden RapidAPI-Headern, wie unten gezeigt.
curl --request GET \ --url "https://fxmacrodata1.p.rapidapi.com/v1/announcements/usd/inflation?limit=3" \ --header "X-RapidAPI-Key: $RAPIDAPI_KEY" \ --header "X-RapidAPI-Host: fxmacrodata1.p.rapidapi.com"
Marketplace-Endpunkt-Abdeckung
Das Verzeichnis umfasst Ankündigungen, Veröffentlichungskalender, den Datenkatalog, tägliche FX Kurse, COT Positionierung, Zentralbank-Nachrichten, Marktsitzungen und einen Gesundheitscheck. Der Zugriff auf Währungen und Historie hängt von Ihrem RapidAPI-Plan ab. Nutzen Sie den Katalog, um unterstützte Indikator-Slugs zu finden.
Direkter FXMacroData-Zugriff
Die anderen Beispiele auf dieser Seite verwenden api.fxmacrodata.com und ein FXMacroData X-API-Key bei Bedarf. Schlüssel und Abonnements sind zwischen den Kanälen getrennt. Ein RapidAPI-Abonnement deckt die aufgeführten REST Endpunkte ab; Website-Abonnements, MCP, Prognosen, Streaming und Webhooks sind separate Angebote.
Halten Sie Ihren Schlüssel aus Browser-Code und öffentlichen Repositories fern. Für längere Ergebnismengen folgen Sie pagination.next_offset until pagination.has_more ist falsch. Senden Sie Ihren API Schlüssel niemals an den Support.
Erster API Call
Schnelle Anfrage
Das erste Snippet läuft so wie es ist: kein Schlüssel erforderlich für USD Daten, bereitgestellt 15 Minuten nach Veröffentlichung. Hinzufügen X-API-Key für alle 22 Währungen und Echtzeit-Bereitstellung, gesendet von einem Server, Skript oder Notebook.
# USD inflation, no key: 15-minute delay, most recent 90 days
curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation?limit=5"
# EUR inflation: add X-API-Key for all 22 currencies and real-time releases
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/announcements/eur/inflation"
Python Anfragen
Kopierbare Python API Anfragen
Verwenden Sie diese direkten REST Beispiele, wenn Sie die rohe API Anfrage anstelle eines SDK Wrappers wünschen. Ersetzen Sie YOUR_API_KEY nur auf geschützten Routen.
USD Inflations-Marktkonsens
Konsens-, Umfrage-, Zentralbank-, IMF- und FXMacroData-Prognosen, verknüpft mit realisierten Bekanntmachungen.
import requests
url = "https://api.fxmacrodata.com/v1/predictions/usd/inflation"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
USD Inflation mit 'known-at' Zeitstempeln
Öffentliche USD Inflationsdaten für Point-in-Time-Backtests.
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 Spot-Historie
Tägliche FX Preis-Historie für Paarkurven, Modelle und Veröffentlichungs-Overlays.
import requests
url = "https://api.fxmacrodata.com/v1/forex/eur/usd"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
AUD Leitzinserhistorie
Zentralbank-Entscheidungshistorie mit Veröffentlichungszeitpunkt für Forschung ohne Lookahead-Bias.
import requests
url = "https://api.fxmacrodata.com/v1/announcements/aud/policy_rate"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
JPY kommender Veröffentlichungsplan
Kommende Makro-Events mit UTC, markt-lokalen und angeforderten Zeitzonen-Feldern zur Planung von Alerts, Modell-Aktualisierungen und Trading-Reviews.
import requests
url = "https://api.fxmacrodata.com/v1/calendar/jpy"
params = {
"timezone": "Asia/Tokyo",
}
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
Goldrohstoffpreise
Offizielle Edelmetall-Zeitreihen mit täglichen Werten und Änderungsfeldern.
import requests
url = "https://api.fxmacrodata.com/v1/commodities/gold"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()
print(payload.get("data", payload))
Python
Installieren Sie das offizielle fxmacrodata Paket von PyPI (1.2.x). Synchronisierte und asynchrone Clients geben einfache JSON Wörterbücher zurück, die direkt in pandas geladen werden. Client() ohne Schlüssel liest die kostenlose USD Stufe; übergeben Sie api_key für jede andere Währung und Echtzeit-Bereitstellung.
Verwendung der SDK
from fxmacrodata import Client # USD inflation — no key needed: 15-minute delay, most recent 90 days data = Client().get_indicator("usd", "inflation") print(data["data"][0]) # Add X-API-Key for all 22 currencies and real-time releases client = Client(api_key="YOUR_API_KEY") # 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")
Direkte Verwendung des 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])
Blättern durch die vollständige Historie
import requests URL = "https://api.fxmacrodata.com/v1/announcements/eur/inflation" HEADERS = {"X-API-Key": "YOUR_API_KEY"} rows, offset = [], 0 while True: resp = requests.get( URL, params={"limit": 100, "offset": offset}, headers=HEADERS, timeout=30, ) resp.raise_for_status() page = resp.json() rows.extend(page["data"]) if not page["pagination"]["has_more"]: break offset = page["pagination"]["next_offset"] print(len(rows), "rows")
Async-Client
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())
Vorhersagen & Prognosen
Der /v1/predictions/{currency}/{indicator} der Endpoint liefert Prognosedaten aus Marktkonsens-Umfragen, Zentralbank-Prognosen, IMF World Economic Outlook und professionellen Analysten-Umfragen. Vorhersagen werden für eine bestimmte Währung und einen Indikator angefordert, wie z. B. https://api.fxmacrodata.com/v1/predictions/usd/inflation; Vorhersageanfragen nur für Währungen werden nicht unterstützt. Jede Vorhersage ist über ihre Ankündigung verknüpft via announcement_id, sodass Sie Prognosen mit realisierten Beobachtungen verknüpfen können.
prediction_type="fxmacrodata" ist eine von FXMacroData generierte Schätzung; ein echter zusammengestellter Konsens ist gekennzeichnet als market_consensus. Die Verfügbarkeit von Prognosen variiert je nach Release — prüfen Sie den Abdeckungsmatrix. Für eine Forschung ohne Look-ahead-Bias folgen Sie dem Point-in-Time Backtesting-Leitfaden.
/v1/predictions/coverage/{currency}. Ein Test- oder bezahlter Schlüssel gibt die Prognosewerte zurück.
Python — Vorhersagen abrufen und mit Ist-Werten zusammenführen
import requests HEADERS = {"X-API-Key": "YOUR_API_KEY"} # Predictions for USD inflation — requires API key preds = requests.get( "https://api.fxmacrodata.com/v1/predictions/usd/inflation", headers=HEADERS, 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"}, headers=HEADERS, timeout=30, ).json() # Join predictions with actuals using announcement_id actuals = requests.get( "https://api.fxmacrodata.com/v1/announcements/usd/inflation", headers=HEADERS, 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 — Vorhersagen nach Typ abrufen
# Which sources forecast USD indicators — free, no key curl "https://api.fxmacrodata.com/v1/predictions/coverage/usd" # All USD inflation predictions — requires API key curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/usd/inflation" # Filter by prediction type: market_consensus, imf_weo, central_bank_forecast, survey curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/usd/inflation?prediction_type=market_consensus" # EUR policy-rate predictions curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/eur/policy_rate"
Referenz der Prognosetypen
| prediction_type | Beschreibung |
|---|---|
| market_consensus | Zusammengefasster Konsens für Markt- oder Ökonomenereignisse, sofern verfügbar |
| market_prediction | Punktprognose eines professionellen Prognostikers |
| model_nowcast | Zentralbank- oder Reservebank-Modell Nowcast |
| Umfrage | Zentralbankumfrage unter professionellen Prognostikern (z. B. ECB SPF) |
| central_bank_forecast | Offizielle Zentralbank-Prognose (z. B. RBNZ MPS, BoC MPR) |
| central_bank_projection | Offizielle Zentralbankprognose |
| imf_weo | IMF World Economic Outlook Prognose |
| fxmacrodata | FXMacroData-generierte Vorhersage, die Zentralbank-Guidance, Umfragen und historische Trends kombiniert |
cURL
Keine Installation erforderlich. Funktioniert von jedem Terminal aus.
# USD inflation — no-key evaluation, up to 100 requests/day curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation" # EUR policy rate — send your API key in the X-API-Key header curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate" # Release calendar for Australia — requires API key curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/calendar/aud" # 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 -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/forex/usd/jpy" # Data catalogue (discover available indicators for USD) curl "https://api.fxmacrodata.com/v1/data_catalogue/usd"
JavaScript / TypeScript
Funktioniert serverseitig in Node.js (18+), Deno und Bun. Der API sendet keine CORS-Header, rufen Sie ihn daher von Ihrem Backend aus auf statt aus dem Browser-Code.
Offizieller npm-Client
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);
Direkte Verwendung von 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 = process.env.FXMD_API_KEY; const eur = await fetch( "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate", { headers: { "X-API-Key": API_KEY } } ); console.log(await eur.json());
Los geht's
Keine externen Pakete erforderlich — die Standardbibliothek erledigt alles.
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
Erfordert httr und 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", add_headers(`X-API-Key` = "YOUR_API_KEY") ) print(fromJSON(content(eur, "text")))
Java
Verwendungen java.net.http (Java 11+). Keine externen Bibliotheken erforderlich.
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
Verwendungen 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
Verwendet das integrierte webread funktion.
% 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, 'HeaderFields', {'X-API-Key', 'YOUR_API_KEY'}); url = 'https://api.fxmacrodata.com/v1/announcements/eur/policy_rate'; eur = webread(url, opts); disp(eur);
Generieren Sie einen typisierten Client für jede Sprache
Der FXMacroData API veröffentlicht ein vollständiges OpenAPI 3.1 Spezifikation. Verwenden Sie es mit openapi-generator um vollständig typisierte Clients für Kotlin, Swift, Rust, Dart, Ruby, PHP und 40 + andere Sprachen zu erstellen.
# 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
Bereit zum Bauen?
USD Veröffentlichungsdaten funktionieren ohne Schlüssel, bis zu 100 Anfragen/Tag und 15 Minuten nach der Veröffentlichung. Abonnieren Sie für Echtzeit-Veröffentlichungen, Prognosewerte, vollständige Historie, höhere Limits und jede Währung.