All
ফিল্টার দ্বারা:
আমি কিভাবে আমার অ্যাকাউন্টে নগদ জমা করব?
আমার অ্যাকাউন্ট যাচাইকরণের জন্য সাহায্য দরকার।
আমি কেন আমার অ্যাকাউন্টে প্রবেশ করতে পারছি না?
কোনো ক্রিপ্টো তোলার ফি আছে কি?
আমি আমার অ্যাকাউন্টে সাইন ইন করতে সাহায্য চাই।
অনুগ্রহ করে মনে রাখবেন যে নীচের তথ্যগুলি আমাদের প্রমাণীকরণ অ্যালগরিদমের সঠিক বাস্তবায়ন অনুমান করে, কারণ এটি সম্ভাব্য ইনপুট এবং ফর্ম্যাটিং ত্রুটিগুলি নিয়ে কাজ করে।
আমাদের প্রমাণীকরণ অ্যালগরিদম সম্পর্কে আরও জানতে অনুগ্রহ করে ক্লিক করুন এখানে
একটি সফল ব্যক্তিগত কল করার জন্য, একটি HTTP POST অনুরোধ উপযুক্ত এন্ডপয়েন্টে পাঠাতে হবে।
এই অনুরোধে হেডার API-সাইন (স্বাক্ষর) অন্তর্ভুক্ত থাকে যা এনকোড করা Post_data কে তার হ্যাশিং অ্যালগরিদমের অংশ হিসাবে ব্যবহার করে।
যদি হেডারে অন্তর্ভুক্ত স্বাক্ষর এবং অনুরোধে অন্তর্ভুক্ত POST ডেটার মধ্যে কোনো অমিল থাকে, তাহলে একটি অবৈধ API কী ত্রুটি ফেরত দেওয়া হবে।
নীচে একটি সঠিকভাবে গঠিত কলের উদাহরণ দেওয়া হলো যেখানে প্রমাণীকরণ অ্যালগরিদমে ব্যবহৃত ডেটা অনুরোধের বডিতে থাকা ডেটার সাথে মিলে যায়:
Python
#!/usr/bin/env python3
import time
import requests
import urllib.parse
import hashlib
import hmac
import base64
api_key = ''
secret_key = ''
nonce = str(int(1000 * time.time()))
# Define the URI path for the Kraken API request
uri_path = '/0/private/AddOrder'
# API URL
api_url = 'https://api.kraken.com'
# Create a dictionary for the request data
# Note that this is the data that will be used to calculate the Authentication Algorithm (API-Sign).
data = {
'nonce': nonce,
'ordertype': 'limit',
'type': 'buy',
'volume': '1',
'pair': 'btcusd',
'price': '58626.4',
'validate': True
}
# Encode the data for the request
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce']) + postdata).encode()
# Create a message to be signed
message = uri_path.encode() + hashlib.sha256(encoded).digest()
# Create the HMAC signature
mac = hmac.new(base64.b64decode(secret_key), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
# Create headers for the request
headers = {}
headers['API-Key'] = api_key
headers['API-Sign'] = sigdigest.decode()
# Make the POST request
# Note that the data below is what is sent in the HTTP request.
req = requests.post(api_url + uri_path, headers=headers, data={
'nonce': nonce,
'ordertype': 'limit',
'type': 'buy',
'volume': '1',
'pair': 'btcusd',
'price': '58626.4',
'validate': True
})
# Print the result
print(req.json())
# Result:
# {'error': [], 'result': {'descr': {'order': 'buy 1.00000000 XBTUSD @ limit 58626.4'}}}তবে, যখন অর্ডারটাইপ এবং ভলিউম অদলবদল করা হয়, তখন একটি অবৈধ কী ত্রুটি তৈরি হয়।
Python
#!/usr/bin/env python3
import time
import requests
import urllib.parse
import hashlib
import hmac
import base64
api_key = ''
secret_key = ''
nonce = str(int(1000 * time.time()))
# Define the URI path for the Kraken API request
uri_path = '/0/private/AddOrder'
# API URL
api_url = 'https://api.kraken.com'
# Create a dictionary for the request data
data = {
'nonce': nonce,
'ordertype': 'limit',
'type': 'buy',
'volume': '1',
'pair': 'btcusd',
'price': '58626.4',
'validate': True
}
# Encode the data for the request
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce']) + postdata).encode()
# Create a message to be signed
message = uri_path.encode() + hashlib.sha256(encoded).digest()
# Create the HMAC signature
mac = hmac.new(base64.b64decode(secret_key), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
# Create headers for the request
headers = {}
headers['API-Key'] = api_key
headers['API-Sign'] = sigdigest.decode()
# Make the POST request
req = requests.post(api_url + uri_path, headers=headers, data={
'nonce': nonce,
'volume': '1',
'type': 'buy',
'ordertype': 'limit',
'volume': '1',
'pair': 'btcusd',
'price': '58626.4',
'validate': True
})
# Print the result
print(req.json())
# Result:
# {'error': ['EAPI:Invalid key']}একটি ইঙ্গিত যা অবৈধ কী ত্রুটির কারণ হতে পারে তা হল যদি একাধিক প্যারামিটার প্রয়োজন হয় না এমন এন্ডপয়েন্টগুলিতে কল সফল হয় (ব্যালেন্স, ওপেনঅর্ডার)। যদি আপনি এই কলগুলি থেকে ক্রমাগত একটি বৈধ প্রতিক্রিয়া পান, তাহলে অমিলের তত্ত্বটি আরও বিশ্বাসযোগ্য বলে মনে হয়।
*অনুগ্রহ করে মনে রাখবেন যে উপরের উদাহরণে, ভ্যালিডেট প্যারামিটার ব্যবহার করা হয়েছিল যা শুধুমাত্র ইনপুটগুলি যাচাই করে কিন্তু অর্ডার জমা দেয় না। লাইভ ট্রেডিংয়ের জন্য প্যারামিটারটি বাতিল করা উচিত*
বডি এবং হেডারের কন্টেন্ট টাইপের মধ্যে অমিলও একটি অবৈধ API কী-এর কারণ হতে পারে।
নীচে এমন একটি পরিস্থিতি দেখুন যেখানে হেডার এবং পোস্ট ডেটা উভয়ই URL এনকোড করা হয়েছে:
Python
api_key = ""
api_secret = base64.b64decode("")
api_domain = "https://api.kraken.com"
api_path = "/0/private/"
api_endpoint = "Balance" # {"error":[]} IS SUCCESS-EMPTY BALANCE
api_parameters = ""
api_nonce = str(int(time.time() * 1000))
api_postdata = api_parameters + "&nonce=" + api_nonce
api_postdata = api_postdata.encode('utf-8')
api_sha256Data = api_nonce.encode('utf-8') + api_postdata
api_sha256 = hashlib.sha256(api_sha256Data).digest()
api_hmacSha512Data = api_path.encode('utf-8') + api_endpoint.encode('utf-8') + api_sha256
api_hmacsha512 = hmac.new(api_secret, api_hmacSha512Data, hashlib.sha512)
api_sig = base64.b64encode(api_hmacsha512.digest())
api_url = api_domain + api_path + api_endpoint
api_request = urllib2.Request(api_url, api_postdata)
api_request.add_header("Content-Type", "application/x-www-form-urlencoded")
api_request.add_header("API-Key", api_key)
api_request.add_header("API-Sign", api_sig)
api_request.add_header("User-Agent", "Kraken REST API")
print("DEBUG DATA : ")
print("api_url : " + api_url)
print("api_endpoint : " + api_endpoint)
print("api_parameters : " + api_parameters)
print("")
api_reply = urllib2.urlopen(api_request).read()
api_reply = api_reply.decode()
print("API JSON DATA:")
print(api_reply)
sys.exit(0)
# Response:
# API JSON DATA:
# {"error":[],"result":{"ADA":"0.00000000","AIR":"0.0000000000","ALGO":"0.00000000","ATOM":"0.00000000",
# "AVAX":"0.0000000000","BONK":"0.24","BSX":"0.00","C98":"0.00000","CVC":"0.0000000000","DOT":"0.0000000058",
# "DYM":"1.001240","ETH2.S":"0.0000000000","FLOW":"0.0000000000","FLR":"0.0000","GRT":"0.0000000000","ICP":"0.00000000",
# "KAVA":"0.00000000","KFEE":"4619.88","KSM":"0.0457969620","KSM.S":"0.0000000000","MATIC":"0.0000000000",
# "MINA":"1.0067624751","MINA.S":"0.0000000000","PARA":"0.000","POLS":"0.00000","SBR":"0.00000000","SCRT":"0.00000000",
# "SCRT21.S":"0.00000000","SDN":"0.0000000000","SEI":"0.0000","SHIB":"0.00000","SOL":"0.0000069748","SOL.S":"0.0000000000",
# "SOL03.S":"0.0201035317","TIA":"0.000000","TRX":"0.00000000","USDC":"0.00000000","USDT":"0.00068726",
# "USDT.B":"3.53191423","WEN":"158958.59","WIF":"0.00000","XBT.M":"0.0001000103","XETH":"0.0000000000",
# "XTZ":"0.00000000","XXBT":"0.0000000000","XXDG":"24.34451185","XXMR":"0.0000000000","ZCAD":"0.0000",
# "ZEUR":"0.2732","ZUSD":"0.6353"}}তবে, যখন আমরা হেডারের কন্টেন্ট টাইপ JSON হিসাবে যোগ করি, তখন আমরা একটি পাই
EAPI: অবৈধ কী ত্রুটি।
Python
api_key = ""
api_secret = base64.b64decode("")
api_domain = "https://api.kraken.com"
api_path = "/0/private/"
api_endpoint = "AddOrder" # {"error":[]} IS SUCCESS-EMPTY BALANCE
# api_parameters = "pair=xbtusd&ordertype=market&type=buy&volume=0.0001&validate=True"
api_parameters = ''
api_nonce = str(int(time.time() * 1000))
api_postdata = api_parameters + "&nonce=" + api_nonce
api_postdata = api_postdata.encode('utf-8')
api_sha256Data = api_nonce.encode('utf-8') + api_postdata
api_sha256 = hashlib.sha256(api_sha256Data).digest()
api_hmacSha512Data = api_path.encode('utf-8') + api_endpoint.encode('utf-8') + api_sha256
api_hmacsha512 = hmac.new(api_secret, api_hmacSha512Data, hashlib.sha512)
api_sig = base64.b64encode(api_hmacsha512.digest())
api_url = api_domain + api_path + api_endpoint
api_request = urllib2.Request(api_url, api_postdata)
print("DEBUG DATA : ")
print("api_url : " + api_url)
print("api_endpoint : " + api_endpoint)
print("api_parameters : " + api_parameters)
print("")
headers = {}
headers['API-Key'] = api_key
headers['API-Sign'] = api_sig
headers['Content-Type'] = 'application/json'
headers['Accepts'] = 'application/json'
headers['User-Agent'] = "Kraken REST API"
api_reply = urllib2.urlopen(api_request).read()
api_reply = api_reply.decode()
data = {'nonce': api_nonce}
req = requests.post(api_url, headers=headers, data=data)
print(req.json())
print("API JSON DATA:")
print(api_reply)
sys.exit(0)
# API JSON DATA:
# {"error":["EAPI:Invalid key"]}*মনে রাখবেন যে URL এনকোড করা ডেটা বা JSON এনকোড করা ডেটা উভয়ই ব্যবহার করা সম্ভব, তবে SHA256 ইনপুট এবং HTTP অনুরোধ উভয় ক্ষেত্রেই ডেটা ঠিক একই হতে হবে।*
একটি অবৈধ কী ত্রুটি অসম্পূর্ণ বা অনুপস্থিত এন্ডপয়েন্ট URI পাস করার কারণেও হতে পারে (উদাহরণস্বরূপ "AddOrder" এর পরিবর্তে “/0/private/AddOrder”)।
প্রমাণীকরণ অ্যালগরিদমকে সঠিকভাবে API-সাইন হেডার তৈরি করার জন্য, এটিকে সম্পূর্ণ URI ব্যবহার করতে হবে (উদাহরণস্বরূপ "/0/private/AddOrder”)। যদি এই URI-এর কোনো অংশ কাটা হয়, তাহলে এটি API-সাইন-এর জন্য একটি ভুল মানের দিকে নিয়ে যাবে এবং ফলস্বরূপ একটি অবৈধ কী ত্রুটি হবে।
নীচে শুধুমাত্র “AddOrder” এনকোডিংয়ের জন্য পাস করার একটি উদাহরণ দেওয়া হলো, সম্পূর্ণ এন্ডপয়েন্ট URI “/0/private/AddOrder” এর পরিবর্তে
Python
api_key = ''
secret_key = ''
# Define the URI path for the Kraken API request
uri_path = 'AddOrder'
# API URL
api_url = 'https://api.kraken.com/0/private/'
# Create a dictionary for the request data
data = {
"nonce": str(int(1000 * time.time())),
"ordertype": 'limit',
'type': 'buy',
'volume': '0.07617478622420963',
'pair': 'SOLUSD',
'price': '127.47',
'validate': 'true'
}
# Encode the data for the request
postdata = urllib.parse.urlencode(data)
encoded = (str(data['nonce']) + postdata).encode()
# Create a message to be signed
message = uri_path.encode() + hashlib.sha256(encoded).digest()
# Create the HMAC signature
mac = hmac.new(base64.b64decode(secret_key), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
# Create headers for the request
headers = {}
headers['API-Key'] = api_key
headers['API-Sign'] = sigdigest.decode()
# Make the POST request
req = requests.post(api_url + uri_path, headers=headers, data=data)
# Print the result
print(req.json())
# Result:
# {'error': ['EAPI:Invalid key']}আরেকটি সাধারণ সমস্যা যা একটি অবৈধ কী ত্রুটির কারণ হয় তা হল POST অনুরোধ এবং HTTP প্রমাণীকরণের মধ্যে এনকোডিংয়ের অমিল।
নীচের উদাহরণে, POST অনুরোধে পাস করা ‘ডেটা’ URL ফর্ম্যাট করা হয়েছে (স্পেসগুলি ‘+’ হিসাবে এনকোড করা হয়েছে) অ্যাপ্লিকেশন /x-www-form-urlencoded কন্টেন্ট-টাইপ হিসাবে, যেখানে ‘data_formatted’ স্পেসগুলিকে ‘%20’ হিসাবে এনকোড করছে।
যদিও উভয় উদাহরণেই স্পেসগুলি এনকোড করা হয়েছে, প্রমাণীকরণ অ্যালগরিদম এবং POST অনুরোধে পাস করা ডেটা ঠিক একই নয়। এর ফলে একটি অবৈধ কী ত্রুটি হবে।
Python
# Define the URI path for the Kraken API request
uri_path = '/0/private/DepositAddresses'
# API URL
api_url = 'https://api.kraken.com'
# Calculate Nonce for both data variables
nonce = str(int(1000 * time.time()))
# Create a dictionary for the request data
data = {
"nonce": nonce,
"asset": 'BTC',
'method': 'Bitcoin Lightning',
'amount': '0.2',
'new': True
}
postdata_data = urllib.parse.urlencode(data)
# Encode the data for the request manually
data_formatted = f'nonce={nonce}&asset=BTC&method=Bitcoin%20Lightning&amount=0.2&new=True'
postdata = data_formatted
encoded = (nonce + postdata).encode()
# Create a message to be signed
message = uri_path.encode() + hashlib.sha256(encoded).digest()
# Create the HMAC signature
mac = hmac.new(base64.b64decode(secret_key), message, hashlib.sha512)
sigdigest = base64.b64encode(mac.digest())
# Create headers for the request
headers = {}
headers['API-Key'] = api_key
headers['API-Sign'] = sigdigest.decode()
# Make the POST request
req = requests.post(api_url + uri_path, headers=headers, data=data)
# Print the result
print(req.json())
# Result:
# {'error': ['EAPI:Invalid key']}এটি স্পষ্টভাবে বোঝানোর জন্য, ডেটার 2টি ভিন্ন ফর্ম্যাট নিচে দেখুন:
Bash
data = nonce=1719929687102&asset=BTC&method=Bitcoin+Lightning&amount=0.2&new=True
data_formatted = nonce=1719929687102&asset=BTC&method=Bitcoin%20Lightning&amount=0.2&new=True*প্লেইন টেক্সট বা পার্সেন্ট এনকোডেড উভয়ই ব্যবহার করা সম্ভব, যতক্ষণ না প্রমাণীকরণ ডেটা এবং অনুরোধ উভয় ক্ষেত্রেই ফর্ম্যাট একই থাকে।*