Quickstart
ඕනෑම භාෂාවකින් ආරම්භ කරන්න
FXMacroData API යනු සම්මත JSON REST API එකකි. HTTP සහාය ඇති ඕනෑම භාෂාවක් ක්රියා කරයි. යතුරක් නොමැතිව වඩාත්ම මෑතකාලීන 90 දින සඳහා freemium කාල-ශ්රේණි endpoints ලබා ගත හැක. සම්පූර්ණ ඉතිහාසය සහ ගෙවන endpoint පවුල් විවෘත කිරීමට Individual API යතුරක් එක් කරන්න.
මූලික 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 40+ භාෂාවලින් clients ස්වයංක්රීයව ජනනය කිරීමට.
Accept-Encoding: gzip සෑම ඉල්ලීමකදීම (8–12× කුඩා payloads), නැවත භාවිතා කරන්න ETag ප්රතිචාර ශීර්ෂකය (response header) මෙහි If-None-Match පුනරාවර්තන සමීක්ෂණ මත (ප්රතිලාභ) 304 Not Modified ශරීරයක් නොමැතිව), සහ ලබා දෙන්න ?limit=50 එවැනි තනි-දර්ශක endpoints මත /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 වස්තුව. Backtests සහ ආයතනික වාර්තාකරණය සඳහා, පරීක්ෂා කරන්න point_in_time_safe, has_announcement_datetime, source_type, සහ is_stale.
පළමු API ඇමතුම
ඉක්මන් ඉල්ලීම
සජීවී නිවේදන endpoint එකකින් ආරම්භ කරන්න. සහතික කිරීම (Authentication) පවතින්නේ api_key සෘජු බ්රවුසර සහ ස්ක්රිප්ට් පරීක්ෂාව සඳහා විමසුම් පරාමිතිය.
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Python ඉල්ලීම්
පිටපත් කළ හැකි Python API ඉල්ලීම්
SDK wrapper එකක් වෙනුවට ඔබට raw API ඉල්ලීම අවශ්ය වූ විට මෙම සෘජු REST උදාහරණ භාවිතා කරන්න. ආරක්ෂිත මාර්ගවල පමණක් 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))
known-at timestamps සහිත USD උද්ධමනය
point-in-time backtests සඳහා පොදු USD උද්ධමන වාර්තා.
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 ස්පොට් ඉතිහාසය
යුගල ප්රස්ථාර, ආකෘති සහ නිකුත් කිරීමේ overlay සඳහා දෛනික 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))
Python
නිලවරුන් ස්ථාපනය කරන්න fxmacrodata PyPI වෙතින් පැකේජය. Sync සහ async clients, pandas-ready ප්රතිදානය.
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, එවිට ඔබට පුරෝකථනයන් සැබෑ නිරීක්ෂණ සමඟ සම්බන්ධ කළ හැක.
prediction_type="fxmacrodata" FXMacroData විසින් ජනනය කරන ලද ඇස්තමේන්තුවකි; සැබෑ සම්පාදිත පොදු එකක් ලෙස ලේබල් කර ඇත market_consensus. පුරෝකථන ලබා ගත හැකි බව නිකුත් කිරීමට අනුව වෙනස් වේ — පරීක්ෂා කරන්න ආවරණ න්යාසය. Look-ahead-free පර්යේෂණ සඳහා, අනුගමනය කරන්න point-in-time backtesting මාර්ගෝපදේශය.
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 වර්ග පිළිබඳ යොමුව
| 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
ස්ථාපනය කිරීමක් අවශ්ය නොවේ. ඕනෑම ටර්මිනලයකින් ක්රියා කරයි.
# 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
Fetch API සමඟ Node.js (18+), Deno, Bun සහ නවීන බ්රවුසරවල ක්රියා කරයි.
නිල npm ක්ලයන්ට්
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+). බාහිර පුස්තකාල අවශ්ය නොවේ.
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
built-in භාවිතා කරයි 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 Kotlin, Swift, Rust, Dart, Ruby, PHP, සහ 40+ අනෙකුත් භාෂාවන් සඳහා සම්පූර්ණයෙන් ටයිප් කරන ලද clients නිපදවීමට.
# 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
ගොඩනැගීමට සූදානම්ද?
USD endpoints දිනකට 100 ඉල්ලීම් දක්වා යතුරක් රහිත ඇගයීමකට සහය දක්වයි. ඉහළ සීමාවන් සහ බහු-මුදල් ප්රවේශය සඳහා දායක වන්න.