# API reference

- **Base URL:** `https://api.pakdatahub.com`. Every data endpoint is under `/v1`.
- **Format:** JSON (UTF-8) by default; CSV on `/v1/series/{id}` with `?format=csv`.
- **Auth:** `X-API-Key: pk_live_xxx` header ([Authentication](https://pakdatahub.com/docs/authentication.md)). (key required) marks keyed endpoints; the rest are public.
- **Dates:** ISO `YYYY-MM-DD`. Monthly data is dated to the **last day of the month**, and quarterly data to the quarter end.

## Response envelopes

Series endpoints (`/v1/series`, `/v1/commodities`) return:

```json
{
  "success": true,
  "series": "rates.kibor.3m",
  "meta": { "name": "KIBOR 3-Month", "unit": "percent", "frequency": "daily",
            "source": "SBP", "last_updated": "2026-09-24", "transform": null },
  "data": [ { "date": "2026-09-24", "value": 11.75, "dims": { "side": "offer" } } ],
  "pagination": { "next_cursor": null, "count": 1 }
}
```

List endpoints (funds, securities, auctions, trade, AMCs, search, calendar) return `{ "success": true, "data": [...], "count": N }`.

Errors return `{ "success": false, "error": { "code", "message" } }` ([Errors](https://pakdatahub.com/docs/errors-rate-limits.md)).

## Endpoints

### Discovery (public)
| Endpoint | Page |
|---|---|
| `GET /v1/catalog`, `GET /v1/catalog/{id}` | [Catalog](https://pakdatahub.com/docs/api-catalog.md) |
| `GET /v1/search?q=` | [Search](https://pakdatahub.com/docs/api-search.md) |
| `GET /v1/calendar` | [Release calendar](https://pakdatahub.com/docs/api-calendar.md) |
| `GET /v1/status` | [Status](https://pakdatahub.com/docs/api-status.md) |
| `GET /v1/plans` | [Billing](https://pakdatahub.com/docs/api-billing.md) |

### Time series (key required)
| Endpoint | Page |
|---|---|
| `GET /v1/series/{id}`, `GET /v1/series/{id}/latest` | [Series](https://pakdatahub.com/docs/api-series.md) |
| `?transform=yoy\|mom\|pct_change\|3ma\|index` | [Transforms](https://pakdatahub.com/docs/api-transforms.md) |
| `?vintage=YYYY-MM-DD` | [Revision vintages](https://pakdatahub.com/docs/api-vintages.md) |
| `GET /v1/commodities`, `/by-city`, `/items`, `/cities` | [Commodities](https://pakdatahub.com/docs/api-commodities.md) |

### Datasets (key required)
| Endpoint | Page |
|---|---|
| `GET /v1/funds`, `/screener`, `/{id}`, `/{id}/nav\|returns\|payouts\|expenses\|portfolio` | [Mutual funds](https://pakdatahub.com/docs/api-funds.md) |
| `GET /v1/funds/{id}/analytics` | [Fund analytics](https://pakdatahub.com/docs/api-fund-analytics.md) |
| `GET /v1/amcs`, `GET /v1/amcs/{amc}` | [AMCs](https://pakdatahub.com/docs/api-amcs.md) |
| `GET /v1/securities`, `/{code}/prices`, `/trades` | [Debt securities](https://pakdatahub.com/docs/api-securities.md) |
| `GET /v1/fixed-income/auctions` | [Auctions](https://pakdatahub.com/docs/api-auctions.md) |
| `GET /v1/trade` | [External trade](https://pakdatahub.com/docs/api-trade.md) |

### Account (key required) / session
| Endpoint | Page |
|---|---|
| `GET /v1/usage`, `/v1/usage/history` | [Usage](https://pakdatahub.com/docs/api-usage.md) |
| `GET/PATCH /v1/account`, `GET/POST/DELETE /v1/keys` | [Account & keys](https://pakdatahub.com/docs/api-account-keys.md) |
| `GET/POST/DELETE /v1/webhooks` | [Webhooks](https://pakdatahub.com/docs/api-webhooks.md) |
| `POST /auth/signup\|login\|logout\|change-password\|set-password`, Google | [Auth](https://pakdatahub.com/docs/api-auth.md) |
| `POST /v1/checkout`, `GET /v1/billing/portal`, `GET /v1/account/key/{token}` | [Billing](https://pakdatahub.com/docs/api-billing.md) |

## Quick examples

```bash
# public: discover
curl "https://api.pakdatahub.com/v1/search?q=remittances"
# keyed: data
curl -H "X-API-Key: pk_live_xxx" "https://api.pakdatahub.com/v1/series/remittances.total?from=2024-01-01&sort=asc"
```

```python
import httpx
r = httpx.get("https://api.pakdatahub.com/v1/series/fx.rate.avg.usd",
              params={"from": "1947-01-01", "sort": "asc"},
              headers={"X-API-Key": "pk_live_xxx"}, timeout=30)
print(r.json()["data"][-1])
```

```js
const res = await fetch("https://api.pakdatahub.com/v1/series/rates.kibor.3m/latest?dims=side:offer",
  { headers: { "X-API-Key": "pk_live_xxx" } });
const { meta, data } = await res.json();
console.log(meta.name, data[0].value);
```

What data exists: the [data dictionary](https://pakdatahub.com/docs/data-dictionary.md). Copy-paste recipes for each dataset: [API guides](https://pakdatahub.com/guides).

---
Source: https://pakdatahub.com/docs/api-reference - PakDataHub docs index: https://pakdatahub.com/docs/llms.txt
