Tús Go Sasta
Tosaigh in aon teanga
Is JSON REST API rialta API FXMacroData é. Oibríonn aon teanga le tacar HTTP. Tá endpointí freemium time-series ar fáil do na 90 laethraí is déanaí gan eochair. Cuir eochair API Indibiduáltach leis chun an stair iomlán agus teaglaigh endpointí tíortha a dh unlocking.
Bunús URL
https://api.fxmacrodata.com
Cruthú
X-API-Eochair: YOUR_API_KEY
Ceadú: Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
Formáit fhreagairte
JSON (Content-Type: application/json)
openapi-generator-cli chun cliantas a ghiniú go huathoibríoch i dteangacha 40+.
Accept-Encoding: gzip ar gach iarratas (8–12× payloads níoslyú ETag ceannaire freagra i If-None-Match ar pollanna athchúrsaithe (torthaí 304 Not Modified gan corp), agus pasáil ?limit=50 ar deireadh-phointe amháin cosúil le /v1/announcements/usd/inflation nó /v1/predictions/usd/inflation nuair nachnraíonn tú ach sraithanna leiseanacha. Feic an tagairt iomlán →
core_pce tá sé ann do USD ach níl sé ann do gach airgeadas. Liostaigh gach slug a thacaíonn le hairgead le haghaidh GET /v1/data_catalogue/{currency}, mar shampla /v1/data_catalogue/usd. 404 le error_code: NO_DATA_IN_REQUESTED_WINDOW ciallaíonn go bhfuil an slug bailí agus go bhfuil an fuinneog dáta iarrtha folumháin amháin — leathnaigh start_date/end_date seachas an URL a athrú.
data_quality aithirg. point_in_time_safe, has_announcement_datetime, source_type, agus is_stale.
Glaoch API chéadúla
Iarratas Gasta
Tosaigh le deireadh (endpoint) fógra beo. Fanann an t-úchtú sa api_key paraiméadar cuideachta le haghaidh testáil brabhraire agus scripte díreach.
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Python iarratas
Iarratais Python API is féidir leagadh
Úsáid na samplaí díreach REST seo nuair atá an iarratas API amhrach u Aghaidh ar SDK. Athraigh YOUR_API_KEY ar chóir ar threoracha cosanta amháin.
comhcheol margaidh inflation USD
Comhaontais, suirmhú, baincisiú, IMF, agus réamhaisnéisí FXMacroData nasctha le fógraí réalaise.
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 le timestamps known-at
Onóraí infláite USD phoiblí le haghaidh backtests ag amanna ar leith.
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))
stair spot EUR/USD FX
Stair praghas FX laethúil do chomharthaí páir, modailí, agus díreachadh scaoileadh.
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))
historia ráta beilidheachais AUD
Stair chinntheas baincéire lárna le timing scaoileadh le haghaidh taighde gan breathnú chun tosaigh.
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))
sceideal scaoileadh upcoming JPY
Imeachtaí macro atá le teacht le UTC, réimsí margaidh-rialacha, agus réimsí tíomnáire iarrata, le haghaidh pleanáil fógraí, athnuachan modail, agus athbhreithniú caidrimh.
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))
Praghsanna earraí óir
Sraith ama oifigiúil metiléis luachacha laethúla agus cúntais athraithe.
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
Suiteáil an oifigiúil fxmacrodata pacáid ó PyPI. Cliantanna comhtháilithe agus neamhtháilithe, toradh réidh le pandas.
Ag úsáid an 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")
Ag baint úsáide as an REST API go díreach
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])
Cliant asincrúnach
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())
Réamhaisnéisí & Réamhaisnéisí
An /v1/predictions/{currency}/{indicator} fochaillí tairsealaíonn sonraí réamhaispeis ó shuísí comhaontuithe margaidh, tograí bainc chentralacha, IMF World Economic Outlook, agus shuísí forasaithe gairmiúla. Déan iarratas ar réamhaispeisí do airgeadra agus tíomnáir ar leith, mar shampla https://api.fxmacrodata.com/v1/predictions/usd/inflation; ní thacaítear le hiarrataí réamhaisnéis curasaig amháin. Tá gach réamhaisnéis nasctha lena fógrainthe trí announcement_id, ionas gur féidir leat foraoisneacha a nascadh le observations réallaithe.
prediction_type="fxmacrodata" is meascán é a генеराíodh ag FXMacroData; tá tionglas cumhachtach fíor le marcáil market_consensus. Íongann an fheidhmíocht réamhaisnéis de réir sráithe — seiceáil an matrise clúdach. Le haghaidh taighde gan breathnú ar aghaidh, lean an treoir backtesting le pointe amhair.
Python — faigh réamhaisnéisí agus nasc le réalaiseacha
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 — féigh tormánacha de réir cineál
# 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"
Tagairt do chineálacha réamhaisnéise
| cineál_réamhaisnéise | Síosúlú |
|---|---|
| market_consensus | Comhdhéanú imeachtaí margaidh nó eaconomóra, nuair atá sé ar fáil |
| market_prediction | Point prediction foraoisneach gairmiúil |
| model_nowcast | Nowcast múnla baincisiú nó bainc tairiscint |
| suirmhán | Suiteach bainc an bhanc ceannais ar fógraíocht ghairmiúil (m.sh. ECB SPF) |
| central_bank_forecast | Tograil oifigiúla bainc chentralacha (m.sh. RBNZ MPS, BoC MPR) |
| central_bank_projection | Taismeach oifigiúil banca lárna |
| imf_weo | Tograil IMF World Economic Outlook |
| fxmacrodata | Réamhaispeis ghineadh le haghaidh FXMacroData a cheanglaíonn treoir bainc chentralacha, suís, agus tendendí stairiúla |
cURL
Ní gá suiteáil a dhéanamh. Oibríonn ó aon inchinn.
# 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
Oibríonn sé in Node.js (18+), Deno, Bun, agus brabhair nua-aimseartha leis an Fetch API.
Cliant npm oifigiúil
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);
Úsáid Fetch go díreach
// 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());
Imigh
Níl pacáistí externacha uait — láimhseálann an leabharlann std iomlán.
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
Tá gá le httr agus 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
Úsáideanna java.net.http (Java 11+). Ní gá leabhair eachtracha a úsáid.
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
Úsáideanna 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
Úsáideann sé an built-in webread feidhme.
% 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);
Giniúla cliant clóite do gach teanga
Cuireann API FXMacroData i leagan iomlán Sainmhíniú OpenAPI 3.1. Úsáid é le openapi-generator chun cliantas go hiomlán clóite a tháirgeadh do Kotlin, Swift, Rust, Dart, Ruby, PHP, agus 40+ teangacha eile.
# 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
Réidh le tógáil?
Tacaíonn deireadhacha USD le measúnú gan eochair go 100 iarratas/lá. Liostáil le haghaidh teorainneacha níos airde agus rochtain il-airgeadaí.