Live release feed
Sub-second macro releases for FX backtests
Point-in-time history
Official CPI, jobs, GDP, and central-bank events with point-in-time history.
USD 25/month 14-day free trial
Start Free Trial
빠른 시작: Node.js로 FXMacroData에 연결 image
Share headline card X LinkedIn Email
Download

By Language

Quick Start Guides

빠른 시작: Node.js로 FXMacroData에 연결

몇 분 안에 Node.js에서 FXMacroData를 실행하십시오. 내장된 가져오기 API, 비 동기화 / 대기 패턴, 멀티 지표 요청 및 중앙 은행 데이터를 뽑기 위해 실행 준비가 된 스크립트를 포함합니다.

다른 언어로도 제공 English
Share article X LinkedIn Email

FXMacroData REST API는 HTTP GET 요청을 할 수있는 모든 언어에서 소비되도록 설계되었습니다. Node.js는 내장 된 fetch implementation from v18 onwards, so there is nothing extra to install for basic usage — just your API key and a few lines of JavaScript. This guide walks you from zero to a working multi-indicator script in under ten minutes.

당신 이 건축 할 것

자율화된 Node.js 스크립트 FXMacroData REST API에 대한 인증, G10 여러 통화에 대한 정책율 및 인플레이션 데이터를 병행으로 가져와 콘솔에 깨끗한 요약 테이블을 인쇄합니다.

필수 조건

  • Node.js 18 이상 v18은 글로벌 fetch API: v20+는 생산을 위해 권장됩니다.
  • npm (Node.js와 함께 묶여) 선택적인 패키지를 추가하는 경우만 필요합니다
  • FXMacroData API 키 등록하세요 / 가입 그리고 대시보드에서 키를 복사

Node.js 버전을 확인하세요:

node --version   # should print v18.x.x or later

단계 1 API 키를 안전하게 저장

버전 제어에 전념할 수 있는 소스 파일에서 API 키를 하드 코딩하지 마십시오. 가장 간단한 안전한 접근법은 실행 시에서 읽히는 환경 변수입니다.

리눅스/맥오스에서는 프로필에 추가 (~/.bashrc 아니면 ~/.zshrc):

export FXMD_API_KEY="your_actual_api_key_here"

윈도우에서 (파워):

$env:FXMD_API_KEY = "your_actual_api_key_here"

Node.js 프로젝트의 경우, .env 파일과 함께 도텐 그 설정에 대한 단계 6을 참조하십시오.

단계 2 API 형태를 이해

모든 FXMacroData 지표 엔드포인트는 동일한 패턴을 따르고, 일반 검색 보조자를 직접적으로 만들 수 있습니다. 기본 구조는 다음과 같습니다:

GET https://fxmacrodata.com/api/v1/announcements/{currency}/{indicator}?api_key=YOUR_API_KEY

응답은 JSON입니다. data 매 요소는 를 가지고 있습니다. date숫자 val, 그리고 (대부분의 지표에 대해) announcement_datetime 값이 풀린 순간을 정확히 알려주는 것:

{
  "data": [
    { "date": "2025-03-19", "val": 4.25, "announcement_datetime": "2025-03-19T18:00:00Z" },
    { "date": "2025-01-29", "val": 4.25, "announcement_datetime": "2025-01-29T19:00:00Z" },
    { "date": "2024-12-18", "val": 4.25, "announcement_datetime": "2024-12-18T19:00:00Z" }
  ]
}

이 깨끗하고 일관된 구조는 비즈니스 로직, 데이터베이스 또는 하류 API에서 사용하기 전에 거의 변환이 필요하지 않습니다.

단계 3 첫 전화

이름의 파일을 만들자 fxmd.js and add the following. This fetches the US Federal Reserve policy rate for the last two years using Node.js's built-in fetch

// fxmd.js  —  requires Node.js 18+
const API_KEY = process.env.FXMD_API_KEY;
const BASE    = "https://fxmacrodata.com/api/v1";

async function getIndicator(currency, indicator, startDate) {
  const url = new URL(`${BASE}/announcements/${currency}/${indicator}`);
  url.searchParams.set("api_key", API_KEY);
  if (startDate) url.searchParams.set("start", startDate);

  const res = await fetch(url.toString());
  if (!res.ok) {
    throw new Error(`API error ${res.status}: ${await res.text()}`);
  }
  const json = await res.json();
  return json.data ?? [];
}

// Fetch the Fed policy rate
const data = await getIndicator("usd", "policy_rate", "2023-01-01");
console.log(`Latest USD policy rate: ${data[0]?.val}% on ${data[0]?.date}`);

실행해

FXMD_API_KEY=your_key node fxmd.js

최고급 대기 위의 예제에서는 최상위 레벨을 사용했습니다. await이쪽은 작동합니다 .mjs 파일이나 언제 "type": "module" 네 에 꽂혀있어요 package.json. CommonJS 모듈은 호출을 async 함수와 즉시 호출 (단계 5의 완전한 예제 참조).

단계 4 여러 표시기를 병행해서 가져오기

Promise.all fires all requests concurrently, so fetching a dozen indicators takes roughly the same wall-clock time as fetching one. Here is a reusable pattern for pulling several currencies and indicators at once:

const CURRENCIES  = ["usd", "eur", "gbp", "aud", "jpy"];
const INDICATORS  = ["policy_rate", "inflation"];
const START       = "2024-01-01";

// Build a flat list of [currency, indicator] pairs
const pairs = CURRENCIES.flatMap(c => INDICATORS.map(i => [c, i]));

// Fire all requests in parallel
const results = await Promise.all(
  pairs.map(([currency, indicator]) =>
    getIndicator(currency, indicator, START)
      .then(data => ({ currency, indicator, latest: data[0] ?? null }))
      .catch(err => ({ currency, indicator, latest: null, error: err.message }))
  )
);

// Print a quick summary
for (const row of results) {
  if (row.error) {
    console.log(`${row.currency.toUpperCase()} ${row.indicator}: ERROR — ${row.error}`);
  } else if (row.latest) {
    console.log(
      `${row.currency.toUpperCase()} ${row.indicator}: ${row.latest.val} (${row.latest.date})`
    );
  }
}

- .catch 요청당 단 하나의 잘못된 응답은 전체 을 중단하지 않습니다. 일부 데이터가 여전히 실행 가능한 야간 작업을 실행할 때 유용합니다.

단계 5 제작 준비 된 스크립트

아래는 올바른 오류 처리, 구성 가능한 통화 및 지표 목록 및 로깅 또는 하류 처리용으로 형식화된 출력으로 완전한 CommonJS 호환 스크립트입니다:

// macro-snapshot.js  —  CommonJS, Node.js 18+
"use strict";

const API_KEY = process.env.FXMD_API_KEY;
const BASE    = "https://fxmacrodata.com/api/v1";

if (!API_KEY) {
  console.error("Error: FXMD_API_KEY environment variable is not set.");
  process.exit(1);
}

// ── Configuration ──────────────────────────────────────────────────────────
const CURRENCIES = ["usd", "eur", "gbp", "cad", "jpy", "aud", "nzd", "chf"];
const INDICATORS = ["policy_rate", "inflation", "unemployment"];
const START_DATE = "2024-01-01";
// ───────────────────────────────────────────────────────────────────────────

async function getIndicator(currency, indicator, startDate) {
  const url = new URL(`${BASE}/announcements/${currency}/${indicator}`);
  url.searchParams.set("api_key", API_KEY);
  if (startDate) url.searchParams.set("start", startDate);

  const res = await fetch(url.toString());
  if (!res.ok) {
    const body = await res.text().catch(() => "");
    throw new Error(`HTTP ${res.status}${body ? ": " + body.slice(0, 120) : ""}`);
  }
  const json = await res.json();
  return Array.isArray(json.data) ? json.data : [];
}

async function main() {
  const pairs = CURRENCIES.flatMap(c => INDICATORS.map(i => [c, i]));

  const results = await Promise.all(
    pairs.map(async ([currency, indicator]) => {
      try {
        const data = await getIndicator(currency, indicator, START_DATE);
        return { currency, indicator, latest: data[0] ?? null, error: null };
      } catch (err) {
        return { currency, indicator, latest: null, error: err.message };
      }
    })
  );

  // Group by currency for readable output
  const byCurrency = {};
  for (const row of results) {
    if (!byCurrency[row.currency]) byCurrency[row.currency] = [];
    byCurrency[row.currency].push(row);
  }

  console.log("\n=== FXMacroData Macro Snapshot ===\n");
  for (const [currency, rows] of Object.entries(byCurrency)) {
    console.log(`  ${currency.toUpperCase()}`);
    for (const row of rows) {
      if (row.error) {
        console.log(`    ${row.indicator.padEnd(20)} — error: ${row.error}`);
      } else if (row.latest) {
        console.log(
          `    ${row.indicator.padEnd(20)} ${String(row.latest.val).padStart(8)}  (${row.latest.date})`
        );
      } else {
        console.log(`    ${row.indicator.padEnd(20)} — no data`);
      }
    }
    console.log();
  }
}

main().catch(err => {
  console.error("Fatal:", err.message);
  process.exit(1);
});

스크립트를 실행하세요:

FXMD_API_KEY=your_key node macro-snapshot.js

샘플 출력:

=== FXMacroData Macro Snapshot ===

  USD
    policy_rate             4.25  (2025-03-19)
    inflation               2.40  (2025-04-10)
    unemployment            4.20  (2025-04-04)

  EUR
    policy_rate             2.40  (2025-04-17)
    inflation               2.20  (2025-04-16)
    unemployment            6.10  (2025-03-31)

  GBP
    policy_rate             4.50  (2025-03-20)
    inflation               2.60  (2025-03-26)
    unemployment            4.40  (2025-04-15)
  ...

단계 6 지역 개발을 위한 도텐브를 이용

더 큰 Node.js 프로젝트를 만들 때 API 키를 .env 파일로 자동으로 로드합니다. 도텐 패키지:

npm install dotenv

을 만들자 .env 프로젝트 루트에서 파일을 (이것을 추가 .gitignore 즉시):

FXMD_API_KEY=your_actual_api_key_here

스크립트의 맨 위에 한 줄 더하세요.

require("dotenv").config();   // CommonJS
// or
import "dotenv/config";       // ES module

그 후엔 이 글의 나머지 부분은 process.env.FXMD_API_KEY 이전과 똑같은 모습입니다. 다른 변화가 필요 없습니다.

생산 중 (클라우드 기능, AWS 람다, 베르셀, 렌더 등) FXMD_API_KEY 플랫폼의 비밀 관리자를 통해 보안 환경 변수로 .env 파일에서 원본 제어로 이동합니다.

단계 7 전체 지표 목록을 탐구하십시오

위의 매크로 스냅샷은 세 가지 지표를 다루지만 FXMacroData는 14 개의 주요 통화 블록에서 80 개 이상의 시간 계열을 노출합니다. getIndicator 이 모든 것을 도와주는 도구가 작동합니다. 그냥 통화와 지표 슬러그를 교환합니다. FX 트레이더에 대한 몇 가지 높은 가치 사례:

  • 실제율 빼기 inflation 에서 policy_rate 중장기 외환 방향의 핵심 동력인 두 통화 사이의 실제 금리 차이를 계산하기 위해 미국 달러 정책금리 문서 최종점 세부사항을 위해
  • 노동자 데이터 unemployment non_farm_payrolls그리고 average_hourly_earnings (USD) 는 중앙은행의 반응 기능에 대한 초기 신호를 제공합니다.
  • 감정 consumer_confidence pmi그리고 business_confidence lead hard-data indicators by one to two months and can precede currency moves before they appear in rate decisions.
  • 무역 흐름 trade_balance exports그리고 imports 상품화폐 쌍 (AUD, NZD, CAD) 을 거래 조건의 변화와 연결합니다.

모든 통화에 대한 전체 카탈로그를 https://fxmacrodata.com/api/v1/catalogue/{currency}?api_key=YOUR_API_KEY또는 에서 상호 작용하는 문서들을 탐색하십시오. api-data-docs-

요약

이제 Node.js에서 FXMacroData를 소비하는 데 필요한 모든 것을 가지고 있습니다:

  • 일반적 getIndicator(currency, indicator, startDate) auth 및 오류 확인을 처리하는 보조자
  • 를 통해 병행 멀티 지표 요청 Promise.all 요청에 따른 오류 격리
  • 생산 준비가 된 스크립트, 당신은 스케줄, 서버 없는 기능에 배포, 또는 기존 Node.js 백엔드에 통합 할 수 있습니다
  • 환경 변수 또는 를 통해 안전한 API 키 관리 dotenv

다음 단계로 자연스럽게: 스냅샷 스크립트를 cron 작업이나 작업 실행기와 같이 스케줄링합니다. n8n, 데이터베이스에 결과를 푸시하거나 거래 알고리즘에 입력합니다. 스크립트가 읽는 동일한 깨끗한 JSON 구조는 React 대시보드, Express API 또는 Cloud Function 트리거를 구축하는 것과 동일합니다.

더 많은 언어별 안내를 위해 빠른 시작 가이드 부문 파이썬과 R의 통로들은 분석과 시각화를 위한 생태계별 도구와 같은 지표 세트를 다루고 있습니다.

Blogroll

AI Answer-Ready

Key Facts

Page
Quick Start Nodejs FXmacrodata
Section
Articles
Canonical URL
https://fxmacrodata.com/ko/articles/quick-start-nodejs-fxmacrodata
Source
FXMacroData editorial and official publisher references
Last Updated
2026-06-15 11:06 UTC

Provenance And Trust

Cite the canonical URL and source field above. Where available, this page maps to official publisher releases and timestamped updates.

Quick Q&A

What is this page about? This page explains Quick Start Nodejs FXmacrodata with directly usable context for trading, research, and API workflows.

What source should be cited? Use the canonical URL and the listed source field; cite official publisher references when available.

How fresh is this content? The last updated value above reflects the page metadata or latest available data timestamp.

Can this be used in AI assistants? Yes. This section is intentionally structured for retrieval and citation in chat assistants.

Prompt Packs

Use these in ChatGPT, Claude, Gemini, Mistral, Perplexity, or Grok for consistent source-aware outputs.