---
title: "Quickstart — Narwhal API"
description: "Start with Economics, FX, Commodities, Yield curves, Prediction markets, Calendars, Markets, and Ownership. Authenticate with a Bearer key and read API responses."
url: "https://narwhalapi.com/docs/quickstart"
---

# Make your first Narwhal API request

Get an API key, make your first request and read the response. One key works for every Narwhal API.

This guide starts with CPI, then links to references for live APIs at `api.narwhalapi.com`.

**Economics coverage**

**46 Countries**: `ARG, AUS, AUT, BEL, BRA, CAN, CHE, CHL, CHN, COL, CZE, DEU, DNK, ESP, EST, FIN, FRA, GBR, HRV, IDN, IND, IRL, ISR, ITA, JPN, KOR, LTU, LUX, LVA, MEX, MYS, NLD, NOR, NZL, PAK, PHL, POL, PRT, QAT, SAU, SGP, SVN, SWE, THA, USA, ZAF`. Coverage varies by operation and country. Each operation lists its supported countries. 215 countries in total. Countries without a national, OECD, Eurostat or BIS series have annual history from the World Bank on the history routes. Each operation page lists its countries. Every data request needs a Bearer key.

**Free credit:** $10 free every month, with no card. Calls cost from $2 to $10 per 1,000, depending on the API. The limit is 50 requests a minute on free credit and 500 once you add paid credit. REST and MCP use the same credit.

## Set up your API key

Send the key as a Bearer token in the `Authorization` header—never in the URL. [Create an account to get a free key](https://narwhalapi.com/signup), then read the [authentication guide](https://narwhalapi.com/docs/authentication.md) before storing it.

An AI agent can sign up for its user instead: [Agent sign-up](https://narwhalapi.com/docs/agent-signup.md)

Terminal

```
export NARWHAL_API_KEY="nw_live_..."
```

## Request official CPI

Pass the ISO three-letter country code in the path. Omitting `period` returns the latest accepted complete release.

Request

```
curl --request GET \
  --url https://api.narwhalapi.com/v1/economics/USA/cpi \
  --header "Authorization: Bearer $NARWHAL_API_KEY"
```

Example response

```
{
  "country": "USA",
  "period": "2026-07",
  "value": "333.918",
  "index_base": "1982-84=100",
  "released_on": "2026-08-12"
}
```

## Python and JavaScript examples

Use the same environment variable and endpoint in your application. These examples use built-in libraries.

Python 3

```
import json
import os
from urllib.request import Request, urlopen

request = Request(
    "https://api.narwhalapi.com/v1/economics/USA/cpi",
    headers={"Authorization": "Bearer " + os.environ["NARWHAL_API_KEY"]},
)
with urlopen(request, timeout=30) as response:
    data = json.load(response)
print(data)
```

JavaScript · Node.js 18+

```
const key = process.env.NARWHAL_API_KEY;
if (!key) throw new Error("Set NARWHAL_API_KEY first");
const response = await fetch(
  "https://api.narwhalapi.com/v1/economics/USA/cpi",
  { headers: { Authorization: "Bearer " + key }, signal: AbortSignal.timeout(30000) }
);
const data = await response.json();
if (!response.ok) throw new Error(JSON.stringify(data));
console.log(data);
```

## Choose your API

| API | Start with |
| --- | --- |
| [Economics API](https://narwhalapi.com/docs/api/economics.md) | CPI, inflation, labour, GDP, and trade data from official publishers. Coverage varies by country and indicator. |
| [FX API](https://narwhalapi.com/docs/api/fx.md) | Current rates, conversion, and paginated history with a timestamp for every rate. |
| [Public holidays API](https://narwhalapi.com/docs/api/calendars.md) | Published public holidays with national, regional, and observed-day scope. |
| [Palm oil API](https://narwhalapi.com/docs/api/commodities.md) | CPO and FFB prices from Indonesia and Malaysia, with native units and history. |

## Choose a country and indicator

Latest-release and matching history operations are available, with indicator coverage varying by country. The [Economics API reference](https://narwhalapi.com/docs/api/economics.md) lists every path and response shape.

| Indicator | Path suffix |
| --- | --- |
| CPI | `/cpi` |
| Inflation | `/inflation` |
| Unemployment | `/unemployment` |
| Labour-force participation | `/labour-force-participation` |
| GDP and growth | `/gdp` · `/gdp-growth` |
| Trade | `/trade` |

## Connect through MCP

Use the same key and schemas with an MCP client. Tool discovery lists the operations available to your account across all four APIs. See the [MCP guide](https://narwhalapi.com/docs/mcp.md).

Client-neutral field map

```
{
  "url": "https://api.narwhalapi.com/mcp",
  "headers": {
    "Authorization": "Bearer YOUR_NARWHAL_API_KEY"
  }
}
```

Replace the placeholder through your MCP client's secure secret setting. Plain JSON does not expand environment variables by itself.

First tools/call

```
{
  "method": "tools/call",
  "params": {
    "name": "fx_get_rates",
    "arguments": { "base": "USD", "currencies": ["EUR", "JPY"] }
  }
}
```

Initialization and `tools/list` cost nothing. Each successful `tools/call` costs one call at the price of its API.

## Read the response

Read each operation’s response schema before integrating.

| Rule | What it means |
| --- | --- |
| `period` | The exact month, quarter, or year returned by the official release. |
| `released_on` | The official publication date. |
| Decimal strings | Values avoid binary floating-point surprises. |
| Missing data | Incomplete or unavailable releases fail closed; missing never becomes zero. |

Read [how Narwhal stores and updates official releases](https://narwhalapi.com/docs/freshness.md).

### Credit headers on charged responses

`X-Request-ID` `X-Narwhal-Cost` `X-Narwhal-Balance` `X-RateLimit-Limit` `X-RateLimit-Remaining` `X-RateLimit-Reset`

`X-RateLimit-Limit` is the size of your request bucket (the burst), not a count of requests per minute. The bucket refills at your per-minute rate, `X-RateLimit-Remaining` is what is left in it, and `X-RateLimit-Reset` is when it is full again, in UTC.

## Handle errors by status and code

Check the HTTP status first, then use `code` in application logic. `detail` is for logs and debugging. The [errors and credits guide](https://narwhalapi.com/docs/errors.md) lists every public status.

RFC 9457 problem response

```
{
  "type": "https://narwhalapi.com/problems/invalid-query",
  "title": "Invalid query",
  "status": 400,
  "detail": "The request parameters are not valid for this operation.",
  "code": "invalid_query",
  "request_id": "019d1af4-8f33-7b21-91af-ef535f2dcf50"
}
```

Need help with a key? Contact Narwhal API.

See what's new in the [changelog.](https://narwhalapi.com/changelog.md)

LLM? [Read llms.txt.](https://narwhalapi.com/llms.txt)

Was this page helpful?
