Արագ մեկնարկ
Սկսեք ցանկացած լեզվով
FXMacroData API-ը ստանդարտ JSON REST API է: Ցանկացած լեզու՝ HTTP աջակցությամբ, կաշխատի: Freemium ժամանակային շարքերի endpoint-ները հասանելի են վերջին 90 օրերի համար՝ առանց բանալու: Ավելացրեք անհատական API բանալի՝ ամբողջական պատմությունը և վճարովի endpoint ընտանիքները բացելու համար:
Հիմնական URL
https://api.fxmacrodata.com
Աուտենտիֆիկացիա
X-API-Բանալի՝ YOUR_API_KEY
Արտոնագիր (Authorization): Bearer YOUR_API_KEY
?api_key=YOUR_API_KEY
Պատասխանի ձևաչափը
JSON (Content-Type: application/json)
openapi-generator-cli ավտոմատ կերպով հաճախորդներ ստեղծելու համար 40+ լեզուներով:
Accept-Encoding: gzip ամեն հարցման դեպքում (8–12× փոքր payload-ներ), վերօգտագործեք ETag պատասխանի վերնագիրը If-None-Match կրկնվող հարցումների վրա (վերադարձնում է 304 Not Modified առանց մարմնի), և փոխանցել ?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 կանչը
Արագ հարցում
Սկսեք իրական ժամանակի հայտարարման վերջնակետից: Ավտենտացիան մնում է api_key query պարամետր՝ բրաուզերի և սկրիպտի ուղղակի թեստավորման համար:
curl "https://api.fxmacrodata.com/v1/announcements/eur/inflation?api_key=YOUR_API_KEY"
Python հարցումներ
Պատճենվող Python API հարցումներ
Օգտագործեք այս ուղղակի REST օրինակները, երբ ցանկանում եք ստանալ հում API հարցում՝ SDK wrapper-ի փոխարեն: Փոխարինեք YOUR_API_KEY միայն պաշտպանված երթուղիների (routes) դեպքում:
USD ինֆլյացիայի շուկայական կոնսենսուս
Կոնսենսուսի, հարցման, կենտրոնական բանկի, 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 backtest-ների համար:
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 spot պատմություն
Օրական 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-ից: Սինխրոն և ասինխրոն հաճախորդներ, 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())
Կանխատեսումներ & Կանխատեսումներ
Այն /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. Կանխատեսման հասանելիությունը տարբերվում է release-ների հիման վրա — ստուգեք ծածկույթի մատրիցա. Առանց look-ahead-ի հետազոտության համար, հետևեք կետային 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_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+): Արտաքին գրադարաններ պետք չեն:
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);
Գեներացրեք տիպավորված հաճախորդ ցանկացած լեզվով
FXMacroData API-ը հրապարակում է ամբողջական OpenAPI 3.1 սպեցիֆիկացիա. Օգտագործեք այն openapi-generator Kotlin, Swift, Rust, Dart, Ruby, PHP, և 40+ այլ լեզուների համար լիովին տիպավորված հա khách-ներ ստեղծելու համար:
# 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 հարցում/օր: Բաժանորդագրվեք՝ ավելի բարձր սահմանաչափեր և բազմաարժույթ հասանելիություն ստանալու համար: