mauerstrwolf Posted April 20 Share Posted April 20 (edited) Moin, ich kriege bei diesem Python code immer den Fehler 400 Bad Request. Bin Anfänger und kann den Fehler ohne Hilfe nicht finden. import requests import hashlib import time import hmac api_key= 'abcde123' api_secret= "abc12345" nonce = str(int(time.time() * 1000000)) http_method= 'POST' uri= 'https://api.bitcoin.de/v4/btceur/orders/' #order einstellungen pparams = { 'max_amount_currency_to_trade': 1, 'payment_option': 2, 'price': 40000, 'sepa_option': 1, 'type': 'sell', 'min_amount_currency_to_trade': 0.5, 'new_order_for_remaining_amount': 1, } #Signatur #alphabetisch sortieren, in url wandeln url_encoded_query_string = "" sortparams = (sorted(pparams.items())) for k,v in sortparams: url_encoded_query_string += str(k) + "=" + str(v) + "&" url_encoded_query_string = url_encoded_query_string[:-1] #md5 encode post_parameter_md5_hashed_url_encoded_query_string = (hashlib.md5(url_encoded_query_string.encode()).hexdigest()) #hmac daten hmac_data = http_method+'#'+uri+'#'+api_key+'#'+nonce+'#'+post_parameter_md5_hashed_url_encoded_query_string h = hmac.new(bytes(api_secret, 'utf-8'), b'', hashlib.sha256) h.update(bytes(hmac_data, 'utf-8')) hmac = (h.hexdigest()) #Signatur #POST head ={'X-API-KEY': api_key, 'X-API-NONCE': nonce, 'X-API-SIGNATURE': hmac} body = sortparams r = requests.post(url= uri, headers=head, data=body) print (r) Edited April 20 by mauerstrwolf Fehler Link to comment Share on other sites More sharing options...
Firith Posted May 7 Share Posted May 7 uri= 'https://api.bitcoin.de/v4/btceur/orders/' Uri? Sollte es nicht url heissen? Link to comment Share on other sites More sharing options...
..::. o.Z.o.n.e .::.. Posted May 7 Share Posted May 7 (edited) vor 7 Stunden schrieb Firith: uri= 'https://api.bitcoin.de/v4/btceur/orders/' Uri? Sollte es nicht url heissen? URI wäre ansich auch Ok und ist nur der übergeordnete Begriff von URL und URN. Ist jedoch in unserem Sprachgebrauch eher rar. ;o)) PS. Die Frage ist natürlich eher was im Script definiert wurde. Das schaut jedoch Ok aus. PPS. Dieser Faden erinnert mich übrigens an diesen. Edited May 7 by ..::. o.Z.o.n.e .::.. PS … + PPS Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now