ការចាប់ផ្តើមរហ័ស

ចាប់ផ្តើមក្នុងភាសាណាមួយ

FXMacroData API គឺជា JSON ស្តង់ដារ REST API។ រាល់ភាសាដែលមានការគាំទ្រ HTTP គឺអាចប្រើបាន។ Freemium time-series endpoints មានសម្រាប់ 90 ថ្ងៃចុងក្រោយបំផុតដោយមិនចាំបាច់មាន key។ បន្ថែម key បុគ្គល API ដើម្បីដោះសោប្រវត្តិសាស្ត្រពេញលេញ និងគ្រួសារ endpoint បង់ប្រាក់។

មូលដ្ឋាន URL

https://api.fxmacrodata.com

ការផ្ទៀងផ្ទាត់ភាពត្រឹមត្រូវ (Authentication)

X-API-Key: YOUR_API_KEY

Authorization: Bearer YOUR_API_KEY

?api_key=YOUR_API_KEY

ទម្រង់នៃ Response

JSON (Content-Type: application/json)

បង្កើត client ដែលមានប្រភេទដោយស្វ័យប្រវត្តិ: ប្រើប្រាស់អ្វីដែលបានបោះពុម្ពផ្សាយ បទដ្ឋាន OpenAPI 3.1 ជាមួយ openapi-generator-cli ដើម្បីបង្កើត client ដោយស្វ័យប្រវត្តិក្នុង 40+ ភាសា។
អត្ថប្រយោជន៍នៃប្រសិទ្ធភាពឥតគិតថ្លៃ៖ ផ្ញើ Accept-Encoding: gzip លើរាល់ការស្នើសុំ (8–12× payload តូចជាងមុន), ប្រើឡើងវិញនូវ ETag response header ក្នុង If-None-Match លើការស្ទង់មតិដដែលៗ (ផ្តល់មកវិញ 304 Not Modified ដោយគ្មាន body), និងបញ្ជូន ?limit=50 លើ endpoints សូចនាករតែមួយ ដូចជា /v1/announcements/usd/inflation/v1/predictions/usd/inflation នៅពេលដែលអ្នកត្រូវការតែជួរទិន្នន័យថ្មីៗប៉ុណ្ណោះ។ មើលឯកសារយោងពេញលេញ →
ស្វែងរក indicator slugs មុនពេលកំណត់ path ក្នុងកូដ៖ slugs នៃសូចនាករប្រែប្រួលទៅតាមរូបិយប័ណ្ណ — 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.
ពិនិត្យគុណភាពនៃចម្លើយ៖ endpoints ដែលគាំទ្រដោយប្រភពនឹងផ្តល់ត្រឡប់មកវិញនូវកម្រិតកំពូល data_quality វត្ថុ។ សម្រាប់ការធ្វើតេស្តឡើងវិញ និងការរាយការណ៍ស្ថាប័ន សូមពិនិត្យ point_in_time_safe, has_announcement_datetime, source_type, និង is_stale.

ការហៅ API លើកដំបូង

សំណើរហ័ស (Quick Request)

ចាប់ផ្តើមជាមួយ live announcement endpoint។ ការផ្ទៀងផ្ទាត់អត្តសញ្ញាណស្ថិតនៅក្នុង api_key ប៉ារ៉ាម៉ែត្រសំណួរសម្រាប់ការធ្វើតេស្តតាមរយៈ browser និង script ដោយផ្ទាល់។

ឧទាហរណ៍អតិផរណា EUR GET /api/v1/announcements/eur/inflation
សំណើកូដ (Request snippet)
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"

Python ការស្នើសុំ

ការស្នើសុំ Python API ដែលអាចចម្លងបាន

ប្រើឧទាហរណ៍ REST ដោយផ្ទាល់ទាំងនេះ នៅពេលអ្នកចង់បានសំណើ API ដើម ជំនួសឱ្យ wrapper SDK។ ជំនួស YOUR_API_KEY តែនៅលើ route ដែលត្រូវបានការពារប៉ុណ្ណោះ។

ការយល់ស្របទីផ្សារអតិផរណា 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 អតិផរណាជាមួយនឹងត្រាពេលវេលាដែលបានដឹង

កំណត់ត្រាអតិផរណា USD សាធារណៈសម្រាប់ point-in-time backtests។

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

ព្រឹត្តិការណ៍ម៉ាក្រូដែលនឹងមកដល់ ជាមួយនឹងវាល 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))
ផ្លូវការ SDK

Python

ដំឡើងកម្មវិធីផ្លូវការ fxmacrodata កញ្ចប់ពី PyPI។ ក្លាយជា client แบบ sync និង async, លទ្ធផលដែលត្រៀមរួចសម្រាប់ pandas។

pip install fxmacrodata

ការប្រើប្រាស់ 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())
ថ្មី

ការទស្សន៍ទាយ & ការព្យាករណ៍

នោះ /v1/predictions/{currency}/{indicator} endpoint បង្ហាញទិន្នន័យព្យាករណ៍ពីការស្ទង់មតិឯកច្ឆន្ទនៃទីផ្សារ, ការព្យាករណ៍របស់ធនាគារកណ្តាល, IMF World Economic Outlook និងការស្ទង់មតិរបស់អ្នកព្យាករណ៍អាជីព។ ការទស្សន៍ទាយត្រូវបានស្នើសុំសម្រាប់រូបិយប័ណ្ណ និងសូចនាករជាក់លាក់ ដូចជា https://api.fxmacrodata.com/v1/predictions/usd/inflation; ការស្នើសុំការទស្សន៍ទាយសម្រាប់តែរូបិយប័ណ្ណគឺមិនត្រូវបានគាំទ្រទេ។ ការទស្សន៍ទាយនីមួយៗត្រូវបានភ្ជាប់ទៅនឹងការប្រកាសរបស់វាតាមរយៈ announcement_id, ដើម្បីអ្នកអាចភ្ជាប់ការព្យាករណ៍ជាមួយនឹងការសង្កេតដែលបានសម្រេច។

កុំចាត់ទុករាល់ការព្យាករណ៍ថាជាមតិឯកច្ឆន្ទ (consensus)។ prediction_type="fxmacrodata" គឺជាការប៉ាន់ស្មានដែលបង្កើតដោយ FXMacroData; មតិឯកច្ឆន្ទដែលបានចងក្រងពិតប្រាកដត្រូវបានដាក់ស្លាកថា market_consensus. ភាពអាចរកបាននៃការព្យាករណ៍ប្រែប្រួលតាមការចេញផ្សាយ — ពិនិត្យមើល ម៉ាទ្រីសគ្របដណ្តប់ (coverage matrix). សម្រាប់ការស្រាវជ្រាវដែលគ្មានការមើលទុកមុន សូមអនុវត្តតាម មគ្គុទ្ទេសក៍ backtesting แบบ point-in-time.
USD គឺឥតគិតថ្លៃសម្រាប់ 90 ថ្ងៃចុងក្រោយបំផុត — មិនត្រូវការកូនសោ API សម្រាប់ការទស្សន៍ទាយ USD នៅក្នុងបង្អួចនោះទេ។ ប្រវត្តិ USD ពេញលេញ និងរូបិយប័ណ្ណផ្សេងទៀតទាំងអស់តម្រូវឱ្យមានការសាកល្បងដែលមានសុពលភាព ឬកូនសោ API ដែលបានបង់ប្រាក់។

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, និង browser ទំនើបៗជាមួយនឹង Fetch API។

npm client ផ្លូវការ

npm install @fxmacrodata/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.

install.packages(c("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

ប្រើប្រាស់កម្មវិធីដែលមានស្រាប់ 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);

បង្កើត typed client សម្រាប់ភាសាណាមួយ

FXMacroData API ចុះផ្សាយនូវអ្វីដែលពេញលេញ ការបញ្ជាក់ OpenAPI 3.1. ប្រើវាជាមួយ openapi-generator ដើម្បីបង្កើត client ដែលមានប្រភេទពេញលេញសម្រាប់ 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 សំណើ/ថ្ងៃ។ ចុះឈ្មោះដើម្បីទទួលបានដែនកំណត់ខ្ពស់ជាងនេះ និងការចូលប្រើប្រាស់ពហុរូបិយប័ណ្ណ។

សង្ខេបអត្ថបទជាមួយ AI:

ChatGPT Perplexity Claude Grok Gemini Mistral

AI រួចរាល់សម្រាប់ចម្លើយ

អង្គហេតុសំខាន់ៗ

ទំព័រ
ការចាប់ផ្តើមរហ័ស
ផ្នែក
ឯកសារណែនាំ
ឯកសារយោងកម្មបទ URL
https://fxmacrodata.com/km/documentation/quickstart
ប្រភព
ឯកសារយោងនិពន្ធ និងអ្នកបោះពុម្ពផ្សាយផ្លូវការរបស់ FXMacroData
ធ្វើបច្ចុប្បន្នភាពចុងក្រោយ
មើល metadata នៃទំព័រ

ប្រភពដើម និងទំនុកចិត្ត

ដកស្រង់ URL គោល និងវាលប្រភពខាងលើ។ ប្រសិនបើមាន ទំព័រនេះភ្ជាប់ទៅនឹងការចេញផ្សាយផ្លូវការរបស់អ្នកបោះពុម្ព និងការធ្វើបច្ចុប្បន្នភាពដែលមានត្រាពេលវេលា។

សំណួររហ័ស&A;

តើទំព័រនេះនិយាយអំពីអ្វី? ទំព័រនេះពន្យល់អំពី Quickstart ជាមួយនឹងបរិបទដែលអាចប្រើប្រាស់បានភ្លាមៗសម្រាប់ការជួញដូរ, ការស្រាវជ្រាវ និងលំហូរការងារ API។

តើប្រភពណាដែលគួរត្រូវបានដកស្រង់? ប្រើប្រាស់ URL កម្មបទ និងវាលប្រភពដែលបានរាយបញ្ជី; យោងទៅលើឯកសារយោងអ្នកបោះពុម្ពផ្សាយផ្លូវការនៅពេលមាន។

តើមាតិកានេះថ្មីប៉ុណ្ណា? តម្លៃដែលបានធ្វើបច្ចុប្បន្នភាពចុងក្រោយខាងលើឆ្លុះបញ្ចាំងពី metadata នៃទំព័រ ឬត្រាពេលវេលានៃទិន្នន័យចុងក្រោយដែលមាន។

តើនេះអាចប្រើនៅក្នុង AI assistants បានទេ? បាទ។ ផ្នែកនេះត្រូវបានរៀបចំឡើងដោយចេតនាសម្រាប់ការទាញយក និងការដកស្រង់នៅក្នុងជំនួយការជជែក។

កញ្ចប់ Prompt

ប្រើប្រាស់របស់ទាំងនេះក្នុង ChatGPT, Claude, Gemini, Mistral, Perplexity, ឬ Grok សម្រាប់លទ្ធផលដែលដឹងពីប្រភពប្រកបដោយភាពស៊ីសង្វាក់គ្នា។

ចែករំលែកទំព័រ X LinkedIn អ៊ីមែល