1243 lines
41 KiB
Python
1243 lines
41 KiB
Python
|
|
# . documentação API: https://docs.coingecko.com/v3.0.1/reference/introduction
|
|
|
|
import requests
|
|
import json
|
|
|
|
CHAVE_API = 'CG-K5RS5VXsdFDip2UvY3z8VjQP'
|
|
headers = {
|
|
'accept': 'application/json',
|
|
'x-cg-demo-api-key': CHAVE_API
|
|
}
|
|
|
|
url_raiz_API = 'https://api.coingecko.com/api/v3/'
|
|
|
|
# chamada API geral
|
|
def API(api_endpoint: str = '', api_parameters_dict: dict[str, str] = {}) -> tuple[str, int, dict]:
|
|
'''função genérica para fazer uma chamada a API CoinGecko'''
|
|
# validar parametros
|
|
# api_endpoint
|
|
if not isinstance(api_endpoint, str):
|
|
raise TypeError('\'api_endpoint\' tem de ser do tipo \'str\'')
|
|
if api_endpoint == None or api_endpoint == '':
|
|
raise ValueError('\'api_endpoint\' tem de ser definido')
|
|
# api_parameters_dict
|
|
if not isinstance(api_parameters_dict, dict):
|
|
raise TypeError('\'api_parameters_dict\' tem de ser do tipo \'dict\'')
|
|
|
|
# processar argumentos
|
|
api_parameters_string = '' if api_parameters_dict == {} else '?'
|
|
ampersand = '' # primeira iteração é '', depois passa a '&'
|
|
for param in api_parameters_dict:
|
|
if api_parameters_dict[param] == '':
|
|
continue
|
|
api_parameters_string += ampersand + param + '=' + api_parameters_dict[param]
|
|
if ampersand == '':
|
|
ampersand = '&'
|
|
url_pedido = url_raiz_API + api_endpoint + api_parameters_string
|
|
resposta = requests.get(url_pedido, headers=headers)
|
|
return url_pedido, resposta.status_code, resposta.json()
|
|
|
|
|
|
def ping() -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/ping-server
|
|
|
|
função para verificar o estado do servidor API CoinGecko'''
|
|
return API('ping',{})
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = ping()
|
|
# print(f'codigo: {codigo}')
|
|
# print(f'resposta: {dados}')
|
|
|
|
|
|
def coin_price_by_ids(
|
|
ids: str = '',
|
|
vs_currencies: str = '',
|
|
include_market_cap: bool = False,
|
|
include_24hr_vol: bool = False,
|
|
include_24hr_change: bool = False,
|
|
include_last_updated_at: bool = False,
|
|
precision: int | str = ''
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/simple-price
|
|
|
|
consultar preço de um ou mais moedas usando o seu ID de Moeda
|
|
|
|
podem ser passadas multiplas IDs de moedas separadas por virgula, como objecto de tipo 'str'
|
|
|
|
parametros:
|
|
ids (obrigatorio)
|
|
|
|
vs_currencies (obrigatorio)'''
|
|
# dicionario de parametros
|
|
api_parameters= {
|
|
'ids': '',
|
|
'vs_currencies': '',
|
|
'include_24hr_vol': '',
|
|
'include_24hr_change': '',
|
|
'include_last_update_at': '',
|
|
'precision': '',
|
|
}
|
|
# validacao de parametros
|
|
# ids
|
|
if not isinstance(ids, str):
|
|
raise TypeError('\'ids\' não é do tipo \'str\'')
|
|
if ids == '':
|
|
raise ValueError('\'ids\' tem de ser definido')
|
|
api_parameters['ids'] = ids
|
|
# vs_currencies
|
|
if not isinstance(vs_currencies, str):
|
|
raise TypeError('\'vs_currencies\' não é do tipo \'str\'')
|
|
if vs_currencies == '':
|
|
raise ValueError('\'vs_currencies\' tem de ser definido')
|
|
api_parameters['vs_currencies'] = vs_currencies
|
|
# include_market_cap
|
|
if not isinstance(include_market_cap, bool):
|
|
include_market_cap = False
|
|
if include_market_cap:
|
|
api_parameters['include_market_cap'] = str(True).lower()
|
|
# include_24hr_vol
|
|
if not isinstance(include_24hr_vol, bool):
|
|
include_24hr_vol = False
|
|
if include_24hr_vol:
|
|
api_parameters['include_24hr_vol'] = str(True).lower()
|
|
# include_24hr_change
|
|
if not isinstance(include_24hr_change, bool):
|
|
include_24hr_change = False
|
|
if include_24hr_change:
|
|
api_parameters['include_24hr_change'] = str(True).lower()
|
|
# include_last_update_at
|
|
if not isinstance(include_last_updated_at, bool):
|
|
include_last_updated_at = False
|
|
if include_last_updated_at:
|
|
api_parameters['include_last_updated_at'] = str(True).lower()
|
|
# precision
|
|
if (not isinstance(precision, (int, str))):
|
|
raise TypeError('\'precision\' não é do tipo \'int\' ou \'str\'')
|
|
if precision != '':
|
|
if isinstance(precision, str):
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
precision = str(precision)
|
|
api_parameters['precision'] = precision
|
|
|
|
return API('simple/price', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados_dict = coin_price_by_ids('bitcoin,xkc,ethereum','eur', precision=True)
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for moeda in dados_dict:
|
|
# print(f'{moeda}')
|
|
# for vs_currencies in dados_dict[moeda]:
|
|
# print(f'\t{vs_currencies}: {dados_dict[moeda][vs_currencies]}')
|
|
# else:
|
|
# print(f'erro: {codigo}{dados_dict}')
|
|
|
|
|
|
def coin_price_by_token_addresses(
|
|
id_platform: str = '',
|
|
contract_addresses: str = '',
|
|
vs_currencies: str = '',
|
|
include_market_cap: bool = False,
|
|
include_24hr_vol: bool = False,
|
|
include_24hr_change: bool = False,
|
|
include_last_updated_at: bool = False,
|
|
precision: int | str = ''
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/simple-token-price
|
|
|
|
consultar preco de tokens usando os endereços de contrato dos tokens
|
|
|
|
parametros:
|
|
id (obrigatorio) - id da plataforma onde residem os contratos
|
|
|
|
contract_addresses (obrigatorio) - endereços dos contratos, separados por virgula se forem mais que 1
|
|
|
|
vs_currencies (obrigatorio) - moedas de referencia, separadas por virgula se forem mais que 1'''
|
|
# dicionario de parametros
|
|
api_parameters= {
|
|
'id_platform': '',
|
|
'contract_addresses': '',
|
|
'vs_currencies': '',
|
|
'include_market_cap': '',
|
|
'include_24hr_vol': '',
|
|
'include_24hr_change': '',
|
|
'include_last_updated_at': '',
|
|
'precision': '',
|
|
}
|
|
# validacao de parametros
|
|
# id_platform ('id' já existe como metodo, não pode ser usado)
|
|
if not isinstance(id_platform, str):
|
|
raise TypeError('\'id_platform\' tem de ser do tipo \'str\'')
|
|
if id_platform == '':
|
|
raise ValueError('\'id_platform\' tem de ser definido')
|
|
api_parameters['id'] = id_platform
|
|
# contract_addresses
|
|
if not isinstance(contract_addresses, str):
|
|
raise TypeError('\'contract_addresses\' tem de ser do tipo \'str\'')
|
|
if contract_addresses == '':
|
|
raise ValueError('\'contract_addresses\' tem de ser definido')
|
|
api_parameters['contract_addresses'] = contract_addresses
|
|
# vs_currencies
|
|
if not isinstance(vs_currencies, str):
|
|
raise TypeError('\'vs_currencies\' tem de ser do tipo \'str\'')
|
|
if vs_currencies == '':
|
|
raise ValueError('\'vs_currencies\' tem de ser definido')
|
|
api_parameters['vs_currencies'] = vs_currencies
|
|
# include_market_cap
|
|
if not isinstance(include_market_cap, bool):
|
|
include_market_cap = False
|
|
if include_market_cap != False:
|
|
api_parameters['include_market_cap'] = str(include_market_cap).lower()
|
|
# include_24hr_vol
|
|
if not isinstance(include_24hr_vol, bool):
|
|
include_24hr_vol = False
|
|
if include_24hr_vol != False:
|
|
api_parameters['include_24hr_vol'] = str(include_24hr_vol).lower()
|
|
# include_24hr_change
|
|
if not isinstance(include_24hr_change, bool):
|
|
include_24hr_change = False
|
|
if include_24hr_change != False:
|
|
api_parameters['include_24hr_change'] = str(include_24hr_change).lower()
|
|
# include_last_updated_at
|
|
if not isinstance(include_last_updated_at, bool):
|
|
include_last_updated_at = False
|
|
if include_last_updated_at != False:
|
|
api_parameters['include_last_updated_at'] = str(include_last_updated_at).lower()
|
|
# precision
|
|
if (not isinstance(precision, (int, str))):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'int\' ou \'str\'')
|
|
if isinstance(precision, str):
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
precision = str(precision)
|
|
api_parameters['precision'] = precision
|
|
|
|
return API(f'simple/token_price/{api_parameters['id']}',api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# id_plataforma = 'ethereum'
|
|
# enderecos_contracto = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0x4594cffbfc09bc5e7ecf1c2e1c1e24f0f7d29036'
|
|
# url, codigo, dados = coin_price_by_token_addresses(id_plataforma, enderecos_contracto, 'eur')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for contrato in dados:
|
|
# print(f'{contrato}')
|
|
# for vs_currency in dados[contrato]:
|
|
# print(f'\t{vs_currency}: {dados[contrato][vs_currency]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def supported_currencies_list() -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/simple-supported-currencies
|
|
|
|
este endpoint permite consultar quais as moedas de referencia suportadas pela CoinGecko'''
|
|
return API('simple/supported_vs_currencies', {})
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = supported_currencies_list()
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for moeda in dados:
|
|
# print(f'{moeda}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coins_list(include_platform: bool = False) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-list
|
|
|
|
obter todas as moedas suportadas em CoinGecko com IDs, nome,
|
|
simbolo e (no caso de contractos) endereco na plataforma das moedas
|
|
'''
|
|
# dicionario de parametros
|
|
api_parameters= {
|
|
'include_platform': '',
|
|
}
|
|
# validacao parametros
|
|
# include_platform
|
|
if not isinstance(include_platform, bool):
|
|
include_platform = False
|
|
if include_platform:
|
|
api_parameters['include_platform'] = str(True).lower()
|
|
|
|
return API('coins/list', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coins_list(include_platform=False)
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
# lista auxiliar para ordenação dos dados retornados por coins_list_with_market_data()
|
|
# lista_tipos_ordenacao = [
|
|
# 'market_cap_asc',
|
|
# 'market_cap_desc',
|
|
# 'volume_asc',
|
|
# 'volume_desc',
|
|
# 'id_asc',
|
|
# 'id_desc'
|
|
# ]
|
|
# lista auxiliar para parametro 'price_change_percentage'
|
|
# lista_timeframe_price_change = [
|
|
# '1h',
|
|
# '24h',
|
|
# '7d',
|
|
# '14d',
|
|
# '30d',
|
|
# '200d',
|
|
# '1y'
|
|
# ]
|
|
def coins_list_with_market_data(
|
|
vs_currency: str = '',
|
|
ids: str = '',
|
|
category: str = '',
|
|
order: str = '',
|
|
per_page: int = 100,
|
|
page: int = 0,
|
|
sparkline: bool = False,
|
|
price_change_percentage: str = '',
|
|
locale: str = '',
|
|
precision: int | str = ''
|
|
) -> tuple[str, int, dict]:
|
|
'''
|
|
https://docs.coingecko.com/v3.0.1/reference/coins-markets
|
|
|
|
consultar preço, cap mercado, volume e dados de mercado de todas as moedas suportadas
|
|
|
|
'''
|
|
# dicionario de parametros para passar para a API, todos os valores tem de ser do tipo 'str'
|
|
api_parameters = {
|
|
'vs_currency': '',
|
|
'ids': '',
|
|
'category': '',
|
|
'order': '',
|
|
'per_page': '',
|
|
'page': '',
|
|
'sparkline': '',
|
|
'price_change_percentage': '',
|
|
'locale': '',
|
|
'precision': '',
|
|
}
|
|
# validação de parametros
|
|
# vs_currency
|
|
if not isinstance(vs_currency, str):
|
|
raise TypeError('\'vs_currency\' tem de ser do tipo \'str\'')
|
|
if vs_currency == '' or vs_currency == ' ':
|
|
raise ValueError('\'vs_currency\' tem de ser definido')
|
|
api_parameters['vs_currency'] = vs_currency
|
|
# ids
|
|
if not isinstance(ids, str):
|
|
raise TypeError('\'ids\' tem de ser do tipo \'str\'')
|
|
if ids != '':
|
|
api_parameters['ids'] = ids
|
|
# category
|
|
if not isinstance(category, str):
|
|
raise TypeError('\'category\' tem de ser do tipo \'str\'')
|
|
if category != '':
|
|
api_parameters['category'] = category
|
|
if ids == '' and category == '':
|
|
raise ValueError('\'ids\' ou \'category\' têm de ser definidos')
|
|
# order
|
|
if not isinstance(order, str):
|
|
raise TypeError('\'order\' tem de ser do tipo \'str\'')
|
|
# if not order in lista_tipos_ordenacao:
|
|
# order = lista_tipos_ordenacao[1]
|
|
api_parameters['order'] = order
|
|
# per_page
|
|
if not isinstance(per_page, int):
|
|
raise TypeError('\'per_page\' tem de ser do tipo \'int\'')
|
|
if (per_page < 1) or (per_page > 250):
|
|
per_page = 100
|
|
api_parameters['per_page'] = str(per_page)
|
|
# page
|
|
if not isinstance(page, int):
|
|
raise TypeError('\'page\' tem de ser do tipo \'int\'')
|
|
api_parameters['page'] = str(page)
|
|
# sparkline
|
|
if not isinstance(sparkline, bool):
|
|
raise TypeError('\'sparkline\' tem de ser do tipo \'bool\'')
|
|
if sparkline:
|
|
api_parameters['sparkline'] = str(True).lower()
|
|
# price_change_percentage
|
|
if not isinstance(price_change_percentage, str):
|
|
raise TypeError('\'price_change_percentage\' tem de ser do tipo \'str\'')
|
|
# for timeframe in price_change_percentage.split(','):
|
|
# if not timeframe in lista_timeframe_price_change:
|
|
# price_change_percentage = lista_timeframe_price_change[0]
|
|
# else:
|
|
# price_change_percentage += f',{timeframe}'
|
|
api_parameters['price_change_percentage'] = price_change_percentage
|
|
# locale
|
|
if not isinstance(locale, str):
|
|
raise TypeError('\'locale\' tem de ser do tipo \'str\'')
|
|
api_parameters['locale'] = locale
|
|
# precision
|
|
if precision != '':
|
|
if not isinstance(precision, (int, str)):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'int\' ou \'str\'')
|
|
if isinstance(precision, str):
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
precision = str(precision)
|
|
api_parameters['precision'] = precision
|
|
|
|
return API('coins/markets', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coins_list_with_market_data('eur', 'bitcoin')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# print(f'codigo: {codigo}')
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_data_by_id(
|
|
id_criptomoeda: str = '',
|
|
localization: bool = True,
|
|
tickers: bool = True,
|
|
market_data: bool = True,
|
|
community_data: bool = True,
|
|
developer_data: bool = True,
|
|
sparkline: bool = False,
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id
|
|
|
|
este endpoint permite fazer uma consulta a todos os dados de uma moeda
|
|
(nome, preço, dados mercado... incluindo tickers de correctora) na
|
|
CoinGecko com base numa id de moeda
|
|
'''
|
|
# dicionario de parametros
|
|
api_parameters = {
|
|
'id': '',
|
|
'localization': '',
|
|
'tickers': '',
|
|
'market_data': '',
|
|
'community_data': '',
|
|
'developer_data': '',
|
|
'sparkline': '',
|
|
}
|
|
# validação de parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == '':
|
|
raise ValueError('\'id_criptomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# localization
|
|
if not isinstance(localization, bool):
|
|
raise TypeError('\'localization\' tem de ser do tipo \'bool\'')
|
|
if not localization:
|
|
api_parameters['localization'] = str(localization).lower()
|
|
# tickers
|
|
if not isinstance(tickers, bool):
|
|
raise TypeError('\'tickers\' tem de ser do tipo \'bool\'')
|
|
if not tickers:
|
|
api_parameters['tickers'] = str(tickers).lower()
|
|
# market_data
|
|
if not isinstance(market_data, bool):
|
|
raise TypeError('\'market_data\' tem de ser do tipo \'bool\'')
|
|
if not market_data:
|
|
api_parameters['market_data'] = str(market_data).lower()
|
|
# community_data
|
|
if not isinstance(community_data, bool):
|
|
raise TypeError('\'community_data\' tem de ser do tipo \'bool\'')
|
|
if not community_data:
|
|
api_parameters['community_data'] = str(community_data).lower()
|
|
# developer_data
|
|
if not isinstance(developer_data, bool):
|
|
raise TypeError('\'developer_data\' tem de ser do tipo \'bool\'')
|
|
if not developer_data:
|
|
api_parameters['developer_data'] = str(developer_data).lower()
|
|
# sparkline
|
|
if not isinstance(sparkline, bool):
|
|
raise TypeError('\'sparkline\' tem de ser do tipo \'bool\'')
|
|
if sparkline:
|
|
api_parameters['sparkline'] = str(sparkline).lower()
|
|
|
|
return API(f'coins/{api_parameters['id']}', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_data_by_id('bitcoin')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def coin_tickers_by_id(
|
|
id_criptomoeda: str = '',
|
|
exchange_ids: str = '',
|
|
include_exchange_logo: bool = False,
|
|
page: int = -1,
|
|
order: str = '',
|
|
depth: bool = False
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id-tickers
|
|
|
|
este endpoint permite fazer uma consulta de tickers tanto em
|
|
correctoras centralizadas como descentralizadas a partir de um id
|
|
de moeda
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters: dict[str, str] = {
|
|
'id': '',
|
|
'exchange_ids': '',
|
|
'include_exchange_logo': '',
|
|
'page': '',
|
|
'order': '',
|
|
'depth': '',
|
|
}
|
|
# validacao parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == '':
|
|
raise ValueError('\'id_cripomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# exchange_ids
|
|
if not isinstance(exchange_ids, str):
|
|
raise TypeError('\'exchange_ids\' tem de ser do tipo \'str\'')
|
|
if exchange_ids != '':
|
|
api_parameters['exchange_ids'] = exchange_ids
|
|
# include_exchange_logo
|
|
if not isinstance(include_exchange_logo, bool):
|
|
raise TypeError('\'include_exchange_logo\' tem de ser do tipo \'str\'')
|
|
if include_exchange_logo:
|
|
api_parameters['include_exchange_logo'] = str(include_exchange_logo).lower()
|
|
# page
|
|
if not isinstance(page, int | None):
|
|
raise TypeError('\'page\' tem de ser do tipo \'int\'')
|
|
if page != None:
|
|
if page < 1:
|
|
page = 1
|
|
api_parameters['page'] = str(page)
|
|
# order
|
|
if not isinstance(order, str):
|
|
raise TypeError('\'order\' tem de ser do tipo \'str\'')
|
|
if order != '':
|
|
api_parameters['order'] = order
|
|
# depth
|
|
if not isinstance(depth, bool):
|
|
raise TypeError('\'depth\' tem de ser do tipo \'bool\'')
|
|
if depth:
|
|
api_parameters['depth'] = str(depth).lower()
|
|
|
|
return API(f'coins/{api_parameters['id']}/tickers', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_tickers_by_id('bitcoin',include_exchange_logo=True)
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados[item]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_historical_data_by_id(
|
|
id_criptomoeda: str = '',
|
|
date: str = '',
|
|
localization: bool = True
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id-history
|
|
|
|
este endpoint permite fazer consulta de dados historicos (preco, cap mercado, volume 24h,
|
|
etc) sobre uma moeda numa determinada data, passando o id da moeda.
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters: dict[str, str] = {
|
|
'id': '',
|
|
'date': '',
|
|
'localization': '',
|
|
}
|
|
# validacao de parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == None or id_criptomoeda == '':
|
|
raise ValueError('\'id_criptomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# date
|
|
if not isinstance(date, str):
|
|
raise TypeError('\'date\' tem de ser do tipo \'str\'')
|
|
if date == '' or date == None:
|
|
raise ValueError('\'date\' tem de ser definido')
|
|
if date != '':
|
|
api_parameters['date'] = date
|
|
# localization
|
|
if not isinstance(localization, bool):
|
|
raise TypeError('\'localization\' tem de ser do tipo \'bool\'')
|
|
if not localization:
|
|
api_parameters['localization'] = str(localization).lower()
|
|
|
|
return API(f'coins/{api_parameters['id']}/history', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_historical_data_by_id('bitcoin','10-12-2023',localization=False)
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_historical_chart_data_by_id(
|
|
id_criptomoeda: str = '',
|
|
vs_currency: str = '',
|
|
days: str = '',
|
|
interval: str = '',
|
|
precision: int | str = 'full'
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id-market-chart
|
|
|
|
este endpoint permite fazer consulta para obter dados historicos graficos que
|
|
incluem tempo unix, preco, capitalizacao mercado e volume 24h a partir de um id de moeda
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters = {
|
|
'id': '',
|
|
'vs_currency': '',
|
|
'days': '',
|
|
'interval': '',
|
|
'precision': '',
|
|
}
|
|
# validacao de parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == '':
|
|
raise ValueError('\'id_criptomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# vs_currency
|
|
if not isinstance(vs_currency, str):
|
|
raise TypeError('\'vs_currency\' tem de ser do tipo \'str\'')
|
|
if vs_currency == '':
|
|
raise ValueError('\'vs_currency\' tem de ser definido')
|
|
api_parameters['vs_currency'] = vs_currency
|
|
# days
|
|
if not isinstance(days, str):
|
|
raise TypeError('\'days\' tem de ser do tipo \'str\'')
|
|
if days == '':
|
|
raise ValueError('\'days\' tem de ser definido')
|
|
api_parameters['days'] = days
|
|
# interval
|
|
if not isinstance(interval, str):
|
|
raise TypeError('\'interval\' tem de ser do tipo \'str\'')
|
|
if interval != '':
|
|
api_parameters['interval'] = interval
|
|
# precision
|
|
if not isinstance(precision,( int, str)):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'str\' ou \'int\'')
|
|
if isinstance(precision, str):
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
api_parameters['precision'] = str(precision)
|
|
|
|
return API(f'coins/{api_parameters['id']}/market_chart', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_historical_chart_data_by_id('bitcoin', 'eur', '30')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados[item]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
# temos de criar outra abordagem, este noma de chamada api é enorme...
|
|
def coin_historical_chart_data_within_time_range_by_id(
|
|
id_criptomoeda: str = '',
|
|
vs_currency: str = '',
|
|
from_unix: int = -1,
|
|
to_unix: int = -1,
|
|
precision: str | int = 'full'
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id-market-chart-range
|
|
|
|
este endpoint permite obter dados historicos graficos compreendidos num periodo de tempo
|
|
unix com preco, capitalizacao de mercado e volume 24hrs a partir de um id de moeda
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters = {
|
|
'id': '',
|
|
'vs_currency': '',
|
|
'from': '',
|
|
'to': '',
|
|
'precision': '',
|
|
}
|
|
# validacao parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == '':
|
|
raise ValueError('\'id_criptomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# vs_currency
|
|
if not isinstance(vs_currency, str):
|
|
raise TypeError('\'vs_currency\' tem de ser do tipo \'str\'')
|
|
if vs_currency == '':
|
|
raise ValueError('\'vs_currency\' tem de ser definido')
|
|
api_parameters['vs_currency'] = vs_currency
|
|
# from_unix (como 'from' é nome reservado, foi usado outro nome)
|
|
if not isinstance(from_unix, int):
|
|
raise TypeError('\'from_unix\' tem de ser do tipo \'int\'')
|
|
if from_unix == -1:
|
|
raise ValueError('\'from_unix\' tm de ser definido')
|
|
api_parameters['from'] = str(from_unix)
|
|
# to_unix ('to' não é nome reservado, mas foi usado este nome para manter relação)
|
|
if not isinstance(to_unix, int):
|
|
raise TypeError('\'to_unix\' tem de ser do tipo \'int\'')
|
|
if to_unix == -1:
|
|
raise ValueError('\'to_unix\' tem de ser definido')
|
|
api_parameters['to'] = str(to_unix)
|
|
# precision
|
|
if not isinstance(precision, (int, str)):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'(int, str)\'')
|
|
if isinstance(precision, str):
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
api_parameters['precision'] = str(precision)
|
|
|
|
return API(f'coins/{api_parameters['id']}/market_chart/range', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_historical_chart_data_within_time_range_by_id('bitcoin','eur',1711929600,1712275200)
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados[item]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_ohlc_chart_by_id(
|
|
id_criptomoeda: str = '',
|
|
vs_currency: str = '',
|
|
days: str = '',
|
|
precision: str | int = 'full'
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-id-ohlc
|
|
|
|
este endpoint permite fazer consulta ao gráfico OHLC (Open, High, Low, Close)
|
|
de uma moeda usando o seu id
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters: dict = {
|
|
'id': '',
|
|
'vs_currency': '',
|
|
'days': '',
|
|
'precision': '',
|
|
}
|
|
# validacao de parametros
|
|
# id_criptomoeda (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_criptomoeda, str):
|
|
raise TypeError('\'id_criptomoeda\' tem de ser do tipo \'str\'')
|
|
if id_criptomoeda == '':
|
|
raise ValueError('\'id_criptomoeda\' tem de ser definido')
|
|
api_parameters['id'] = id_criptomoeda
|
|
# vs_currency
|
|
if not isinstance(vs_currency, str):
|
|
raise TypeError('\'vs_currency\' tem de ser do tipo \'str\'')
|
|
if vs_currency == '':
|
|
raise ValueError('\'vs_currency\' tem de ser definido')
|
|
api_parameters['vs_currency'] = vs_currency
|
|
# days
|
|
if not isinstance(days, str):
|
|
raise TypeError('\'days\' tem de ser do tipo \'str\'')
|
|
if days == '':
|
|
raise ValueError('\'days\' tem de ser definido')
|
|
api_parameters['days'] = days
|
|
# precision
|
|
if not isinstance(precision, (str, int)):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'(str, int)\'')
|
|
if isinstance(precision, str):
|
|
if precision != 'full':
|
|
precision = 'full'
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
precision = str(precision)
|
|
api_parameters['precision'] = precision
|
|
|
|
return API(f'coins/{api_parameters['id']}/ohlc', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_ohlc_chart_by_id('bitcoin','eur','1')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_data_by_token_address(
|
|
id_platform: str = '',
|
|
contract_address: str = ''
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/coins-contract-address
|
|
|
|
este endpoint permite consultar todos os dados de uma moeda (nome, preço, mercado...
|
|
incluindo tickers das correctoras) nda pagina da CoinGecko a partir da plataforma do activo
|
|
e do endereço do contrato do token
|
|
'''
|
|
# dicionario parametros
|
|
api_parameters: dict = {
|
|
'id': '',
|
|
'contract_address': '',
|
|
}
|
|
# validação de parametros
|
|
# id_platform (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_platform, str):
|
|
raise TypeError('\'id_platform\' tem de ser do tipo \'str\'')
|
|
if id_platform == '':
|
|
raise ValueError('\'id_platform\' tem de ser definido')
|
|
api_parameters['id'] = id_platform
|
|
# contract_address
|
|
if not isinstance(contract_address, str):
|
|
raise TypeError('\'contract_address\' tem de ser do tipo \'str\'')
|
|
if contract_address == '':
|
|
raise ValueError('\'contract_address\' tem de ser definido')
|
|
api_parameters['contract_address'] = contract_address
|
|
|
|
return API(f'coins/{api_parameters['id']}/contract/{api_parameters["contract_address"]}', {})
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_data_by_token_address('ethereum','0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados[item]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_historical_chart_data_by_token_address(
|
|
id_platform: str = '',
|
|
contract_address: str = '',
|
|
vs_currency: str = '',
|
|
days: str = '',
|
|
interval: str = '',
|
|
precision: str | int = 'full'
|
|
) -> tuple[str, int, dict]:
|
|
'''https://docs.coingecko.com/v3.0.1/reference/contract-address-market-chart
|
|
|
|
este endpoint permite consultar dados historicos graficos incluindo tempo UNIX,
|
|
preco, capitalização de mercado e volume 24hrs a partir da plataforma do activo e
|
|
endereco de contracto do token
|
|
'''
|
|
# dicionario parameters
|
|
api_parameters: dict = {
|
|
'id': '',
|
|
'contract_address': '',
|
|
'vs_currency': '',
|
|
'days': '',
|
|
'interval': '',
|
|
'precision': '',
|
|
}
|
|
# validacao de parametros
|
|
# id_platform (como 'id' é nome reservado, foi usado outro nome)
|
|
if not isinstance(id_platform, str):
|
|
raise TypeError('\'id_platform\' tem de ser do tipo \'str\'')
|
|
if id_platform == '':
|
|
raise ValueError('\'id_platform\' tem de ser definido')
|
|
api_parameters['id'] = id_platform
|
|
# contract_address
|
|
if not isinstance(contract_address, str):
|
|
raise TypeError('\'contract_address\' tem de ser do tipo \'str\'')
|
|
if contract_address == '':
|
|
raise ValueError('\'contract_address\' tem de ser definido')
|
|
api_parameters['contract_address'] = contract_address
|
|
# vs_currency
|
|
if not isinstance(vs_currency, str):
|
|
raise TypeError('\'vs_currency\' tem de ser do tipo \'str\'')
|
|
if vs_currency == '':
|
|
raise ValueError('\'vs_currency\' tem de ser definido')
|
|
api_parameters['vs_currency'] = vs_currency
|
|
# days
|
|
if not isinstance(days, str):
|
|
raise TypeError('\'days\' tem de ser do tipo \'str\'')
|
|
if days == '':
|
|
raise ValueError('\'days\' tem de ser definido')
|
|
api_parameters['days'] = days
|
|
# interval
|
|
if not isinstance(interval, str):
|
|
raise TypeError('\'interval\' tem de ser do tipo \'str\'')
|
|
api_parameters['interval'] = interval
|
|
# precision
|
|
if not isinstance(precision, (str, int)):
|
|
raise TypeError('\'precision\' tem de ser do tipo \'(str, int)\'')
|
|
if isinstance(precision, str):
|
|
if precision != 'full':
|
|
precision = 'full'
|
|
if precision == 'full':
|
|
precision = '18'
|
|
precision = int(precision)
|
|
if isinstance(precision, int):
|
|
if precision < 0:
|
|
precision = 0
|
|
if precision > 18:
|
|
precision = 18
|
|
precision = str(precision)
|
|
api_parameters['precision'] = precision
|
|
|
|
return API(f'coins/{api_parameters['id']}/contract/{api_parameters['contract_address']}/market_chart', api_parameters)
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = coin_historical_chart_data_by_token_address('ethereum','0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48','eur','1')
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(f'{item}: {dados[item]}')
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
|
|
def coin_historical_chart_data_within_time_range_by_token_address() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def assets_platforms_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def coins_categories_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def coins_categories_list_with_market_data() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def exchanges_list_with_data() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def exchanges_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def exchange_data_by_id() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def exchange_tickers_by_id() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def exchange_colume_chart_by_id() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def derivatives_tickers_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def derivatives_exchange_list_with_data() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def derivatives_exchange_data_by_id() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def derivatives_exchanges_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def nfts_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def nfts_collection_data_by_id() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def nfts_collection_data_by_contrat_address() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def btc_to_curency_exchange_rates() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def search_queries() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def trending_search_list() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def crypto_global_market_data() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def global_defi_market_data() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}')
|
|
|
|
def public_companies_holdings() -> tuple[str, int, dict]:
|
|
pass
|
|
|
|
|
|
# debug (decomentar linhas seguintes para testar funcao)
|
|
# url, codigo, dados = <nome_chamada_api()>
|
|
# print(f'url: {url}')
|
|
# if codigo == 200:
|
|
# for item in dados:
|
|
# print(item)
|
|
# else:
|
|
# print(f'erro {codigo}: {dados}') |