תחילת עבודה מהירה
התחל בכל שפה
ה-API של FXMacroData הוא JSON REST API סטנדרטי. כל שפה עם תמיכה ב-HTTP עובדת. נקודות קצה של סדרות זמן בחינם זמינות עבור 90 הימים האחרונים ללא מפתח. הוסף מפתח API מסוג Individual כדי לפתוח היסטוריה מלאה ומשפחות נקודות קצה בתשלום.
בסיס URL
https://api.fxmacrodata.com
אימות (Authentication)
X-API-Key: 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 ללא גוף), והעבר ?limit=50 בנקודות קצה של אינדיקטור בודד כגון /v1/announcements/usd/inflation או /v1/predictions/usd/inflation כאשר אתה זקוק רק לשורות אחרונות. ראה את הייחוס המלא →
core_pce קיים עבור USD אך לא עבור כל מטבע. רשום כל slug שמטבע תומך בו עם GET /v1/data_catalogue/{currency}, לדוגמה /v1/data_catalogue/usd. 404 עם error_code: NO_DATA_IN_REQUESTED_WINDOW פירושו שה-slug תקין ורק חלון התאריכים המבוקש ריק — להרחיב 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 להעתקה
השתמש בדוגמאות REST ישירות אלו כאשר ברצונך בבקשת API גולמית במקום מעטפת SDK. החלף את 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
היסטוריית החלטות של בנקים מרכזיים עם תזמון פרסום למחקר ללא מבט קדימה (no-lookahead).
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])
לקוח אסינכרוני (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())
תחזיות & תחזיות
ה- /v1/predictions/{currency}/{indicator} נקודת קצה מציגה נתוני תחזית מסקרי קונסנזוס שוק, תחזיות בנק מרכזי, IMF World Economic Outlook וסקרי חזאים מקצועיים. תחזיות מבוקשות עבור מטבע ואינדיקטור ספציפיים, כגון https://api.fxmacrodata.com/v1/predictions/usd/inflation; בקשות תחזית למטבע בלבד אינן נתמכות. כל תחזית מקושרת להכרזה שלה באמצעות announcement_id, כך שתוכל לחבר תחזיות עם תצפיות שהתממשו.
prediction_type="fxmacrodata" היא הערכה שנוצרה על ידי FXMacroData; קונסנזוס מהודר אמיתי מסומן כ- market_consensus. זמינות התחזיות משתנה לפי פרסום — בדוק את ה- מטריצת כיסוי. למחקר ללא מבט קדימה (look-ahead-free), עקוב אחר ה- מדריך backtesting של נקודת זמן.
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 | תחזית מיידית (nowcast) של מודל בנק מרכזי או בנק רזרבה |
| סקר | סקר בנק מרכזי של חזאים מקצועיים (למשל ECB SPF) |
| central_bank_forecast | תחזית רשמית של הבנק המרכזי (למשל RBNZ MPS, BoC MPR) |
| central_bank_projection | תחזית רשמית של בנק מרכזי |
| imf_weo | תחזית IMF World Economic Outlook |
| 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
משתמש ב-built-in webread פונקציה.
% 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);
צור לקוח מוקלד לכל שפה
ה-API של FXMacroData מפרסם מפרט 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 תומכות בהערכה ללא מפתח עד 100 בקשות ליום. הירשמו למגבלות גבוהות יותר וגישה למספר מטבעות.