I'm trying create a order of withdrawal, but the response alerts error 405. I read the docs and saw that this error is related of wrong method, but I'm sure that the correct is POST
The documentation is: https://www.okx.com/docs-v5/en/?typescr ... es-channel
The Create-withdrawal-order: https://www.okx.com/docs-v5/en/?python# ... awal-order
Код, который я использую:
import json, requests
import base64, hmac
from datetime import datetime, timezone
import hashlib
import random
import string
class OkxAPI:
def __init__(self, APIKEY: str, APISECRET: str, PASS: str):
self.apikey = APIKEY
self.apisecret = APISECRET
self.password = PASS
self.baseURL = 'https://okx.com'
@staticmethod
def get_time():
timestamp = datetime.now(timezone.utc).isoformat(timespec='milliseconds').replace("+00:00", "Z")
return timestamp
@staticmethod
def create_client_id(length = 32):
characters = string.ascii_lowercase + string.digits
return ''.join(random.choices(characters, k=length))
def signature(self, timestamp, method, request_path, body, secret_key):
message = timestamp + method + request_path + body
signature = hmac.new(
self.apisecret.encode(), message.encode(), hashlib.sha256
).digest()
output = base64.b64encode(signature).decode()
return output
def get_header(self, request='GET', endpoint='', body=''):
cur_time = self.get_time()
header = dict()
header['CONTENT-TYPE'] = "application/json"
header['OK-ACCESS-KEY'] = self.apikey
header['OK-ACCESS-SIGN'] = self.signature(cur_time, request, endpoint, body, self.apisecret)
header['OK-ACCESS-TIMESTAMP'] = cur_time
header['OK-ACCESS-PASSPHRASE'] = self.password
return header
def withdrawal_payment_methods(self, ccy):
endpoint = f'/api/v5/fiat/withdrawal-payment-methods?ccy={ccy}'
url = self.baseURL + endpoint
# body = {
# 'ccy': ccy
# }
request = 'GET'
header = self.get_header(request, endpoint)
print(header)
response = requests.get(url, headers = header)
return response.json()
def create_withdrawal(self, ccy, amount):
clientId = self.create_client_id()
endpoint = f'/api/v5/fiat/create-withdrawal'
body = f"?paymentAcctId=my-account?ccy={ccy}?amt={amount}?paymentMethod=PIX?clientId={clientId}"
url = self.baseURL + endpoint
request = 'POST'
header = self.get_header(request, endpoint, body)
print(header)
response = requests.post(url, endpoint)
return response.json()
apiKey = ''
secretKey = ''
passphrase = ''
okx = OkxAPI(apiKey, secretKey, passphrase)
# print(okx.withdrawal_payment_methods('BRL'))
print(okx.create_withdrawal('BRL', '10'))
< /code>
Я попытался изменить метод, но ошибка сохраняется. Я также реализую другой метод, wietdrawal_payment_method, и он работает, поэтому я думаю, что подпись/get_time в порядке.
Подробнее здесь: https://stackoverflow.com/questions/794 ... th-okx-api
Ошибка 405 при попытке создать порядок снятия средств с API OKX ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как получить полную историю транзакций и данные о доходах через OKX API
Anonymous » » в форуме Python - 0 Ответы
- 83 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Ошибка OKX {'MSG': 'НЕПРАВИЛЬНЫЙ OK-ACCESS-TIMESTAMP', 'CODE': '50112'}
Anonymous » » в форуме Python - 0 Ответы
- 4 Просмотры
-
Последнее сообщение Anonymous
-