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.
$25/month 14-day free trial
Start Free Trial
Introducing Fxmacrodata Sse Streaming image
Share headline card X LinkedIn Email
Download

Platform News

Product Updates

Introducing Fxmacrodata Sse Streaming

FXMacroData now streams economic data releases in real time over Server-Sent Events. Connect once and receive live announcement payloads the moment central bank data is ingested — no polling required.

Cũng có sẵn tại English
Share article X LinkedIn Email

FXMacroData hiện cung cấp một thời gian thực Server-Sent Events (SSE) dòng điểm cuối. Kết nối một lần và ứng dụng của bạn sẽ nhận được một thông báo trực tiếp khi bất kỳ phát hành kinh tế được ăn bao gồm tất cả 18 đồng tiền hỗ trợ bao gồm Cục Dự trữ Liên bang quyết định chính sách, ECB thông báo lãi suất, và dữ liệu từ tất cả các ngân hàng trung ương lớn khác.

Có gì mới đây?

  • Địa điểm cuối SSE trực tiếp api.fxmacrodata.com/v1/stream/events
  • Kế hoạch miễn phí: Sự kiện thông báo USD, không cần khóa API
  • Kế hoạch chuyên nghiệp: tất cả 18 loại tiền tệ, có thể lọc theo loại tiền và chỉ số
  • Nhịp tim tự động mỗi ~ 30 giây để giữ cho kết nối sống thông qua proxy
  • Chơi lại hỗ trợ qua Last-Event-ID tiêu đề tiếp tục các sự kiện bị bỏ lỡ sau khi ngắt kết nối

Điểm cuối cùng

Dòng SSE có sẵn tại URL sau đây. Đây là một kết nối trực tiếp với máy chủ FXMacroData API Đừng sử dụng fxmacrodata.com/api/... đường dẫn cho SSE, vì tuyến đường đó đi qua lớp CDN mà đệm phản hồi và phá vỡ luồng trực tiếp.

https://api.fxmacrodata.com/v1/stream/events

Các thông số truy vấn tùy chọn cho phép bạn thu hẹp nguồn cấp dữ liệu:

  • currencies danh sách tách bằng dấu phẩy: usd,eur,gbp
  • indicators danh sách tách bằng dấu phẩy: inflation,policy_rate
  • api_key Chìa khóa API chuyên nghiệp cần thiết cho các loại tiền tệ không phải USD
curl -N "https://api.fxmacrodata.com/v1/stream/events?currencies=usd&indicators=inflation,policy_rate"

Định dạng sự kiện

Mỗi bản phát hành kinh tế được xuất bản tạo ra một khung EventSource chuẩn W3C:

id: usd_inflation_1772109000
event: announcement
data: {"event_id": "usd_inflation_1772109000", "currency": "usd", "indicator": "inflation", "records_written": 1, "timestamp": 1772109002}

Thông báo SSE là một kích hoạt hoạt động, không phải là tải dữ liệu đầy đủ. Tài liệu dữ liệu API để lấy lại các chuỗi thời gian đầy đủ bao gồm giá trị mới.


Ví dụ trình duyệt

Trong trình duyệt, bản địa EventSource xử lý kết nối lại tự động. ví dụ sau đây đăng ký Số tiền lương không nông nghiệp USDLạm phát USD sử dụng lớp không xác thực miễn phí:

const streamUrl = new URL("https://api.fxmacrodata.com/v1/stream/events");
streamUrl.searchParams.set("currencies", "usd");
streamUrl.searchParams.set("indicators", "non_farm_payrolls,inflation");

const source = new EventSource(streamUrl);

source.addEventListener("announcement", async (event) => {
const payload = JSON.parse(event.data);
console.log("Release received:", payload.currency, payload.indicator);

// Fetch the full record now that we know new data is available
const resp = await fetch(
  `https://api.fxmacrodata.com/v1/announcements/${payload.currency}/${payload.indicator}`
);
const records = await resp.json();
console.log("Latest record:", records[records.length - 1]);
});

source.onerror = (err) => console.error("SSE error", err);

Ví dụ Python

Đối với một nhân viên phía máy chủ, sử dụng requests n ng m Last-Event-ID khi kết nối lại để xem lại bất kỳ sự kiện nào đã bỏ lỡ:

import json, time, requests

API_KEY = "YOUR_API_KEY"
STREAM_URL = (
  "https://api.fxmacrodata.com/v1/stream/events"
  "?currencies=usd,eur&indicators=inflation,policy_rate&api_key=" + API_KEY
)

def consume():
  last_id = None
  while True:
      headers = {"Accept": "text/event-stream"}
      if last_id:
          headers["Last-Event-ID"] = last_id
      try:
          with requests.get(STREAM_URL, headers=headers, stream=True, timeout=90) as r:
              r.raise_for_status()
              event = {}
              for line in r.iter_lines(decode_unicode=True):
                  if not line:
                      if event.get("event") == "announcement" and event.get("data"):
                          payload = json.loads(event["data"])
                          last_id = event.get("id") or payload["event_id"]
                          print("New release:", payload)
                      event = {}
                      continue
                  if not line.startswith(":"):
                      field, _, value = line.partition(":")
                      event[field] = value.lstrip()
      except requests.RequestException as e:
          print(f"Disconnected: {e}. Retrying...")
          time.sleep(3)

consume()

Tính sẵn có của kế hoạch

Kế hoạch miễn phí

Chỉ có sự kiện thông báo USD. Không cần khóa API. Kết nối trực tiếp với api.fxmacrodata.com/v1/stream/events không có bất kỳ thông số xác thực nào.

Kế hoạch chuyên nghiệp

Tất cả 18 loại tiền tệ. lọc theo bất kỳ sự kết hợp nào của các loại tiền và chỉ số. ?api_key=YOUR_KEY trong chuỗi truy vấn.


Tạo ra gì tiếp theo

SSE stream hoạt động tốt nhất như một lớp kích hoạt trên các dòng công việc REST hiện có của bạn.

  • Cập nhật thẻ bảng điều khiển thời gian thực làm mới một bảng ngay khi dữ liệu mới đến thay vì thăm dò mỗi N phút.
  • Thông báo giao dịch so sánh bản phát hành mới nhất với ngưỡng của bạn và bắn một thông báo Slack hoặc webhook ngay lập tức.
  • Lưu ý không hợp lệ sử dụng sự kiện SSE như là tín hiệu để lấy lại và lưu trữ hồ sơ chỉ số cập nhật.
  • Kết hợp với Lịch phát hành biết kế hoạch tiếp theo và sử dụng SSE như là xác nhận trực tiếp khi nó thực sự xuất bản.

Để biết đầy đủ bước thực hiện bước, xem Hướng dẫn SSE.


Đội ngũ FXMacroData

Blogroll

AI Answer-Ready

Key Facts

Page
Introducing FXmacrodata Sse Streaming
Section
Articles
Canonical URL
https://fxmacrodata.com/vi/articles/introducing-fxmacrodata-sse-streaming
Source
FXMacroData editorial and official publisher references
Last Updated
2026-06-09 13:02 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 Introducing FXmacrodata Sse Streaming 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.