Skip to content

Quickstart

Get started in any language

The FXMacroData API is a standard JSON REST API for server-side use. Any language with HTTP support works. USD announcement data, the USD release calendar, and the data catalogue are free without a key: the most recent 90 days, on a 15-minute release delay, up to 100 requests per day. Forecast values (USD included), every other currency, real-time releases, and full history need an API key, sent in the X-API-Key header. See what is free

Base URL

https://api.fxmacrodata.com

Authentication

X-API-Key: YOUR_API_KEY

Authorization: Bearer YOUR_API_KEY

The legacy ?api_key= query parameter is deprecated: keys in URLs end up in logs.

Response format

JSON (Content-Type: application/json)

Generate typed clients automatically: Use the published OpenAPI 3.1 spec with openapi-generator-cli to auto-generate clients in 40+ languages.
Free performance wins: Send Accept-Encoding: gzip on every request (8–12× smaller payloads), reuse the ETag response header in If-None-Match on repeat polls (returns 304 Not Modified with no body), and pass ?limit=50 on single-indicator endpoints such as /v1/announcements/usd/inflation or /v1/predictions/usd/inflation when you only need recent rows. See the full reference →
Call the API from your server: The API does not send CORS headers to browser origins, so a fetch() from a web page is blocked by the browser. Call FXMacroData from your backend and keep the API key out of client-side code.
Discover indicator slugs before hard-coding paths: Indicator slugs vary by currency — core_pce exists for USD but not for every currency. List every slug a currency supports with GET /v1/data_catalogue/{currency}, for example /v1/data_catalogue/usd. A 200 whose data array is empty and which carries no_data.error_code: NO_DATA_IN_REQUESTED_WINDOW means the slug is valid and only the requested date window is empty — widen start_date/end_date rather than changing the URL or retrying. A 404 means the currency or indicator slug is wrong.
Check response quality: Source-backed endpoints return a top-level data_quality object. For backtests and institutional reporting, inspect point_in_time_safe, has_announcement_datetime, source_type, and is_stale. point_in_time_safe is false whenever any row in the window carries a publication time derived from the series' measured release lag, so check assumed_release_time_count and the per-row release_time_assumed flag before treating a false as unusable.

Marketplace access

Use FXMacroData through RapidAPI

RapidAPI is an optional marketplace channel for the FXMacroData REST API. FXMacroData supplies the data; RapidAPI manages your marketplace subscription, API key, request quota and billing. No separate FXMacroData account or key is needed for requests through this channel.

  1. Open the official FXMacroData listing and choose a plan. Check the pricing tab for current coverage, quotas and rate limits.
  2. Copy your RapidAPI key from the endpoint playground and store it in your server environment as RAPIDAPI_KEY.
  3. Send requests to https://fxmacrodata1.p.rapidapi.com with both RapidAPI headers, as shown below.
curl --request GET \
  --url "https://fxmacrodata1.p.rapidapi.com/v1/announcements/usd/inflation?limit=3" \
  --header "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  --header "X-RapidAPI-Host: fxmacrodata1.p.rapidapi.com"

Marketplace endpoint coverage

The listing includes announcements, release calendars, the data catalogue, daily FX rates, COT positioning, central-bank news, market sessions and a health check. Currency and history access depend on your RapidAPI plan. Use the catalogue to find supported indicator slugs.

Direct FXMacroData access

The other examples on this page use api.fxmacrodata.com and an FXMacroData X-API-Key when required. Keys and subscriptions are separate between channels. A RapidAPI subscription covers the listed REST endpoints; website subscriptions, MCP, forecasts, streaming and webhooks are separate offerings.

Keep your key out of browser code and public repositories. For longer result sets, follow pagination.next_offset until pagination.has_more is false. Never send your API key to support.

First API call

Quick Request

The first snippet runs as-is: no key needed for USD data, served 15 minutes after release. Add X-API-Key for all 22 currencies and real-time delivery, sent from a server, script, or notebook.

No key · USD inflation GET /v1/announcements/usd/inflation
1 · No key needed
# USD inflation, no key: 15-minute delay, most recent 90 days
curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation?limit=5"
2 · With API key · EUR
# EUR inflation: add X-API-Key for all 22 currencies and real-time releases
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/announcements/eur/inflation"

Python requests

Copyable Python API requests

Use these direct REST examples when you want the raw API request instead of an SDK wrapper. Replace YOUR_API_KEY only on protected routes.

USD inflation market consensus

Consensus, survey, central-bank, IMF, and FXMacroData forecasts joined to realised announcements.

import requests

url = "https://api.fxmacrodata.com/v1/predictions/usd/inflation"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()

print(payload.get("data", payload))

USD inflation with known-at timestamps

Public USD inflation records for 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))

EUR/USD FX spot history

Daily FX price history for pair charts, models, and release overlays.

import requests

url = "https://api.fxmacrodata.com/v1/forex/eur/usd"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()

print(payload.get("data", payload))

AUD policy-rate history

Central-bank decision history with release timing for no-lookahead research.

import requests

url = "https://api.fxmacrodata.com/v1/announcements/aud/policy_rate"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()

print(payload.get("data", payload))

JPY upcoming release schedule

Upcoming macro events with UTC, market-local, and requested-timezone fields for planning alerts, model refreshes, and trading reviews.

import requests

url = "https://api.fxmacrodata.com/v1/calendar/jpy"
params = {
    "timezone": "Asia/Tokyo",
}
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, params=params, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()

print(payload.get("data", payload))

Gold commodity prices

Official precious-metals time series with daily values and change fields.

import requests

url = "https://api.fxmacrodata.com/v1/commodities/gold"
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.get(url, headers=headers, timeout=20)
response.raise_for_status()
payload = response.json()

print(payload.get("data", payload))
Official SDK

Python

Install the official fxmacrodata package from PyPI (1.2.x). Sync and async clients return plain JSON dictionaries that load straight into pandas. Client() with no key reads the free USD tier; pass api_key for every other currency and real-time delivery.

pip install fxmacrodata

Using the SDK

from fxmacrodata import Client

# USD inflation — no key needed: 15-minute delay, most recent 90 days
data = Client().get_indicator("usd", "inflation")
print(data["data"][0])

# Add X-API-Key for all 22 currencies and real-time releases
client = Client(api_key="YOUR_API_KEY")

# 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")

Using the REST API directly

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])

Paging through full history

import requests

URL = "https://api.fxmacrodata.com/v1/announcements/eur/inflation"
HEADERS = {"X-API-Key": "YOUR_API_KEY"}

rows, offset = [], 0
while True:
    resp = requests.get(
        URL,
        params={"limit": 100, "offset": offset},
        headers=HEADERS,
        timeout=30,
    )
    resp.raise_for_status()
    page = resp.json()
    rows.extend(page["data"])
    if not page["pagination"]["has_more"]:
        break
    offset = page["pagination"]["next_offset"]

print(len(rows), "rows")

Async client

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())
New

Predictions & Forecasts

The /v1/predictions/{currency}/{indicator} endpoint surfaces forecast data from market consensus surveys, central-bank projections, IMF World Economic Outlook, and professional-forecaster surveys. Predictions are requested for a specific currency and indicator, such as https://api.fxmacrodata.com/v1/predictions/usd/inflation; currency-only prediction requests are not supported. Each prediction is linked to its announcement via announcement_id, so you can join forecasts with realised observations.

Do not treat every forecast as consensus. prediction_type="fxmacrodata" is an FXMacroData-generated estimate; a true compiled consensus is labelled market_consensus. Forecast availability varies by release — check the coverage matrix. For look-ahead-free research, follow the point-in-time backtesting guide.
Forecast values need an API key for every currency, USD included. Coverage — which sources forecast each indicator — is free without a key at /v1/predictions/coverage/{currency}. A trial or paid key returns the forecast values.

Python — fetch predictions and join with actuals

import requests

HEADERS = {"X-API-Key": "YOUR_API_KEY"}

# Predictions for USD inflation — requires API key
preds = requests.get(
    "https://api.fxmacrodata.com/v1/predictions/usd/inflation",
    headers=HEADERS,
    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"},
    headers=HEADERS,
    timeout=30,
).json()

# Join predictions with actuals using announcement_id
actuals = requests.get(
    "https://api.fxmacrodata.com/v1/announcements/usd/inflation",
    headers=HEADERS,
    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 — fetch predictions by type

# Which sources forecast USD indicators — free, no key
curl "https://api.fxmacrodata.com/v1/predictions/coverage/usd"

# All USD inflation predictions — requires API key
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/usd/inflation"

# Filter by prediction type: market_consensus, imf_weo, central_bank_forecast, survey
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/usd/inflation?prediction_type=market_consensus"

# EUR policy-rate predictions
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/predictions/eur/policy_rate"

Prediction types reference

prediction_typeDescription
market_consensusCompiled market or economist event consensus, where available
market_predictionProfessional-forecaster point prediction
model_nowcastCentral-bank or reserve-bank model nowcast
surveyCentral-bank survey of professional forecasters (e.g. ECB SPF)
central_bank_forecastOfficial central-bank projection (e.g. RBNZ MPS, BoC MPR)
central_bank_projectionOfficial central-bank projection
imf_weoIMF World Economic Outlook projection
fxmacrodataFXMacroData-generated prediction combining central-bank guidance, surveys, and historical trends

cURL

No install needed. Works from any terminal.

# USD inflation — no-key evaluation, up to 100 requests/day
curl "https://api.fxmacrodata.com/v1/announcements/usd/inflation"

# EUR policy rate — send your API key in the X-API-Key header
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate"

# Release calendar for Australia — requires API key
curl -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/calendar/aud"

# 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 -H "X-API-Key: YOUR_API_KEY" "https://api.fxmacrodata.com/v1/forex/usd/jpy"

# Data catalogue (discover available indicators for USD)
curl "https://api.fxmacrodata.com/v1/data_catalogue/usd"

JavaScript / TypeScript

Works server-side in Node.js (18+), Deno, and Bun. The API does not send CORS headers, so call it from your backend rather than from browser code.

Official 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);

Using Fetch directly

// 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 = process.env.FXMD_API_KEY;
const eur = await fetch(
  "https://api.fxmacrodata.com/v1/announcements/eur/policy_rate",
  { headers: { "X-API-Key": API_KEY } }
);
console.log(await eur.json());

Go

No external packages needed — the standard library handles everything.

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

Requires httr and 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",
  add_headers(`X-API-Key` = "YOUR_API_KEY")
)
print(fromJSON(content(eur, "text")))

Java

Uses java.net.http (Java 11+). No external libraries needed.

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

Uses 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

Uses the built-in 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, 'HeaderFields', {'X-API-Key', 'YOUR_API_KEY'});
url = 'https://api.fxmacrodata.com/v1/announcements/eur/policy_rate';
eur = webread(url, opts);
disp(eur);

Generate a typed client for any language

The FXMacroData API publishes a complete OpenAPI 3.1 specification. Use it with openapi-generator to produce fully typed clients for Kotlin, Swift, Rust, Dart, Ruby, PHP, and 40+ other languages.

# 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

Ready to build?

USD release data works without a key, up to 100 requests/day and 15 minutes behind publication. Subscribe for real-time releases, forecast values, full history, higher limits, and every currency.

AI Answer-Ready

Key Facts

Page
Quickstart
Section
Documentation
Canonical URL
https://fxmacrodata.com/documentation/quickstart
Source
FXMacroData editorial and official publisher references
Last Updated
See page metadata

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 Quickstart 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.

Share page X LinkedIn Email