Quickstart
Magsimula sa anumang wika
Ang FXMacroData API ay isang standard JSON REST API. Anumang wika na may HTTP support ay gagana. Ang mga freemium time-series endpoint ay available para sa pinakabagong 90 araw nang walang key. Magdagdag ng Individual API key upang i-unlock ang buong history at mga paid endpoint family.
Basehan URL
https://api.fxmacrodata.com
Authentication
X-API-Key: YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
Format ng response
JSON (Content-Type: application/json)
openapi-generator-cli upang auto-generate ng mga client sa mga wikang 40+.
Accept-Encoding: gzip sa bawat request (8–12× mas maliliit na payload), gamitin muli ang ETag response header sa If-None-Match sa mga repeat poll (nagbabalik 304 Not Modified na walang body), at ipasa ?limit=50 sa mga single-indicator endpoint tulad ng /v1/announcements/usd/inflation o /v1/predictions/usd/inflation kapag kailangan mo lamang ng mga kamakailang row. Tingnan ang buong reference →
core_pce umiiral para sa USD ngunit hindi para sa bawat currency. Ilista ang bawat slug na suportado ng isang currency gamit ang GET /v1/data_catalogue/{currency}, halimbawa /v1/data_catalogue/usd. Isang 404 na may error_code: NO_DATA_IN_REQUESTED_WINDOW nangangahulugang ang slug ay valid at ang hinihiling na date window lamang ang walang laman — palawakin start_date/end_date sa halip na baguhin ang URL.
data_quality object. Para sa mga backtest at institutional reporting, suriin point_in_time_safe, has_announcement_datetime, source_type, at is_stale.
Unang API call
Mabilis na Request
Magsimula sa isang live announcement endpoint. Ang authentication ay mananatili sa api_key query parameter para sa direktang browser at script testing.
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Mga request sa Python
Mga copyable na Python API requests
Gamitin ang mga direktang REST halimbawang ito kapag gusto mo ang raw API request sa halip na isang SDK wrapper. Palitan ang YOUR_API_KEY sa mga protected route lamang.
USD consensus ng merkado sa implasyon
Consensus, survey, central-bank, IMF, at mga forecast ng FXMacroData na pinagsama sa mga realized announcement.
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 inflation na may known-at timestamps
Public USD inflation records para sa mga point-in-time backtest.
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))
spot history ng EUR/USD FX
Araw-araw na kasaysayan ng presyo ng FX para sa mga pair chart, modelo, at release overlay.
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))
kasaysayan ng AUD policy-rate
Kasaysayan ng desisyon ng central-bank na may release timing para sa no-lookahead research.
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))
darating na iskedyul ng release ng JPY
Mga darating na macro event na may UTC, market-local, at requested-timezone fields para sa pagpaplano ng mga alert, model refresh, at trading review.
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))
Presyo ng gold commodity
Opisyal na time series ng mga precious-metals na may mga araw-araw na halaga at change fields.
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
I-install ang opisyal na fxmacrodata package mula sa PyPI. Sync at async clients, pandas-ready output.
Gamit ang 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")
Gamit ang REST API nang direkta
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 na kliyente
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())
Mga Prediksyon & Mga Forecast
Ang /v1/predictions/{currency}/{indicator} ang endpoint ay nagpapakita ng forecast data mula sa mga market consensus survey, projection ng central-bank, IMF World Economic Outlook, at mga survey ng professional-forecaster. Ang mga prediction ay hinihiling para sa isang partikular na currency at indicator, tulad ng https://api.fxmacrodata.com/v1/predictions/usd/inflation; ang mga currency-only prediction request ay hindi suportado. Ang bawat prediksyon ay nakaugnay sa anunsyo nito sa pamamagitan ng announcement_id, kaya maaari mong pagsamahin ang mga forecast sa mga realized observation.
prediction_type="fxmacrodata" ay isang estimate na ginawa ng FXMacroData; ang isang tunay na compiled consensus ay may label na market_consensus. Ang availability ng forecast ay nag-iiba depende sa release — suriin ang matrix ng saklaw. Para sa look-ahead-free research, sundin ang gabay sa point-in-time backtesting.
Python — kumuha ng mga prediction at pagsamahin sa mga actual
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 — kumuha ng mga prediction ayon sa uri
# 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"
Sanggunian ng mga uri ng prediction
| prediction_type | Paglalarawan |
|---|---|
| market_consensus | Pinagsama-samang consensus ng market o ng ekonomista, kung mayroon |
| market_prediction | Point prediction ng propesyonal na forecaster |
| model_nowcast | Central-bank o reserve-bank model nowcast |
| survey | Central-bank survey ng mga propesyonal na forecaster (hal. ECB SPF) |
| central_bank_forecast | Opisyal na projection ng central-bank (hal. RBNZ MPS, BoC MPR) |
| central_bank_projection | Opisyal na projection ng central-bank |
| imf_weo | IMF proyeksyon ng World Economic Outlook |
| fxmacrodata | Prediction na ginawa ng FXMacroData na pinagsasama ang guidance ng central-bank, mga survey, at historical trends |
cURL
Hindi kailangan ng install. Gumagana mula sa anumang terminal.
# 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
Gumagana sa Node.js (18+), Deno, Bun, at mga modernong browser gamit ang Fetch API.
Opisyal na 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);
Gamit ang Fetch nang direkta
// 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());
Punta
Walang kailangang external package — ang standard library na ang humahawak ng lahat.
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
Nangangailangan ng httr at 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
Mga Gamit java.net.http (Java 11+). Walang kailangang external libraries.
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
Mga Gamit 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
Gumagamit ng built-in 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);
Bumuo ng isang typed client para sa anumang wika
Ang FXMacroData API ay naglalathala ng isang kumpletong OpenAPI 3.1 espesipikasyon. Gamitin ito kasama ang openapi-generator upang makabuo ng fully typed clients para sa Kotlin, Swift, Rust, Dart, Ruby, PHP, at 40+ iba pang mga wika.
# 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
Handa nang bumuo?
Ang mga endpoint ng USD ay sumusuporta sa no-key evaluation hanggang 100 request/araw. Mag-subscribe para sa mas mataas na limitasyon at multi-currency access.