Authentication

Every data endpoint needs an API key. Discovery endpoints are public and need none: /v1/catalog, /v1/search, /v1/status, /v1/calendar (and /v1/calendar.ics), /v1/plans, /v1/commodities/items, /v1/commodities/cities, /v1/agri/markets, /v1/agri/commodities, /v1/trade/products, /v1/trade/countries and /v1/regional/districts.

Sending your key

The preferred way is the X-API-Key header:

curl -H "X-API-Key: pk_live_xxx" \
  "https://api.pakdatahub.com/v1/series/rates.kibor.3m"

For quick tests, pandas read_csv or a spreadsheet import, you can pass it as a query parameter instead:

https://api.pakdatahub.com/v1/series/rates.kibor.3m?api_key=pk_live_xxx

Avoid the query-parameter form in production, because URLs end up in logs and browser history.

Key format and storage

Session tokens (dashboard)

The web dashboard signs you in with email and password or Google, and holds a session token. The account-management endpoints accept either credential:

Endpoint API key Session token (X-Session-Token)
/v1/series, /v1/funds, all data endpoints yes no
/v1/account, /v1/keys, /v1/usage, /v1/webhooks, /v1/billing/portal yes yes

See Auth endpoints for signup, login and logout.

What happens when a key is wrong

{ "success": false, "error": { "code": "unauthorized", "message": "missing API key" } }

A missing or invalid key returns 401 unauthorized. The other auth-related errors are:

See Errors & rate limits.

Rotating a key

  1. Create a new key (POST /v1/keys or the dashboard).
  2. Deploy it.
  3. Revoke the old one (DELETE /v1/keys/{id}).

Revocation takes effect immediately.

·

Also as Markdown: authentication.md · All docs