Orientação gerada a partir de informações públicas. Apenas para referência.
O pacote coingecko_api oferece uma maneira simples de interagir com a API do CoinGecko (versão 3) em aplicações Dart e Flutter. Permite que desenvolvedores obtenham dados em tempo real sobre criptomoedas, incluindo preços, informações de mercado, taxas de câmbio e muito mais. Projetado para simplicidade e confiabilidade, suporta todas as principais plataformas: Android, iOS, Web, macOS, Windows e Linux. Ideal para aplicativos que exigem insights atualizados sobre o mercado de criptoativos, ele abstrai solicitações HTTP complexas em métodos fáceis de usar. O pacote é mantido no GitHub e se integra perfeitamente por meio do gerenciador de pacotes pub do Flutter.
Casos de uso
Buscando preços ao vivo de criptomoedas
Exibindo tendências de mercado em um painel
Construindo rastreadores de portfólio de cripto
Integrando dados de taxa de câmbio em tempo real
Monitorando o desempenho do token ao longo do tempo
Principais recursos
Interface de API simples e limpa
Suporta todas as principais plataformas
Acesso a dados em tempo real
Cobertura abrangente de endpoints
Integração fácil com o Flutter
Indicado para
Aplicativos de rastreamento de cripto
Ferramentas de análise de blockchain
interfaces de gerenciamento de portfólio
backends de aplicativos Web3
Projetos educacionais sobre criptomoedas
Considerações
Requer conexão com a internet para recuperação de dados
Limites de taxa se aplicam conforme os termos do CoinGecko
Pode ser necessário tratamento de erros para falhas de rede
Dependente da estabilidade da API externa
Não é adequado para aplicativos somente offline
README original
Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.
All methods are asynchronous and use Future, so you need to use await to get the result.
Query results
The result of each method is a special object of type CoinGeckoResult. This is a kind of wrapper that allows you to first find out how successful the request was using its isError property. If isError is false, then we can use the data property of this object to get the processed data itself. Otherwise, we can view the error code and error message using properties errorCode and errorMessage.
Sections
All methods are divided into sections for easier understanding of the purpose of each method. To call any method, we first need to specify a section.
General scheme:
final result = await api./*section name*/./*method name*/(/*parameters*/);
Let's take a closer look at each of the sections and a set of methods in them.
Each section will contain a table indicating the method, a short description of the method and the corresponding query string from the official CoinGecko website.
ping
Method name
Description
Query string
ping
Check API server status.
/ping
simple
Method name
Description
Query string
listPrices
Get the current price of any cryptocurrencies in any other supported currencies that you need.
/simple/price
listTokenPrices
Get current price of tokens (using contract addresses) for a given platform in any other currency that you need.
/simple/token_price/{id}
listSupportedVsCurrencies
Get list of supported vs currencies.
/simple/supported_vs_currencies
coins
Method name
Description
Query string
listCoins
List all supported coins id, name and symbol.
/coins/list
listCoinMarkets
List all supported coins price, market cap, volume, and market related data.
/coins/markets
getCoinData
Get current data (name, price, market, ... including exchange tickers) for a coin.
/coins/{id}
listCoinTickers
Get coin tickers (paginated to 100 items).
/coins/{id}/tickers
getCoinHistory
Get historical data (name, price, market, stats) at a given date for a coin.
/coins/{id}/history
getCoinMarketChart
Get historical market data include price, market cap, and 24h volume (granularity auto).
/coins/{id}/market_chart
getCoinMarketChartRanged
Get historical market data include price, market cap, and 24h volume within a range of timestamp (granularity auto).
/coins/{id}/market_chart/range
listCoinStatusUpdates
Get status updates for a given coin.
/coins/{id}/status_updates
getCoinOHLC
Get coin's OHLC.
/coins/{id}/ohlc
contract
Method name
Description
Query string
getContractTokenData
Get coin info from contract address.
/coins/{id}/contract/{contract_address}
getContractMarketChart
Get historical market data include price, market cap, and 24h volume (granularity auto) from a contract address.
Get exchange volume in BTC and top 100 tickers only.
/exchanges/{id}
getExchangeTickers
Get exchange tickers (paginated, 100 tickers per page).
/exchanges/{id}/tickers
getExchangeVolumeChartData
Get volume_chart data for a given exchange.
/exchanges/{id}/volume_chart
derivatives
Method name
Description
Query string
listDerivatives
List all derivative tickers.
/derivatives
listDerivativeExchanges
List all derivative exchanges.
/derivatives/exchanges
getDerivativeExchange
Show derivative exchange data.
/derivatives/exchanges/{id}
listDerivativeExchangesShort
List all derivative exchanges name and identifier.
/derivatives/exchanges/list
asset_platforms
Method name
Description
Query string
listAssetPlatforms
List all asset platforms (Blockchain networks).
/asset_platforms
exchange_rates
Method name
Description
Query string
getBtcExchangeRates
Get BTC-to-Currency exchange rates.
/exchange_rates
search
Method name
Description
Query string
searchFor
Search for coins, categories and markets listed on CoinGecko ordered by largest Market Cap first.
/search
trending
Method name
Description
Query string
getSearchTrending
Get trending search coins (Top-7) on CoinGecko in the last 24 hours.
/search/trending
global
Method name
Description
Query string
getGlobalData
Get cryptocurrency global data.
/global
getGlobalDefiData
Get cryptocurrency global decentralized finance(defi) data.
/global/decentralized_finance_defi
companies
Method name
Description
Query string
getCompaniesData
Get public companies data.
/companies/public_treasury/{coin_id}
indexes
Method name
Description
Query string
listMarketIndexes
List all market indexes.
/indexes
getMarketIndex
Get market index by market id and index id.
/indexes/{market_id}/{id}
listMarketIndexesShort
List market indexes id and name.
/indexes/list
Full Example
final result = await api.coins.getCoinOHLC(
id: 'bitcoin',
vsCurrency: 'usd',
days: 7,
);
if (!result.isError) {
print('getCoinOHLC method returned result');
result.data.forEach(
(item) => print(
'${item.timestamp}: open = ${item.open}, high = ${item.high}, low = ${item.low}, close = ${item.close}',
),
);
} else {
print('getCoinOHLC method returned error ${result.errorCode}: ${result.errorMessage}');
}
Tests
Each method is covered by a separate test using native dart testing platform dart test.
Roadmap
See the open issues for a list of proposed features and known issues.
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
Fork the project
Create your feature branch (git checkout -b feature/AmazingFeature)
Commit your changes (git commit -m 'Add some AmazingFeature')
Push to the branch (git push origin feature/AmazingFeature)
Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.