Overview
This endpoint demonstrates advanced data transformation capabilities by aggregating cryptocurrency market data and global statistics, while using flatmap filters to clean and reshape the response. HTTP Method:GETEndpoint:
/cryptos/{currency}
Parameters
The fiat currency to display prices in (e.g., “usd”, “eur”, “gbp”)
What It Demonstrates
- Aggregation with Collections: Combines cryptocurrency data with global market statistics
- Advanced Transformation: Uses flatmap filters to move and delete fields
- Safe JSON Encoding: Handles potentially unsafe JSON responses
- Field Filtering: Selects specific nested fields from global data
- Data Grouping: Organizes global statistics under
marketkey
Request Example
Expected Response
Backend Services Called
1. CoinGecko Market Data
- Host:
https://api.coingecko.com - URL Pattern:
/api/v3/coins/markets?vs_currency={currency}&ids=bitcoin%2Cethereum&order=market_cap_desc&per_page=100&page=1&sparkline=false - Purpose: Fetches current market data for Bitcoin and Ethereum
- Encoding:
safejson
2. CoinGecko Global Data
- Host:
https://api.coingecko.com - URL Pattern:
/api/v3/global - Purpose: Fetches global cryptocurrency market statistics
- Target:
data(extracts data from the nested response) - Group:
market
KrakenD Configuration
Key Configuration Options
encoding: "safejson"
Handles potentially unsafe JSON responses from the CoinGecko API, preventing issues with special characters or malformed data.
flatmap_filter
Advanced transformation operations applied to the backend response:
Move Operation:
coins field in the response.
Delete Operation:
target
Extracts a specific field from the backend response. The global endpoint returns {data: {...}}, so target: "data" extracts the inner object.
allow with Nested Fields
Filters nested fields using dot notation (e.g., total_market_cap.btc), allowing precise control over complex response structures.
Use Cases
- Cryptocurrency price tracking applications
- Portfolio management systems
- Market analysis dashboards
- Trading platform integrations
- Financial data aggregation services