Ìbẹ̀rẹ̀ Kíákíá
Bẹ̀rẹ̀ ní èdè kọ̀ọ̀kan
FXMacroData API jẹ́ JSON REST API ìṣe. Gbogbo èdè tí ó ní ìtìlẹ́yìn HTTP ṣiṣẹ́. Freemium time-series endpoints wà fún àwọn ọjọ́ 90 tó ṣẹ̀ṣẹ̀ kọjá láìní kii. Fi Individual API kii sí i láti ṣí ìtàn kíkún ati àwọn ẹgbẹ́ endpoint tí wọ́n ń sanwó fún.
Ìpìlẹ̀ URL
https://api.fxmacrodata.com
Ìfọwọ́sí (Authentication)
X-API-Key: YOUR_API_KEY
Ìṣẹ́funni (Authorization): Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
Ọ̀nà ìdáhùn
JSON (Content-Type: application/json)
openapi-generator-cli láti ṣẹ̀dá àwọn oníbàárà ní 40+ èdè.
Accept-Encoding: gzip lórí gbogbo ìbéèrè (8–12× payloadi tí ó kéré koko), lo ETag response header nínú If-None-Match lórí ìbéèrè tó tẹ̀lé ara wọn (ó ń mú 304 Not Modified láìní body), kí o sì fi ?limit=50 lórí àwọn endpoint apáka kan ṣoṣo bíi /v1/announcements/usd/inflation tàbí /v1/predictions/usd/inflation nígbà tí o bá nílò àwọn rọ́ọ̀ (rows) tó ṣẹ̀ṣẹ̀ wá nìkan. Wo ìtọ́ka kíkún →
core_pce ó wà fún USD ṣùgbọ́n kò wà fún gbogbo owó (currency). Dárúkọ gbogbo slug tí owó kan ṣe ṣeé lò pẹ̀lú GET /v1/data_catalogue/{currency}, fún àpẹẹrẹ /v1/data_catalogue/usd. 404 kan pẹ̀lú error_code: NO_DATA_IN_REQUESTED_WINDOW túmọ̀ sí pé slug náà tọ́, àti pé àkókò tí a béèrè nìkan ni kò ní nǹkan — fẹ̀ sí i start_date/end_date dípò kí o yí URL padà.
data_quality object. Fún backtests àti ìròyìn ilé-iṣẹ́, ṣàyẹ̀wò point_in_time_safe, has_announcement_datetime, source_type, àti is_stale.
Ìpè API àkọ́kọ́
Ìbéèrè Kíákíá
Bẹ̀rẹ̀ pẹ̀lú endpoint ìkéde tó ń ṣiṣẹ́ lọ́wọ́lọ́wọ́. Authentication wà nínú api_key query parameter fún ìdánwò browser àti script ní tààrà.
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Python ìbéèrè
Python API requests tí a lè dípò
Lo àwọn àpẹẹrẹ REST wọ̀nyí nígbà tí o bá fẹ́ raw API request dípò SDK wrapper. Yí YOUR_API_KEY padà níbi àwọn route tí a ṣọ́ nìkan.
ìnáwó USD consensus ọjà
Ìfọwọ́sowọ́pọ̀, ìbéèrè, central-bank, IMF, àti ìsọtẹ́lẹ̀ FXMacroData tí a so pọ̀ mọ́ àwọn ìkéde tí ó ti ṣẹlẹ̀.
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))
inflation USD pẹ̀lú àkókò tí a mọ̀
Àwọn ìṣirò inflation USD tó ṣe gbangba fún àwọn backtest ní àkókò kan pàtó.
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 ìtàn spot
Ìtàn owó FX ojoojúmọ́ fún àwọn chart ìpàdé, àwọn model, àti àwọn ìfipamọ́ ìdánilẹ̀.
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))
ìtàn policy-rate AUD
Ìtàn ìpinnu banki àpapọ̀ pẹ̀lú àkókò ìdirimọ̀ fún ìwádìí láìsí 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))
ètò ìpapọ̀ ìròyìn JPY tó ń bọ̀
Àwọn ìṣẹ̀lẹ̀ macro tó ń bọ̀ pẹ̀lú UTC, ọjà-lọ́ọ́, àti àwọn ìbéèrè timezone fún ètò ìkìlọ̀, ìfọújú rere àwọn model, àti ìyẹ̀wò ìṣòwò.
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))
Iye commodity wúrà
Ìsọfúnni ohun-ìṣẹ́-ọ̀nà precious-metals ti ìjọba pẹ̀lú iye ojoojúmọ́ àti ìyàtọ̀ ìyípadà.
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
Gbé e ìṣẹ́ ìpolongo fxmacrodata àpakò láti PyPI. Àwọn client sync ati async, àbájáde tó ṣe tán fún pandas.
Lílo 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")
Lílo REST API tààrà
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])
Alákòóso async
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())
Àwòrán ìròyìn & Ìsọtẹ́lẹ̀
Ní /v1/predictions/{currency}/{indicator} endpoint ń fún ìsọfúnni ìṣẹ̀lẹ̀ láti inú àwọn ìbéèrè ìfọwọ́sọ́sọ̀pọ̀ ọjà, ìsọfúnni banki àárín, IMF World Economic Outlook, àti àwọn ìbéèrè afọwọ́kọ́. Wọ́n ń béèrè ìsọfúnni fún owó ẹgbẹ́ àti ìṣọ́ kan pàtó, bíi https://api.fxmacrodata.com/v1/predictions/usd/inflation; àwọn ìbéèrè ìròyìn owó ìṣòwò nìkan kò wà ní ìtìlẹ́yìn. Ìròyìn kọ̀ọ̀kan ni a so mọ́ ìpolongo rẹ̀ nípasẹ̀ announcement_id, kí o lè so àwọn ìròyìn forecast pọ̀ mọ́ àwọn àwòṣe tó ṣẹlẹ̀.
prediction_type="fxmacrodata" jẹ́ ìṣírò tí FXMacroData ṣe; ìfọwọ́sí gbogbo (true compiled consensus) ni a ń pè ní market_consensus. Ìṣẹ́ ìgbésẹ̀ ìsọtẹ́lẹ̀ yàtọ̀ sí ìròyìn — ṣàyẹ̀ wò ìwé ìṣọ́ matrix. Fún ìwádìí láìsí look-ahead, tẹ̀lé Ìtọ́ni backtesting ní àkókò pàtó.
Python — gba àwọn ìsọtẹ́lẹ̀ kí o sì so pọ̀ mọ́ àwọn tó ṣẹlẹ̀ gidi
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 — gba àwọn ìròjìnlẹ̀ nípa irúfẹ́ rẹ̀
# 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"
Ìtọ́ka sí irú Prediction
| prediction_type | Àpèjúwe |
|---|---|
| market_consensus | Ìfọwọ́sowọ́pọ̀ ìṣẹ̀lẹ̀ ọjà tàbí ọ̀gbọ́n-oníṣẹ́, níbi tí ó bá wà |
| market_prediction | Ìsọfúnni point prediction láti ọwọ́ afọwọ́yẹ̀ professional |
| model_nowcast | Nowcast central-bank tàbí reserve-bank model |
| ìwádìí (survey) | Ìwádìí ṣàkóso-báǹkì nípa àwọn akọ́ṣẹ́mọṣẹ́ tí ó mọ iṣẹ́ (bí àpẹẹrẹ ECB SPF) |
| central_bank_forecast | Ìsọfúnni gbàgbà láti banki àárín (bí àpẹẹrẹ RBNZ MPS, BoC MPR) |
| central_bank_projection | Ìròyìn projection gbogboogbòò ti central-bank |
| imf_weo | Ìsọfúnni IMF World Economic Outlook |
| fxmacrodata | Ìsọfúnni tí FXMacroData ṣe tí ó so ìtọ́sọ́nà banki àárín, ìbéèrè, àti àwọn ìṣẹ̀lẹ̀ ìtàn pọ̀ |
cURL
Kò nílò ìgbéga. Ó ń ṣiṣẹ́ láti inú terminal èyíkéyìí.
# 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
Ó ń ṣiṣẹ́ nínú Node.js (18+), Deno, Bun, àti àwọn browser òde òní pẹ̀lú Fetch API.
npm client gbàgbà
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);
Nípa lílo Fetch tààrà
// 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());
Lọ
Kò nílò àwọn package tó wà níta — ìpamọ́ (standard library) náà ń ṣe gbogbo rẹ̀.
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
Ó nílò httr àti 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
Àwọn lílo java.net.http (Java 11+). Kò nílò àwọn ìbitìlẹ̀ (libraries) òde òkun.
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
Àwọn lílo 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
Ó ń lo èyí tí ó wà nínú webread iṣẹ́.
% 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);
Dá client tí a kọ sí èdè kọ̀ọ̀kan
FXMacroData API ń polongo ___ Ìsọfúnni OpenAPI 3.1. Lo ó pẹ̀lú openapi-generator láti ṣẹ̀dá àwọn oníbàárà tí a ti ṣe kedere fún Kotlin, Swift, Rust, Dart, Ruby, PHP, ati 40+ àwọn èdè mìíràn.
# 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
Ṣetán láti kọ́?
Àwọn endpoint USD ṣe àyè fún ìdánwò láìsí kọ́ọ̀kì títí di 100 iṣẹ́/ọjọ́. Forúkọsílẹ̀ fún àwọn àyè tí ó ga jùlọ àti àyè fún owó ọ̀tọ̀ọ̀tọ̀.