Open ferencIOS opened 7 months ago
Based on CoinGecko API documentation.
/coins/markets
endpoint to get the list of top cryptocurrencies sorted by market cap. /coins/{id}
where {id}
is the cryptocurrency ID. /coins/{id}/market_chart
provides historical price data over time. Here’s a pseudo-implementation sketch:
// Fetch top ten cryptocurrencies by market cap
func fetchTopCryptocurrencies() {
let url = URL(string: "https://api.coingecko.com/api/v3/coins/markets?vs_currency=eur&order=market_cap_desc&per_page=10&page=1")
}
// Fetch details for a specific cryptocurrency
func fetchCryptoDetails(id: String) {
let url = URL(string: "https://api.coingecko.com/api/v3/coins/\(id)")
}
// Fetch historical market data for a cryptocurrency
func fetchHistoricalData(id: String, days: Int) {
let url = URL(string: "https://api.coingecko.com/api/v3/coins/\(id)/market_chart?vs_currency=eur&days=\(days)")
}
Explore the CoinGecko API documentation to understand how to fetch the top ten cryptocurrencies by market cap, their details, and historical price data.