Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Exploration #1

Open
ferencIOS opened this issue Mar 18, 2024 · 1 comment
Open

API Exploration #1

ferencIOS opened this issue Mar 18, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@ferencIOS
Copy link
Owner

Explore the CoinGecko API documentation to understand how to fetch the top ten cryptocurrencies by market cap, their details, and historical price data.

@ferencIOS ferencIOS added documentation Improvements or additions to documentation question Further information is requested labels Mar 18, 2024
@ferencIOS
Copy link
Owner Author

Based on CoinGecko API documentation.

  • For fetching the top ten cryptocurrencies by market cap, their details, and historical price data, use the /coins/markets endpoint to get the list of top cryptocurrencies sorted by market cap.
  • For details on a specific cryptocurrency, use /coins/{id} where {id} is the cryptocurrency ID.
  • For historical data, /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)")
}

@ferencIOS ferencIOS reopened this Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant