Перейти к публикации
Форум ботоводов

Поиск по сайту

Результаты поиска по тегам 'graviex'.

  • Поиск по тегам

    Введите теги через запятую.
  • Поиск по автору

Тип публикаций


Категории и разделы

  • Ботоводство
    • Разработка, идеи ботов
    • Граберы/парсеры
    • Готовые боты
    • Боты для Telegram
  • Фуршет
    • Breaking news
    • Работа форума
    • Услуги
    • Курилка

Блоги

  • XBTBot - Бот для торговли на криптовалютной бирже BitMex.
  • 16 seater Tempo Traveller Hire

Искать результаты в...

Искать результаты, содержащие...


Дата создания

  • Начать

    Конец


Последнее обновление

  • Начать

    Конец


Фильтр по количеству...

Зарегистрирован

  • Начать

    Конец


Группа


About Me

  1. Исходники GitHub Рецепты API v3 Graviex python 3.9 GET: import time import hmac import hashlib import requests from pprint import pprint ''' All private API requires 3 authentication parameters and zero or more API specific parameters. access_key Your access key. tonce tonce is a timestamp in integer, stands for milliseconds elapsed since Unix epoch. Tonce must be within 30 seconds of server's current time. Each tonce can only be used once. signature Signature of the API request, generated by you, use your secret key. if it useful you can make a donation GIO: GQksGKKU6PotrByC8hQzBRwMAN7FuMNugF ETH: 0x290fE67efA690AE7924DB416d4239daC9c309b97 ''' DEBUG = True # your API keys access_key = '' secret_key = b'' tonce = int(time.time()) * 1000 if DEBUG: print(f'tonce: {tonce}') # the request query sorted in alphabetic order, including access_key and tonce, # e.g. access_key=xxx&foo=bar&tonce=123456789 request = f'access_key={access_key}&tonce={tonce}' # HTTP verb like GET/POST in uppercase verb = 'GET' # request path like /webapi/v3/markets uri = '/webapi/v3/deposits' # The combined string looks like: GET|/webapi/v3/markets|access_key=xxx&foo=bar&tonce=123456789 message = f'{verb}|{uri}|{request}' if DEBUG: print(f'request: {request}\nmessage: {message}') signature = hmac.new( secret_key, message.encode(), hashlib.sha256 ).hexdigest() if DEBUG: print(f'signature: {signature}') query = f'https://graviex.net{uri}?{request}&signature={signature}' response = requests.get(query) if DEBUG: print(f'query: {query}\nresponse: {response}') content = response.json() pprint(f'content: {content}') POST: import time import hmac import hashlib import requests from pprint import pprint ''' All private API requires 3 authentication parameters and zero or more API specific parameters. access_key Your access key. tonce tonce is a timestamp in integer, stands for milliseconds elapsed since Unix epoch. Tonce must be within 30 seconds of server's current time. Each tonce can only be used once. signature Signature of the API request, generated by you, use your secret key. if it useful you can make a donation GIO: GQksGKKU6PotrByC8hQzBRwMAN7FuMNugF DOGE: D8Hy4stikB4Pk8rnSfhQxgdZ59GqmasdPj ETH: 0x290fE67efA690AE7924DB416d4239daC9c309b97 ''' DEBUG = True # your API keys access_key = '' secret_key = b'' tonce = str(int(time.time()) * 1000) if DEBUG: print(f'tonce: {tonce}') # the request query sorted in alphabetic order, including access_key and tonce, # e.g. access_key=xxx&foo=bar&tonce=123456789 request = f'access_key={access_key}&market=gioeth&price=0.00003&side=buy&tonce={tonce}&volume=2.0' # HTTP verb like GET/POST in uppercase verb = 'POST' # request path like /webapi/v3/markets uri = '/webapi/v3/orders' # The combined string looks like: GET|/webapi/v3/markets|access_key=xxx&foo=bar&tonce=123456789 message = f'{verb}|{uri}|{request}' if DEBUG: print(f'request: {request}\nmessage: {message}') signature = hmac.new( secret_key, message.encode(), hashlib.sha256 ).hexdigest() if DEBUG: print(f'signature: {signature}') query = f'https://graviex.net{uri}?{request}&signature={signature}' response = requests.post(query) if DEBUG: print(f'query: {query}\nresponse: {response}') content = response.json() pprint(f'content: {content}') Звонилка: Реализация: Все публичные методы вызываются через приватный апи, ключи обязательны! Переключатель GET/POST get=True/False import time import hmac import hashlib import requests """ WebSite https://graviex.net/desktop API v3 https://graviex.net/documents/api_v3 API Usage Policy https://graviex.net/documents/user-agreement if it useful you can make a donation GIO: GQksGKKU6PotrByC8hQzBRwMAN7FuMNugF ETH: 0x290fE67efA690AE7924DB416d4239daC9c309b97 """ DEBUG = True class GraviexAPI: def __init__(self, access_key=None, secret_key=None): self.access = access_key self.secret = secret_key self.uri_main = "/webapi/v3/" self.base_url = "https://graviex.net/" # or use # self.base_url = "https://graviex.net:443/" def call_api(self, uri_path, param_path=None, params=None, get=True): # create tonce & sorting parameters to make sure the request is correct time.sleep(2) # edit as needed tonce = int(time.time()) * 1000 if not params: params = {} params.update(dict(tonce=tonce, access_key=self.access)) params_keys = list(params.keys()) params_keys.sort() if DEBUG: print(f'params: {params}') # create {canonical_query} & {canonical_uri} request = '' for key in params_keys: value = params[key] request += f'{key}={value}&' if DEBUG: print(f'request: {request}') if param_path: uri = f'{self.uri_main}{uri_path}/{param_path}' else: uri = f'{self.uri_main}{uri_path}' if DEBUG: print(f'uri: {uri}') # create payload & signature (hash of the request) # with crop the last character "&" in request, otherwise the signature will be incorrect if get: verb = 'GET' else: verb = 'POST' message = f'{verb}|{uri}|{request[:-1]}' if DEBUG: print(f'message: {message}') if self.secret: signature = hmac.new( # if api Secret Key not in bytes replace self.secret to # bytes(self.secret, encoding='utf-8'), self.secret, message.encode(), hashlib.sha256 ).hexdigest() # now we have a signed request which can be used like url query = f'{self.base_url}{uri}?{request}signature={signature}' else: query = f'{self.base_url}{uri}' print(f'query: {query}') # send requests and get responses if get: response = requests.get(query) else: response = requests.post(query) return response.json() if __name__ == '__main__': # 6000 requests/keypair/5 minutes, you can contact GRAVIEX if you need more. gex_private = GraviexAPI( access_key='', secret_key=b'' ) market = 'giobtc' currency = 'gio' timestamp = int(time.time() - 1000000000000) * 1000 public_apis = [ {'path': 'markets', 'sub_path': None, 'params': {}}, {'path': 'markets', 'sub_path': market, 'params': {'market': market}}, {'path': 'tickers', 'sub_path': None, 'params': {}}, {'path': 'markets', 'sub_path': market, 'params': {'market': market}}, {'path': 'depth', 'sub_path': None, 'params': {'market': market, 'limit': 1, 'order': None}}, {'path': 'trades', 'sub_path': None, 'params': {'market': market, 'limit': 1, 'order_by': 'desc', 'timestamp': timestamp, 'from': timestamp, 'to': timestamp}}, {'path': 'trades_simple', 'sub_path': None, 'params': {'market': market}}, {'path': 'k', 'sub_path': None, 'params': {'market': market, 'limit': 1, 'period': 1, 'timestamp': timestamp}}, {'path': 'k_with_pending_trades', 'sub_path': None, 'params': {'market': market, 'trade_id': 1, 'limit': 1, 'period': 1, 'timestamp': timestamp}}, {'path': 'timestamp', 'sub_path': None, 'params': {}}, {'path': 'currency', 'sub_path': 'info', 'params': {'currency': currency}}, ] for api in public_apis: r = gex_private.call_api(api['path'], param_path=api['sub_path'], params=api['params']) print(f'api: {api}:\n{r}\n')
×
×
  • Создать...