Market Data Price v1 Service
Skip The Details?​
- 👉 Jump to Package Types
- 👉 Jump to Service Methods
Overview​
The PriceService provides market data pricing information for token pairs on the Mesh platform. This service enables retrieval of current market prices to support:
- Trading Decisions: Get real-time prices before executing trades
- Portfolio Valuation: Calculate holdings value in your preferred quote currency
- Price Discovery: Query mid-market prices for any supported token pair
The service provides a single operation:
- GetCurrentPriceByTokenPair: Retrieve the current mid-market price for a specified base/quote token pair
Prices are returned as the mid-market price for a base token denominated in a quote token, along with a timestamp indicating when the price was observed.
Key Concepts​
Token Pairs​
Prices are always quoted as a pair of tokens:
- Base Token: The token being priced (e.g., XAU, USD, STX40)
- Quote Token: The currency in which the price is denominated (e.g., USD, ZAR)
For example, in an XAU/ZAR pair:
- Base token: XAU (Gold)
- Quote token: ZAR (South African Rand)
- A price of 55,000 means 1 troy ounce of gold = 55,000 ZAR
Supported Token Types​
The service supports pricing for several categories of instruments:
| Category | Examples | Quote Currencies |
|---|---|---|
| Cryptocurrencies | BTC, ETH, XLM, USDC, USDT, SOL, DOGE, ADA, DOT | USD, ZAR, other fiat |
| Precious Metals | XAU (Gold), XAG (Silver), XPT (Platinum), XPD (Palladium) | USD, ZAR |
| Fiat Currencies | USD, EUR, GBP, JPY, ZAR, CHF, CAD, AUD, NZD, CNY, INR, BRL | Any supported fiat |
| JSE Equities | STX40, STXRAF, STXWDM, STXEMG, STX500, BRNDZ, TITANS | ZAR |
Certain pair combinations are not supported, such as precious metal to precious metal (e.g., XAU/XAG) or equity to equity (e.g., STX40/STXRAF). If needed, calculate these manually using a common currency.
When both base and quote tokens are the same (e.g., USD/USD), the service returns a price of 1.
Mid-Market Price​
The service returns mid-market prices, which provide a fair reference price that is:
- Neutral between buyers and sellers
- Suitable for portfolio valuation
- A starting point for trade pricing
Cross-Rate Calculation​
For certain token pairs that don't have direct pricing sources, the service automatically calculates cross-rates. For example, to price XAG/ZAR (Silver in Rand), the service:
- Fetches XAG/USD (Silver in US Dollars)
- Fetches USD/ZAR (US Dollar to Rand exchange rate)
- Multiplies the two rates to derive XAG/ZAR
This is handled transparently - you simply request the token pair you need.
Quick Start​
- Configure your client with appropriate API credentials
- Identify your token pair - determine the base token (what you want priced) and quote token (currency to price it in)
- Verify support - ensure your token pair is in a supported category (see table above)
- Call GetCurrentPriceByTokenPair with both tokens specified using their standard codes
Common Workflows​
Get Current Price​
Use GetCurrentPriceByTokenPair to retrieve the current mid-market price for any supported token pair:
- Specify the base token (the asset you want priced)
- Specify the quote token (the currency to price it in)
- Receive the current mid-market price with timestamp
The response includes:
- The echoed base and quote tokens
- The mid-market price as a decimal value
- A timestamp indicating when the price was observed
Forex Conversion​
To convert between fiat currencies:
- Call
GetCurrentPriceByTokenPairwith the source currency as base and target currency as quote - Multiply the amount by the returned price
- Example: Convert 100 USD to ZAR - get USD/ZAR price, multiply by 100
Cryptocurrency Pricing​
To get cryptocurrency prices:
- Call
GetCurrentPriceByTokenPairwith the crypto code (BTC, ETH, XLM, etc.) as base - Use USD, ZAR, or another fiat currency as the quote token
- Crypto-to-crypto pairs (e.g., XLM/USDC) are also supported
Precious Metal Valuation​
To price precious metal holdings:
- Call
GetCurrentPriceByTokenPairwith the metal code (XAU, XAG, XPT, XPD) as base - Use your preferred currency as the quote token (USD or ZAR)
- Multiply by quantity (prices are per troy ounce)
JSE Equity Pricing​
To get prices for JSE-listed instruments:
- Use the instrument ticker as the base token (e.g., STX40, BRNDZ)
- Use ZAR as the quote token (JSE equities are priced in ZAR)
- Prices are returned in Rand (the service handles any underlying cent-to-Rand conversions)
Portfolio Valuation​
To value a portfolio of mixed holdings:
- For each holding, call
GetCurrentPriceByTokenPairwith your holding as base and your reporting currency as quote - Multiply each price by the holding quantity
- Sum for total portfolio value
Authentication & Authorization​
This service implements role-based access control:
Read Operations (GetCurrentPriceByTokenPair)​
- Required Roles:
ROLE_MARKET_DATA_ADMIN,ROLE_MARKET_DATA_VIEWER,ROLE_MARKET_DATA_PRICE_ADMIN, orROLE_MARKET_DATA_PRICE_VIEWER - Method Type:
METHOD_TYPE_READ
The service supports both domain-level roles (ROLE_MARKET_DATA_*) and service-specific roles (ROLE_MARKET_DATA_PRICE_*). Use service-specific roles for fine-grained access control when users should only access price data without broader market data permissions.
All operations are scoped to your authenticated context and require appropriate Market Data domain permissions.
Best Practices​
- Token Code Standards: Use ISO 4217 codes for fiat currencies (USD, EUR, ZAR) and standard commodity codes for precious metals (XAU, XAG, XPT, XPD)
- Error Handling: Unsupported token pairs return an error - verify your pair is in a supported category before calling
- Timestamp Awareness: Always check the returned timestamp to understand price freshness for time-sensitive operations
- Caching Strategy: For high-frequency access, consider caching prices with appropriate TTLs based on your use case requirements