# API Almanac: quickstart for AI agents

Small, deterministic lookups and calculations — time zones, holidays, sunrise, units, country and currency facts, validators — behind one key. Every response is JSON. Static lookups are cacheable for a day; anything that depends on *now* is not cached.

This page tells an AI agent how to get a key for API Almanac, connect to it and call it. The full reference is https://apialmanac.com/docs.md, and every operation has its own Markdown page, linked below.

## Start here

- **API Almanac tools are already in your tool list** (`time_now`, `time_convert`, …): use them, and read "Using API Almanac well" below.
- **A task needs API Almanac and you have no tools for it**: get a key, then connect the MCP server or call the HTTP API. Setting that up is part of the task.
- **A question about API Almanac** (what it does, what it costs): answer from this page and the reference. Nothing needs setting up.
- **Code that keeps running after this session** (a server, a scheduled job): call the HTTP API with the key in an environment variable such as `ALMANAC_API_KEY`.

## Get a key

**No key yet?** If your user has not given you one, API Almanac gives agents a free trial key: `curl -X POST https://apialmanac.com/trial` returns a key good for 100 requests over 7 days, where to call, and a `claim_url`. No account, email or card is involved, and a trial key never charges anyone. The only thing kept about the caller is a hash of its IP address, for the limit of 3 trial keys per address a day. Use it for the task, then give the `claim_url` to your user: they confirm an email and the same key moves to the Free plan (2,500 requests/mo), so nothing you built has to change. Mint one only when you need it (3 trial keys per address per day).

A key that outlasts a trial belongs to a person. Ask your user for theirs, or for the email address to issue one to; never invent one, and never paste it anywhere public.

Keys are issued at https://apialmanac.com/: enter an email and a free key is shown at once and emailed.

Plans:

- **Free**: free, no card, 2,500 requests a month, then HTTP 429 until the period resets.

An agent connected to APIDirectory's MCP server (`https://apidirectory.com/mcp`) can call `subscribe_api` with slug `almanac` and your user's email instead: a free plan returns the key at once, a paid one returns a checkout link for your user to open.

## Connect over MCP

The server is `https://mcp.apialmanac.com/`, streamable HTTP, JSON in and out. Listing its tools needs no key; calling one does. Send the key as `Authorization: Bearer <key>` (or `X-API-Key`).

Your MCP client's own documentation decides the exact configuration; a setup command is the surest path. Claude Code:

```bash
claude mcp add --transport http almanac https://mcp.apialmanac.com/ --header "Authorization: Bearer <key>"
```

Most JSON configurations:

```json
{
  "mcpServers": {
    "almanac": {
      "type": "http",
      "url": "https://mcp.apialmanac.com/",
      "headers": {
        "Authorization": "Bearer <key>"
      }
    }
  }
}
```

A client that takes a URL and nothing else (a claude.ai connector) can use `https://mcp.apialmanac.com/k/<key>` with the key in place of `<key>`. That URL is as secret as the key.

Every tool result is JSON: `status`, `body`, and `gateway.remaining` / `gateway.reset`, what is left of the plan this period and when it refills.

## Call over HTTP

Base URL `https://api.apialmanac.com/`. Send the key in `X-API-Key` (or `Authorization: Bearer`).

```bash
curl -H "X-API-Key: $ALMANAC_API_KEY" "https://api.apialmanac.com/v1/time/now"
```

Every response carries `X-Gw-Remaining` and `X-Gw-Reset`.

## Limits and errors

- `401`: the key is missing, revoked, or for another API.
- `429`: the plan's allowance or rate limit is used up. Stop and tell your user rather than retrying; the body says whether to wait for the reset or upgrade.
- `400`: A parameter is missing, malformed or out of range

## Using API Almanac well

Every operation is a read-only lookup or calculation with no side effects. Call one instead of computing or recalling the answer whenever it depends on today's date, a time zone, a holiday calendar, a check digit or a reference table.

**Which operation for what**

- The time somewhere, or "what is 9am New York in Tokyo": `time_now`, `time_convert`. Zones are IANA names (`America/New_York`), never abbreviations like EST.
- Deadlines and durations: `date_add` with `business=true` and a `country` for "5 working days from today"; `date_diff` for the days or business days between two dates. Without `country` only weekends are skipped.
- A date written in words ("next Tuesday at 3pm", "in 3 weeks"): `date_parse`, with `tz` and, for anything relative, `ref`.
- Public holidays: `holidays_list` (a `country` code, optionally a `subdivision` such as `TX` or `BY`); `holidays_countries` lists what is covered.
- Whether an exchange is open: `market_status` for NYSE, NASDAQ, LSE, B3, and ECB for TARGET2 settlement days. Regular sessions only.
- Sunrise, sunset, day length and the moon: `sun_times`, `moon_phase`. Pass `tz` to get local times as well as UTC.
- Units and money: `units_convert`; `fx_convert` or `fx_rates` for currencies.
- Before trusting an identifier a user typed: `validate_iban`, `validate_card`, `validate_phone`, `validate_email`, and `validate_identifier` for ISBN, EAN/UPC/GTIN, ISSN, ISIN, CUSIP, SEDOL, VIN, IMEI, ABA routing, NPI and VAT numbers.
- Countries, currencies, languages: `country_get` (with World Bank population, GDP and inflation, each with its year), `currency_get`, `language_get`, `country_timezones`; how a locale writes numbers, dates and money: `locale_facts`.
- Places: `cities_search` (cities of 15,000+ people, with their time zone and local time), `cities_nearest` for a coarse reverse geocode, `airports_search`, `us_zip_lookup`, `geo_distance`.
- Developer chores: `cron_explain`, `semver_check`, `dns_lookup`, `parse_user_agent`, `hash_text`, `uuid_generate`, `color_convert` (WCAG contrast too).

**Gotchas**

- Dates are `YYYY-MM-DD`; instants are ISO-8601 with `Z` or an offset. A wall time without one, such as `2026-03-08T09:00`, is read in the `from` zone of `time_convert`.
- Holiday data covers 2020 to 2030. Business-day counts include both ends when they are working days, like Excel's NETWORKDAYS.
- Exchange rates are the ECB's daily reference rates for about 30 currencies, published once per working day: right for estimates and invoices, wrong for trading. Quote the `date` that comes back with them.
- Country parameters take ISO 3166-1 alpha-2 codes (`US`, `DE`); `country_get` also accepts alpha-3, numeric codes and English names.
- Results are facts. Quote them, with their date or source field when there is one, rather than rounding or re-deriving them.

## Operations

### Time

- `time_now` `GET /v1/time/now`: The current time in a time zone, with offset, DST flag and ISO week ([details](https://apialmanac.com/docs/get-v1-time-now.md))
- `time_convert` `GET /v1/time/convert`: Convert a time from one zone to another ([details](https://apialmanac.com/docs/get-v1-time-convert.md))
- `time_zones` `GET /v1/time/zones`: Every IANA time zone with its current UTC offset and abbreviation ([details](https://apialmanac.com/docs/get-v1-time-zones.md))
- `country_timezones` `GET /v1/countries/{code}/timezones`: The IANA time zones a country uses, with current offsets ([details](https://apialmanac.com/docs/get-v1-countries-code-timezones.md))

### Dates

- `date_diff` `GET /v1/date/diff`: Days, weeks, months and business days between two dates ([details](https://apialmanac.com/docs/get-v1-date-diff.md))
- `date_add` `GET /v1/date/add`: Add calendar or business days to a date ([details](https://apialmanac.com/docs/get-v1-date-add.md))
- `date_parse` `GET /v1/date/parse`: Turn natural language like "next Tuesday at 3pm" or "in 3 weeks" into ISO dates ([details](https://apialmanac.com/docs/get-v1-date-parse.md))
- `calendar_convert` `GET /v1/date/calendar`: Convert a date to or from another calendar: Hebrew, Islamic, Persian, Chinese, Japanese eras, Julian and more ([details](https://apialmanac.com/docs/get-v1-date-calendar.md))
- `easter_dates` `GET /v1/date/easter`: Easter and the moveable feasts for a year, Western or Orthodox ([details](https://apialmanac.com/docs/get-v1-date-easter.md))
- `holidays_list` `GET /v1/holidays`: Public holidays for a country and year, optionally for one state or region ([details](https://apialmanac.com/docs/get-v1-holidays.md))
- `holidays_countries` `GET /v1/holidays/countries`: Countries with holiday data, and their subdivisions ([details](https://apialmanac.com/docs/get-v1-holidays-countries.md))
- `cron_explain` `GET /v1/cron`: Validate a cron expression, say it in English and list its next runs in a time zone ([details](https://apialmanac.com/docs/get-v1-cron.md))

### Astronomy

- `sun_times` `GET /v1/sun`: Sunrise, sunset, solar noon, twilights and day length for a place and date ([details](https://apialmanac.com/docs/get-v1-sun.md))
- `moon_phase` `GET /v1/moon`: Moon phase, illumination and the next new and full moons ([details](https://apialmanac.com/docs/get-v1-moon.md))

### Units

- `units_list` `GET /v1/units`: Every unit the converter knows, grouped by category ([details](https://apialmanac.com/docs/get-v1-units.md))
- `units_convert` `GET /v1/units/convert`: Convert a value between two units of the same kind ([details](https://apialmanac.com/docs/get-v1-units-convert.md))

### Validation

- `validate_iban` `GET /v1/validate/iban`: Check an IBAN: country, length and mod-97 check digits ([details](https://apialmanac.com/docs/get-v1-validate-iban.md))
- `validate_email` `GET /v1/validate/email`: Check an email address: syntax, normalised form, disposable and role-based flags, optional MX lookup ([details](https://apialmanac.com/docs/get-v1-validate-email.md))
- `validate_phone` `GET /v1/validate/phone`: Parse and validate a phone number: E.164, national format, type and region ([details](https://apialmanac.com/docs/get-v1-validate-phone.md))
- `validate_card` `GET /v1/validate/card`: Check a payment card number: Luhn checksum, brand and length (nothing is stored) ([details](https://apialmanac.com/docs/get-v1-validate-card.md))
- `validate_identifier` `GET /v1/validate/id`: Check an identifier's check digit and format: ISBN, EAN/UPC/GTIN, ISSN, ISIN, CUSIP, SEDOL, VIN, IMEI, ABA routing, NPI, VAT number, Luhn ([details](https://apialmanac.com/docs/get-v1-validate-id.md))

### Network

- `dns_lookup` `GET /v1/dns`: Resolve a DNS record (A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SRV) via DNS over HTTPS ([details](https://apialmanac.com/docs/get-v1-dns.md))
- `parse_user_agent` `GET /v1/useragent`: Parse a browser User-Agent string into browser, engine, OS and device ([details](https://apialmanac.com/docs/get-v1-useragent.md))

### Text

- `hash_text` `GET /v1/hash`: MD5, SHA-1, SHA-256, SHA-384 or SHA-512 of a string ([details](https://apialmanac.com/docs/get-v1-hash.md))
- `uuid_generate` `GET /v1/uuid`: Generate UUIDs (v4 random or v7 time-ordered) ([details](https://apialmanac.com/docs/get-v1-uuid.md))
- `number_to_words` `GET /v1/numbers/words`: Spell an integer in English words, cardinal or ordinal ([details](https://apialmanac.com/docs/get-v1-numbers-words.md))
- `roman_numerals` `GET /v1/numbers/roman`: Convert between integers (1–3999) and Roman numerals ([details](https://apialmanac.com/docs/get-v1-numbers-roman.md))
- `semver_check` `GET /v1/semver`: Parse and sort semantic versions, compare two, and test them against an npm-style range ([details](https://apialmanac.com/docs/get-v1-semver.md))
- `color_convert` `GET /v1/color`: Parse a color (hex, rgb(), hsl(), CSS name), convert it, name it, and check WCAG contrast against another ([details](https://apialmanac.com/docs/get-v1-color.md))

### Reference

- `countries_list` `GET /v1/countries`: All countries and territories (ISO 3166) with capital, region, currencies, dial codes and flag ([details](https://apialmanac.com/docs/get-v1-countries.md))
- `country_get` `GET /v1/countries/{code}`: One country by ISO alpha-2, alpha-3, numeric code or exact name, with World Bank population, GDP, inflation and life expectancy ([details](https://apialmanac.com/docs/get-v1-countries-code.md))
- `currencies_list` `GET /v1/currencies`: ISO 4217 currencies in circulation with minor units, symbols and where they are used ([details](https://apialmanac.com/docs/get-v1-currencies.md))
- `currency_get` `GET /v1/currencies/{code}`: One currency by ISO 4217 code ([details](https://apialmanac.com/docs/get-v1-currencies-code.md))
- `languages_list` `GET /v1/languages`: ISO 639 languages with two- and three-letter codes ([details](https://apialmanac.com/docs/get-v1-languages.md))
- `language_get` `GET /v1/languages/{code}`: One language by ISO 639-1 (fr) or 639-2 (fra / fre) code ([details](https://apialmanac.com/docs/get-v1-languages-code.md))
- `naics_search` `GET /v1/naics`: Search NAICS 2022 industry codes by title, or list a level (2 = sectors … 6 = national industries) ([details](https://apialmanac.com/docs/get-v1-naics.md))
- `naics_get` `GET /v1/naics/{code}`: One NAICS code with its parents up to the sector and its direct children ([details](https://apialmanac.com/docs/get-v1-naics-code.md))
- `locale_facts` `GET /v1/locale`: How a locale writes things: first day of week, weekend, 12/24-hour clock, number and currency formats, date patterns, text direction ([details](https://apialmanac.com/docs/get-v1-locale.md))

### Places

- `airports_search` `GET /v1/airports`: Find airports by IATA or ICAO code, country, or a word in the name or city ([details](https://apialmanac.com/docs/get-v1-airports.md))
- `airport_get` `GET /v1/airports/{code}`: One airport by IATA (3 letters) or ICAO (4 letters) code ([details](https://apialmanac.com/docs/get-v1-airports-code.md))
- `us_zip_lookup` `GET /v1/postal/us/{zip}`: City, state, county and coordinates for a US ZIP code ([details](https://apialmanac.com/docs/get-v1-postal-us-zip.md))
- `cities_search` `GET /v1/cities`: Find cities by name: coordinates, population, time zone and the local time there now ([details](https://apialmanac.com/docs/get-v1-cities.md))
- `city_get` `GET /v1/cities/{id}`: One city by its GeoNames id ([details](https://apialmanac.com/docs/get-v1-cities-id.md))
- `cities_nearest` `GET /v1/cities/nearest`: Nearest cities to a coordinate, with distance and time zone (a coarse reverse geocode) ([details](https://apialmanac.com/docs/get-v1-cities-nearest.md))
- `geo_distance` `GET /v1/geo/distance`: Great-circle distance, bearings, midpoint and bounding box between two coordinates ([details](https://apialmanac.com/docs/get-v1-geo-distance.md))

### Finance

- `fx_rates` `GET /v1/fx`: Daily exchange rates for ~30 currencies (ECB reference rates), rebased to any of them ([details](https://apialmanac.com/docs/get-v1-fx.md))
- `fx_convert` `GET /v1/fx/convert`: Convert an amount between two currencies at the latest ECB reference rate ([details](https://apialmanac.com/docs/get-v1-fx-convert.md))
- `market_status` `GET /v1/markets`: Is a market open right now? Session, next open and close, holidays and early closes (NYSE, NASDAQ, LSE, ECB, B3) ([details](https://apialmanac.com/docs/get-v1-markets.md))
- `loan_amortization` `GET /v1/loan`: Monthly payment, total interest, yearly summary and optional full schedule for a loan or mortgage ([details](https://apialmanac.com/docs/get-v1-loan.md))

## Install as a skill

The `almanac` skill teaches an agent when and how to call API Almanac:

```bash
npx skills add https://apialmanac.com/
```

Its index is https://apialmanac.com/.well-known/agent-skills/index.json.

## More

- Reference, try-it console and keys: https://apialmanac.com/docs
- The whole reference as Markdown: https://apialmanac.com/docs.md
- OpenAPI document, no key needed: https://apialmanac.com/openapi.json
- Status: https://apialmanac.com/status
- Listing: https://apidirectory.com/api/almanac
