ເລີ່ມຕົ້ນແບບດ່ວນ
ເລີ່ມຕົ້ນໃນທຸກພາສາ
FXMacroData API ແມ່ນ JSON REST API ມາດຕະຖານ. ພາສາໃດກໍຕາມທີ່ມີການຮອງຮັບ HTTP ສາມາດໃຊ້ໄດ້. Endpoint ຊຸດຂໍ້ມູນ time-series ແບບ freemium ມີໃຫ້ສຳລັບ 90 ວັນຫຼ້າສຸດໂດຍບໍ່ຕ້ອງມີ key. ເພີ່ມ key API ແບບ Individual ເພື່ອປົດລັອກປະຫວັດທັງໝົດ ແລະ ໝວດ endpoint ທີ່ຕ້ອງຊຳລະເງິນ.
ພື້ນຖານ URL
https://api.fxmacrodata.com
ການຢືນຢັນຕົວຕົນ
X-API-Key: YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
ຮູບແບບການຕອບສະໜອງ
JSON (Content-Type: application/json)
openapi-generator-cli ເພື່ອສ້າງ clients ອັດຕະໂນມັດໃນພາສາ 40+.
Accept-Encoding: gzip ໃນທຸກໆການຮ້ອງຂໍ (8–12× payload ທີ່ນ້ອຍລົງ), ນຳໃຊ້ ETag header ຂອງການຕອບສະໜອງໃນ If-None-Match ໃນການສອບຖາມແບບຊ້ຳ (ສົ່ງຄືນ 304 Not Modified ໂດຍບໍ່ມີ body), ແລະ ສົ່ງ ?limit=50 ໃນ endpoint ຕົວຊີ້ວັດດຽວ ເຊັ່ນ /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 ວັດຖຸ. ສຳລັບการ backtest ແລະ ການລາຍງານຂອງສະຖາບັນ, ກວດສອບ point_in_time_safe, has_announcement_datetime, source_type, ແລະ is_stale.
ການເອີ້ນ API ຄັ້ງທຳອິດ
ຄຳຂໍດ່ວນ (Quick Request)
ເລີ່ມຕົ້ນດ້ວຍ endpoint ການປະກາດແບບສົດ. ການຢືນຢັນຕົວຕົນຈະຢູ່ໃນ api_key ພາລາມິເຕີການສອບຖາມສຳລັບການທົດສອບໂດຍກົງຜ່ານບຣາວເຊີ ແລະ ສະຄຣິບ.
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
ຄຳຂໍ Python
ຄຳຮ້ອງຂໍ Python API ທີ່ສາມາດຄັດລອກໄດ້
ໃຊ້ຕົວຢ່າງ REST ໂດຍກົງເຫຼົ່ານີ້ ເມື່ອທ່ານຕ້ອງການຄຳຂໍ API ດິບ ແທນທີ່ຈະເປັນ wrapper SDK. ປ່ຽນແທນ YOUR_API_KEY ສະເພາະໃນເສັ້ນທາງທີ່ໄດ້ຮັບການປົກປ້ອງເທົ່ານັ້ນ.
ຄວາມເຫັນພ້ອມກັນຂອງຕະຫຼາດເງິນເຟີ້ USD
Consensus, ການສຳຫຼວດ, ທະນາຄານກາງ, 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 ພ້ອມດ້ວຍ timestamp ທີ່ຮູ້ໃນເວລານັ້ນ
ບັນທຶກເງິນເຟີ້ USD ທີ່ເປັນສາທາລະນະ ສຳລັບການທົດສອບຍ້ອນຫຼັງແບບ point-in-time.
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 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
ປະຫວັດການຕັດສິນໃຈຂອງທະນາຄານກາງ ພ້ອມດ້ວຍເວລາການປ່ອຍຂໍ້ມູນ ສຳລັບການວິໄຈແບບບໍ່ເບິ່ງລ່ວງໜ້າ.
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
ເຫດການ macro ທີ່ກຳລັງຈະມາເຖິງ ພ້ອມດ້ວຍຟິວຂອງ 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. ໄຄລັ້ນແບບ Sync ແລະ async, ຜົນລັດທີ່ພ້ອມສຳລັບ 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
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())
ການຄາດການ & ການພະຍາກອນ
The /v1/predictions/{currency}/{indicator} endpoint ສະແດງຂໍ້ມູນພະຍາກອນຈາກການສຳຫຼວດຄວາມເຫັນພ້ອມກັນຂອງຕະຫຼາດ, ການຄາດການຂອງທະນາຄານກາງ, IMF World Economic Outlook, ແລະ ການສຳຫຼວດຜູ້ພະຍາກອນມືອາຊີບ. ການຄາດການຖືກຮ້ອງຂໍສຳລັບສະກຸນເງິນ ແລະ ຕົວຊີ້ວັດທີ່ສະເພາະເຈາະຈົງ, ເຊັ່ນ https://api.fxmacrodata.com/v1/predictions/usd/inflation; ບໍ່ຮອງຮັບການຮ້ອງຂໍການຄາດການສະເພາະສະກຸນເງິນ. ແຕ່ລະການຄາດການຈະຖືກເຊື່ອມໂຍງກັບການປະກາດຜ່ານ announcement_id, ເພື່ອໃຫ້ທ່ານສາມາດລວມການຄາດການເຂົ້າກັບການສັງເກດທີ່ເກີດຂຶ້ນຈິງ.
prediction_type="fxmacrodata" ແມ່ນການປະມານການທີ່ສ້າງໂດຍ FXMacroData; ຄວາມເຫັນພ້ອມກັນທີ່ຮວບຮວມແທ້ຈິງຈະຖືກຕິດປ້າຍວ່າ market_consensus. ຄວາມພ້ອມຂອງການພະຍາກອນຈະແຕກຕ່າງກັນໄປຕາມການປ່ອຍຂໍ້ມູນ — ກວດສອບທີ່ matrix ຂອງ coverage. ສຳລັບການວິໄຈທີ່ປາສະຈາກ look-ahead, ໃຫ້ປະຕິບັດຕາມ ຄູ່ມືການທົດສອບຍ້ອນຫຼັງແບບ point-in-time.
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
ບໍ່ຈຳເປັນຕ້ອງຕິດຕັ້ງ. ໃຊ້ງານໄດ້ຈາກ 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
ໃຊ້ງານໄດ້ໃນ Node.js (18+), Deno, Bun, ແລະ ບຣາວເຊີທັນສະໄໝ ດ້ວຍ Fetch API.
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);
ການໃຊ້ 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+). ບໍ່ຈຳເປັນຕ້ອງໃຊ້ library ພາຍນອກ.
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
ໃຊ້ສິ່ງທີ່ຕິດຕັ້ງມາໃນຕົວ 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);
ສ້າງ typed client ສຳລັບທຸກໆພາສາ
FXMacroData API ຕີພິມສິ່ງທີ່ສົມບູນ ຂໍ້ກຳນົດ OpenAPI 3.1. ໃຊ້ວ່າມັນກັບ openapi-generator ເພື່ອສ້າງ clients ທີ່ມີການກຳນົດປະເພດຢ່າງສົມບູນສຳລັບ 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
ພ້ອມທີ່ຈະສ້າງແລ້ວບໍ?
endpoints ຂອງ USD ຮອງຮັບການປະເມີນແບບບໍ່ໃຊ້ຄີສູງສຸດ 100 ຄຳຂໍ/ມື້. ສະໝັກສະມາຊິກເພື່ອຂີດຈຳກັດທີ່ສູງຂຶ້ນ ແລະ ການເຂົ້າເຖິງຫຼາຍສະກຸນເງິນ.