Client Libraries
Official, single-file clients for the SOTW API— no dependencies (except R's jsonlite), MIT licensed. The free tier needs no key; a keyraises rate limits. Every value the API returns traces to a primary institution under that source's licence.
Python
Download sotw.py ↓Install
# stdlib only — just drop sotw.py next to your code curl -O https://statisticsoftheworld.com/clients/sotw.py
Use
from sotw import SOTW
sotw = SOTW() # anonymous / free tier
# sotw = SOTW(api_key="YOUR_KEY") # higher limits
sotw.country("USA")
sotw.history("NY.GDP.MKTP.CD", "USA")
sotw.rankings("NY.GDP.MKTP.CD")
sotw.series_observations("UST.YC.10Y")
sotw.calendar(institution="BLS")Install
# requires jsonlite
install.packages("jsonlite")
download.file("https://statisticsoftheworld.com/clients/sotw.R", "sotw.R")Use
source("sotw.R")
sotw <- SOTW() # anonymous / free tier
# sotw <- SOTW(api_key = "YOUR_KEY")
sotw$country("USA")
sotw$history("NY.GDP.MKTP.CD", "USA")
sotw$rankings("NY.GDP.MKTP.CD")
sotw$series_observations("UST.YC.10Y")JavaScript / TypeScript
Download sotw.js ↓Install
# Node 18+ or the browser (uses global fetch) curl -O https://statisticsoftheworld.com/clients/sotw.js
Use
import { SOTW } from "./sotw.js";
const sotw = new SOTW(); // free tier
// const sotw = new SOTW({ apiKey: "YOUR_KEY" });
await sotw.country("USA");
await sotw.history("NY.GDP.MKTP.CD", "USA");
await sotw.rankings("NY.GDP.MKTP.CD");
await sotw.seriesObservations("UST.YC.10Y");Google Sheets
Download sotw-sheets.gs ↓Install
In your Sheet: Extensions → Apps Script → paste sotw-sheets.gs → Save.
Use
=SOTW_VALUE("NY.GDP.MKTP.CD", "USA") latest value
=SOTW_HISTORY("NY.GDP.MKTP.CD", "USA") full history range
=SOTW_SERIES("UST.YC.10Y") latest 10-year yield
=SOTW_RANK("NY.GDP.MKTP.CD", "USA") global rankLLM-native access
SOTW also runs a Model Context Protocol server so AI assistants can query the data directly, and publishes llms.txt for discovery. Full endpoint reference is in the API docs and the OpenAPI spec.