Quickstart
Get started in any language
The FXMacroData API is a standard JSON REST API. Any language with HTTP support works. USD endpoints are free — no key needed to try the examples below.
Base URL
https://fxmacrodata.com/api
Authentication
?api_key=YOUR_API_KEY
Response format
JSON (Content-Type: application/json)
openapi-generator-cli to auto-generate clients in 40+ languages.
Python
Install the official fxmacrodata package from PyPI. Sync and async clients, pandas-ready output.
Using the SDK
from fxmacrodata import Client client = Client(api_key="YOUR_API_KEY") # USD inflation — free, no key required data = client.get_indicator("usd", "inflation") # EUR policy rate — requires API key rate = client.get_indicator("eur", "policy_rate") # Free forex price data fx = client.get_fx_price("usd", "jpy")
Using the REST API directly
import requests resp = requests.get( "https://fxmacrodata.com/api/v1/announcements/usd/inflation", timeout=30, ) resp.raise_for_status() print(resp.json())
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", "cpi") print(data) asyncio.run(main())
cURL
No install needed. Works from any terminal.
# USD inflation — free, no key required curl "https://fxmacrodata.com/api/v1/announcements/usd/inflation" # EUR policy rate — pass your API key as a query parameter curl "https://fxmacrodata.com/api/v1/announcements/eur/policy_rate?api_key=YOUR_API_KEY" # Release calendar for Australia curl "https://fxmacrodata.com/api/v1/calendar/aud?api_key=YOUR_API_KEY" # Forex price history curl "https://fxmacrodata.com/api/v1/forex/usd/jpy" # Data catalogue (discover available indicators) curl "https://fxmacrodata.com/api/v1/data-catalogue"
JavaScript / TypeScript
Works in Node.js (18+), Deno, Bun, and modern browsers with the Fetch API.
// USD inflation — free, no key required const res = await fetch( "https://fxmacrodata.com/api/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://fxmacrodata.com/api/v1/announcements/eur/policy_rate?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 — free, no key required resp, err := http.Get("https://fxmacrodata.com/api/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.
library(httr) library(jsonlite) # USD inflation — free, no key required res <- GET("https://fxmacrodata.com/api/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://fxmacrodata.com/api/v1/announcements/eur/policy_rate", query = list(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://fxmacrodata.com/api/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 — free, no key required var json = await client.GetStringAsync( "https://fxmacrodata.com/api/v1/announcements/usd/inflation" ); var doc = JsonDocument.Parse(json); Console.WriteLine(doc.RootElement);
MATLAB
Uses the built-in webread function.
% USD inflation — free, no key required data = webread('https://fxmacrodata.com/api/v1/announcements/usd/inflation'); disp(data); % With API key for non-USD opts = weboptions('Timeout', 30); url = 'https://fxmacrodata.com/api/v1/announcements/eur/policy_rate?api_key=YOUR_API_KEY'; 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://fxmacrodata.com/api/openapi.json \ -g go \ -o ./fxmacrodata-go-client # Generate a Java client openapi-generator-cli generate \ -i https://fxmacrodata.com/api/openapi.json \ -g java \ -o ./fxmacrodata-java-client
Ready to build?
USD endpoints are free to use immediately. Subscribe for multi-currency access.