Technical Overview
This document lists every REST endpoint exposed by the ZigScan API along with authentication requirements, query parameters, and example payloads. The service is implemented with NestJS/Express and most endpoints proxy ClickHouse or Cosmos SDK data sources.
Base URL & Authentication
Default base URL:
http://localhost:8000API version prefix:
/api/v2Auth for data endpoints: API key header
Authorization: Bearer <api-key>Global throttle: 10 req / 60s per IP (Nest Throttler)
Per-key limit: 100 req / 60s per API key (non-admin)
Admin endpoints require an API key with role
ADMIN.Responses are JSON. Unless otherwise noted, successful calls return HTTP
200 OK; authentication failures return401/403, validation errors400, and upstream failures5xx.
Example:
curl -H "Authorization: Bearer ${ZIGSCAN_API_KEY}" \
http://localhost:8000/api/v2/healthConventions
Pagination parameters use
limitandoffset. Unless a DTO states otherwise,limitdefaults to 50 andoffsetto 0.Date/time fields are returned as ISO 8601 strings.
ClickHouse-backed lists return an object with
dataandtotal_count.
Root Endpoint
GET
/
none
Returns service metadata (name/version).
Example response:
Core Service (/api/v2)
/api/v2)Health & General Stats
GET
/api/v2/health
none
Health check plus ClickHouse status.
GET
/api/v2/stats
API key
Aggregated chain stats (blocks, tx count).
GET /api/v2/health example:
Transactions
GET
/api/v2/transactions/latest
API key
Latest transactions with action type and signer. Supports filtering by action type and date range.
GET
/api/v2/transactions/stats
API key
Aggregate transaction counts (7/15/30 days, TPS, hourly histogram).
GET
/api/v2/transactions/message-types
API key
Lists all message types with transaction counts, ordered by frequency.
GET
/api/v2/transaction/:txHash
API key
Fetches raw transaction data from the chain RPC. Returns 404 if not found.
Query parameters for /transactions/latest:
limit
integer (0–100)
10
Max records.
offset
integer (0–100)
0
Skip records.
action
string
none
Filter by action type (e.g., /cosmos.bank.v1beta1.MsgSend). Supports wildcards (%).
startDate
string (ISO 8601)
none
Start date for filtering (e.g., 2025-10-01T00:00:00).
endDate
string (ISO 8601)
none
End date for filtering (e.g., 2025-10-15T00:00:00).
heightWindow
integer (1–100000)
1000
Number of blocks to look back from the latest height (limits query scope).
beforeHeight
integer (>=1)
none
Height of the last transaction on the previous page; the next call returns entries strictly older than this height within the requested window (useful for paging back).
Example response (latest):
Example response (stats):
Example response (message-types):
GET /api/v2/transaction/:txHash mirrors the Cosmos /cosmos/tx/v1beta1/txs/{txHash} payload (minus tx_response.tx to reduce size).
Blocks
GET
/api/v2/blocks
API key
Paginated block minting snapshots with validator rewards.
GET
/api/v2/blocks/stats
API key
Average/min block times, average tx count, daily block counts.
GET
/api/v2/blocks/details/:height
API key
Full block metadata pulled from the chain RPC.
GET
/api/v2/blocks/transactions/:height
API key
Transactions for a specific block.
Query parameters:
/blocks:limit(1–1000, default 10),offset(default 0)/blocks/stats:days(1–365, default 30)
Example response (/blocks):
Example response (/blocks/stats):
/blocks/details/:height returns the raw Tendermint block (block, block_id, sdk_block) from the ZigChain RPC.
Contracts & Codes
GET
/api/v2/contracts
API key
Contract instantiations with filters.
GET
/api/v2/contract/debug/:contractAddress
API key
Raw instantiate event payloads for debugging.
GET
/api/v2/contract/details/:contractAddress
API key
Fetches on-chain contract metadata.
GET
/api/v2/contract/transactions/:contractAddress
API key
Contract executions involving the address (paginated).
GET
/api/v2/codes
API key
Code storage events with filters.
GET
/api/v2/code/details/:codeId
API key
Code info and associated contracts.
Shared pagination (/contracts, /contract/transactions, /codes): limit (1–1000), offset (0+) default 50/0 via PaginationQueryDto.
Additional filters:
/contracts:contract_address,sender,code_id(strings)height_min,height_max(ints ≥ 1;height_min≤height_max)
/codes:sender,code_idheight_min,height_max
Example response (/contracts):
/contract/debug/:contractAddress returns:
/contract/details/:contractAddress mirrors /cosmwasm/wasm/v1/contract/{address}.
/contract/transactions/:contractAddress returns { data: ContractTransaction[], total_count: number } with the same schema as account transactions.
/code/details/:codeId combines:
Accounts
GET
/api/v2/account/details/:address
API key
Account info plus balances grouped by token type, plus transaction totals and creation metadata.
GET
/api/v2/account/delegations/:address
API key
Active delegations with total count and pagination cursor.
GET
/api/v2/account/transactions/:address
API key
Recent transactions where the address appears as sender/recipient/fee payer.
GET
/api/v2/account/token-metadata
API key
Metadata for native/factory/CW20/IBC tokens (symbol, decimals, icon, etc.).
GET
/api/v2/accounts/total
API key
Total number of accounts (via Cosmos pagination metadata).
Notes:
:addressmust start withzig1; contract (zig1+ > 50 chars) orzigvaloperaddresses are rejected with400.Balances group tokens into
factory,cw20, andIBC. Metadata includessymbol,decimals, andimage_url./account/delegationsreturns{ delegation_responses: DelegationResponse[], pagination: { next_key, total } }; empty delegations yield an empty array with total0./account/transactionsenforces pagination and clampslimitto 1–1000.
Query parameters for /account/transactions/:address:
limit
integer (1–1000)
50
Maximum records per page.
offset
integer (0+)
0
Number of records to skip.
Example (/account/details):
/account/token-metadata accepts a denom query parameter and returns the resolved metadata:
Example request:
Example response:
total_transactionscounts every row inpublic_address_transactionsfor the address.first_block_heightis the earliest height in that table.account_creation_timeis the corresponding block time (all sourced from ClickHouse).
/accounts/total example:
/account/delegations mirrors the Cosmos staking delegation response and always includes a pagination object. /account/transactions returns { data: AccountTransaction[], total_count: number } sorted by height DESC.
Validators
GET
/api/v2/validators
API key
Lists validators (default bonded). Enriches with Keybase avatar.
GET
/api/v2/validator/details/:validatorAddress
API key
Fetch single validator; returns 404 if not found.
Query parameters:
status
string
BOND_STATUS_BONDED
Any Cosmos staking status.
limit
integer (1–1000)
50
offset
integer (0+)
0
Example list response:
Supply & Market Data
GET
/api/v2/supply
API key
On-chain supply plus derived circulating/non-circulating.
GET
/api/v2/zig/market-data
API key
Current price/volume metrics from CoinGecko.
GET
/api/v2/zig/staking-pool
API key
Bonded vs non-bonded staking pool balances.
GET
/api/v2/zig/price-data
API key
Historical price/volume chart data.
/zig/price-data query parameter:
days
string
24hr
Passed directly to CoinGecko (e.g. 7, 30, 90, 1, 7d).
Example (/supply):
Example (/zig/market-data):
/zig/price-data returns CoinGecko chart arrays:
Example (/zig/staking-pool):
TVL
GET
/api/v2/tvl
API key
Latest TVL snapshot plus 30-day history aggregated by entity.
Response example:
Network
GET
/api/v2/network/overview
API key
Chain overview (heights, TPS, staking, validator totals) with caching.
Response mirrors NetworkOverview from NetworkService (heights, tx totals, staking pool, validator counts).
DeFi (Degenter Proxy)
All DeFi endpoints proxy DEGENTER_API responses. Authentication still uses ZigScan API keys.
GET
/api/v2/tokens
API key
Lists Degenter tokens. Supports sorting.
GET
/api/v2/tokens/details/:denom
API key
Token profile, social links, and metrics.
GET
/api/v2/tokens/:denom/pools
API key
Pools for a token.
GET
/api/v2/tokens/:denom/holders
API key
Token holders list.
GET
/api/v2/tokens/:denom/ohlcv
API key
OHLCV candles (default timeframe set by Degenter).
GET
/api/v2/pools/:poolId/trades
API key
Trades for a pool.
Query parameters:
/tokens:limit,offset,sort,dir/tokens/:denom/holders:limit,offset/pools/:poolId/trades:limit(default 50),offset(default 0),unit(usdby default),tf(24hby default)/tokens/:denom/ohlcv: no additional query params; interval configured server-side.
Sample /tokens response:
/tokens/details/:denom returns the Degenter token profile (success, data with metadata, liquidity, price change buckets).
/tokens/:denom/ohlcv response example:
/pools/:poolId/trades response example:
Memes.fun (MDF)
GET
/api/v2/mdf/coins
API key
Paginated Memes.fun coin feed.
Query params: page (default 1, min 1), limit (default 10, max 100). Uses MEMES_FUN_API_BASE_URL + MEMES_FUN_API_KEY.
Response shape mirrors the upstream MemesDotFunCoinsResponse with success, data, and pagination meta.
Saved Items (JWT)
All saved-items routes require a user JWT (Authorization: Bearer <accessToken>).
POST
/api/v2/saved-items
JWT
Save an item (itemSaved, optional itemType).
GET
/api/v2/saved-items
JWT
List saved items with limit, offset, optional itemType.
GET
/api/v2/saved-items/stats
JWT
Totals grouped by itemType.
GET
/api/v2/saved-items/check/:itemSaved
JWT
Returns { itemSaved, isSaved }.
GET
/api/v2/saved-items/:id
JWT
Fetch a saved item by id.
DELETE
/api/v2/saved-items/:id
JWT
Delete a saved item.
DELETE
/api/v2/saved-items
JWT
Delete all saved items for the user.
List response example:
Users & Sessions (JWT)
POST
/api/v2/auth/signup
none
Create user, send verification email.
POST
/api/v2/auth/login
none
Login with identifier (email or username) + password; returns accessToken (24h).
POST
/api/v2/auth/logout
JWT
Invalidate current session token.
POST
/api/v2/auth/logout-all
JWT
Invalidate all sessions for the user.
GET
/api/v2/auth/sessions
JWT
List active sessions (from Redis).
POST
/api/v2/auth/verify-email
none
Verify with token (main flow is email button redirect).
POST
/api/v2/auth/resend-verification
none
Resend verification email.
GET
/api/v2/auth/verify-email-redirect
none
Verifies then redirects to redirect (defaults to dashboard).
POST
/api/v2/auth/forgot-password
none
Sends 6-digit code (rate-limited: 1 request/minute).
POST
/api/v2/auth/reset-password
none
Resets password with 6-digit token (3-minute expiry).
GET
/api/v2/auth/profile
JWT
Current user profile.
DELETE
/api/v2/auth/account
JWT
Delete account after password confirmation.
Tokens are signed with
JWT_SECRET, sessions are stored in Redis (REDIS_HOST/REDIS_PORT).
Admin (/api/v2/admin)
/api/v2/admin)All endpoints are protected by both ApiKeyGuard and AdminGuard, requiring an admin API key.
GET
/api/v2/admin/users
—
Lists masked API keys, roles, request counts, and window status.
GET
/api/v2/admin/system-stats
—
Global auth/rate limit statistics.
POST
/api/v2/admin/execute-query
sql (required)
Executes arbitrary ClickHouse SQL. Returns success, data, count, and executed_by.
GET
/api/v2/admin/audit-log
limit (1–1000, default 100)
Returns recent API key usage snapshots.
Example (POST /admin/execute-query):
Response example:
Metrics
GET
/metrics
Admin API key
Prometheus metrics (HTTP counters/histograms, API key usage, ClickHouse failures, SSH tunnel status).
Content-Type: text/plain; version=0.0.4. Cached by Prometheus scrape interval only.
Error Handling Reference
400 Bad Request– validation failures (e.g., invalid address format,height_min > height_max, non-SELECT query).401 Unauthorized– missing/invalid bearer token.403 Forbidden– admin guard rejection or admin window inactive.404 Not Found– missing on-chain resources (transactions, validators).502/504– upstream APIs (Cosmos, CoinGecko, Degenter) not reachable.
When proxied services return errors, the ZigScan API wraps them as:
with the relevant HTTP status.
Testing & Tooling
Use the included
rest-client.httpor the Postman collection indocs/zigscan-postman.collection.json(seedocs/POSTMAN.md) for manual exploration.For ClickHouse-heavy workflows, prefer scoped
SELECTqueries with explicitLIMITs to minimize response sizes.
Last updated
