Merkl Developer Portal logo

Overview

Access detailed position and transaction data using Merkl States Analytics API

The Merkl States Analytics API provides detailed position and transaction data for users across different DeFi protocols. This service is particularly useful for building analytics dashboards, tracking position history, and computing PnL (Profit and Loss) for user positions.

Base URL and Documentation

Base URL: https://analytics.merkl.xyz

All analytics endpoints live under the /v4/analytics path prefix (e.g. https://analytics.merkl.xyz/v4/analytics/positions/...).

Full API Documentation: Analytics Reference

Authentication

Every analytics endpoint requires an API key, the same as for the Merkl API, in the X-API-Key header:

curl 'https://analytics.merkl.xyz/v4/analytics/positions/{userAddress}/{chainId}' \
  --header 'X-API-Key: your-api-key-here'

Use Cases

  • Position Tracking: Monitor user positions across multiple protocols and chains
  • PnL Analytics: Calculate profit and loss using historical position data with includeHistory=true and historyStep=daily
  • Portfolio Visualization: Display user holdings with enriched token amounts using includeDisplay=true
  • Protocol Analytics: Aggregate data by protocol using the protocol filter
  • Transaction Analysis: Look up position state changes by transaction hash