Python Forum
Python Rest API Public/Secret Keys Authentication Nonce
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Rest API Public/Secret Keys Authentication Nonce
#1
I'm trying to figure out how to write a request to tell my program to say for example buy Bitcoin, on a crypto exchange called Bittrex.

This is their API documentation:

https://bittrex.github.io/api/v1-1#authentication

I totally understand how to use the public API call feature things that do not require authentication/ the use of my public and private key and a nonce. But I do not understand what I am supposed to use for anything that does need authentication/ keys/ a nonce.

I found a way that looks good to create a value for the nonce using a timestamp with time.time, so I think I'm fine with that. I just do not even know where to begin really with where or what structure I place my public key, my private key, and the nonce. And I'm assuming the private key has to be put with something to encrypt it first which must be the hash or sha or something that I have seen in some videos and things that I have read trying to figure this out.

An example of what I am trying to learn how to do would be something like this:

Someone wants to have their program buy $100 of Bitcoin on Bittrex if the price of Bitcoin is at say $10,000 and whatever other parameters they need met are met, like obviously someone is selling Bitcoin on Bittrex and also obviously that this person has money on their Bittrex account to use to buy the Bitcoin with.

bittrex = requests.get('https://api.bittrex.com/api/v1.1/public/getmarketsummaries').json()

^ Those requests that are public are super easy to understand but I am just really having trouble finding an explanation for the requests that are not public requiring keys and all of that.

I think I might have just figured out where to use the nonce by looking at the example in the API documentation, but I'm unsure and still not getting where to even begin with the rest.
Reply
#2
How can I buy say Bitcoin from Bittrex.com using Python and their API? Bittrex's API documentation: https://bittrex.github.io/api/v1-1

The public requests are easy for me to understand. I can do them. I'm using the requests package. For example:

bittrex_exchange = requests.get('https://api.bittrex.com/api/v1.1/public/getmarketsummaries').json()

And later in other places I can use that to get other things, for example:

(bittrex_exchange['result'][0]['MarketName'])

gives me some particular piece of information I need.

But the private requests require authentication using my public key, secret key, and a nonce. I know how to generate a nonce:

noncea = int(round(time.time()-1571111111)*10)

I just put the letter a at the end to avoid mixing up any references in case the word nonce is used anywhere else in my code.

I also know how to encrypt my secret key (or at least I think I know how and am doing this correctly):

bittrex_encrypted_secret_key = hashlib.sha512(str(bittrex_secret_key).encode("utf-8")).hexdigest()

But I have no idea where to put/use my public key, encrypted secret key, and nonce!

If anyone can explain this to me I would greatly appreciate it!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  saml2 idp sso authentication tiagome 1 2,086 Apr-08-2022, 02:38 PM
Last Post: snippsat
  How to Host a REST API that executes a PYTHON script on the WEB SERVER rahul4data 4 3,387 Jan-25-2019, 02:54 PM
Last Post: DeaD_EyE
  Python Flask REST API vndywarhol 1 2,959 Sep-28-2018, 12:43 PM
Last Post: thomasp
  Python HTTPs client code with mutual SSL authentication ashish0265 0 3,859 Jul-28-2018, 07:39 PM
Last Post: ashish0265
  Download all secret links from a map design website fyec 0 2,813 Jul-24-2018, 09:08 PM
Last Post: fyec
  How to send keys at beginning of textbox using python Prince_Bhatia 2 3,023 May-21-2018, 08:15 AM
Last Post: Prince_Bhatia
  how to place Flask code on a public web server rarevesselt 6 6,893 Oct-04-2017, 07:32 AM
Last Post: rarevesselt
  California Public Salary Files Larz60+ 3 4,123 Mar-27-2017, 05:10 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020