Python
import os
import requests
API = "https://api.financecalendarapi.com"API_KEY = os.environ["FC_API_KEY"]
def get(path: str, **params) -> dict: res = requests.get(f"{API}{path}", params=params, headers={"Authorization": f"Bearer {API_KEY}"}, timeout=10) if res.status_code != 200: problem = res.json() raise RuntimeError(f"{problem['code']}: {problem['detail']}") return res.json()
# T+2 for a USD trade on the NYSEprint(get("/v1/business-days/add", date="2027-12-23", n=2, calendars="USD,XNYS")["result"]) # 2027-12-28
# Is it a business day in London today?day = get("/v1/days/today", calendars="XLON", tz="Europe/London")print(day["is_business_day"])
# Every closure and early close for two calendars in 2027for cal in get("/v1/holidays", calendars="XNYS,XLON", **{"from": "2027-01-01", "to": "2027-12-31"})["calendars"]: for e in cal["entries"]: print(cal["id"], e["date"], e["kind"], e["close_time"] or "", e["name"])For many dates, fetch a calendar’s holidays once and do the arithmetic locally, rather than one request per date: the
API counts every request against your plan. pandas users can load format=csv straight into a DataFrame:
import pandas as pd
df = pd.read_csv(f"{API}/v1/holidays?calendars=XNYS&from=2026-01-01&to=2028-12-31&format=csv")