Bitcoin Forum
May 14, 2024, 02:21:06 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to buy Bitcoin from Bittrex using their API and Python?  (Read 154 times)
DELPK249 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
October 31, 2019, 02:38:29 AM
 #1

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!
1715696466
Hero Member
*
Offline Offline

Posts: 1715696466

View Profile Personal Message (Offline)

Ignore
1715696466
Reply with quote  #2

1715696466
Report to moderator
1715696466
Hero Member
*
Offline Offline

Posts: 1715696466

View Profile Personal Message (Offline)

Ignore
1715696466
Reply with quote  #2

1715696466
Report to moderator
1715696466
Hero Member
*
Offline Offline

Posts: 1715696466

View Profile Personal Message (Offline)

Ignore
1715696466
Reply with quote  #2

1715696466
Report to moderator
Bitcoin addresses contain a checksum, so it is very unlikely that mistyping an address will cause you to lose money.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10562



View Profile
October 31, 2019, 04:10:51 AM
 #2

you should stay away from bittrex, it is a scam exchange https://bitcointalk.org/index.php?action=trust;u=96390

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

first create the request URL like the example which would look like this:
Code:
https://api.bittrex.com/api/v1.1/path/call?param=value&apikey=0123456789&nonce=1542020339856
then use HMAC-SHA512 to hash it. the key of this HMAC is your apisecret and the message to hash is the URL. (decode both key and message as ASCII but then encode the result as hex).

now that you are ready you can start your Http POST call https://realpython.com/python-requests/
the URL of this call is the same URL above and the only difference is that you now have to add headers to this call. one header for 'Content-Type'='application/json' and one header to include what you signed. "apisign"="hex_that_was_computed_above"

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DELPK249 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
October 31, 2019, 04:30:44 AM
 #3

you should stay away from bittrex, it is a scam exchange https://bitcointalk.org/index.php?action=trust;u=96390

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

first create the request URL like the example which would look like this:
Code:
https://api.bittrex.com/api/v1.1/path/call?param=value&apikey=0123456789&nonce=1542020339856
then use HMAC-SHA512 to hash it. the key of this HMAC is your apisecret and the message to hash is the URL. (decode both key and message as ASCII but then encode the result as hex).

now that you are ready you can start your Http POST call https://realpython.com/python-requests/
the URL of this call is the same URL above and the only difference is that you now have to add headers to this call. one header for 'Content-Type'='application/json' and one header to include what you signed. "apisign"="hex_that_was_computed_above"

People seem to call exchanges scams sometimes just over them having a problem or two themselves and/or losing money and/or not getting fast responsive service from the exchange. I've seen Bittrex's CEO on CNBC before, they're based in the US, and while I haven't put much money on their exchange I have never had any problems myself with them, so far.

Are people sure that Bittrex is an untrustworthy exchange?

If Bittrex is untrustworthy then I would think that sure narrows down the number of exchanges we can actually use to only around just a few, and if that's the situation we have then I don't see where there is much real opportunity at all for making any money through trading through exchanges. Which would make them mostly pointless for most average people.


I don't understand what you're saying about how to use the key and headers and all of that. I've read that and heard similar in some videos but I can't find an actual example of actual code, and I don't think I'm going to understand this until I find an example of the code so that I can figure out and understand why whatever goes where ever.


Oh and as for my bot I was planning to add other exchanges but just began with Bittrex first since I have some XRP on there. So I'm not opposed at all to not using Bittrex and am fine using any other exchange/s.
DELPK249 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
October 31, 2019, 04:43:59 AM
 #4

Also I feel I should add that Bittrex has to my knowledge never been hacked, and they also support USD trading, not crypto only. I would expect some small problems rarely since they are a much smaller exchange than something like say Coinbase for example, but do people have evidence or proof of theft or similar problems with Bittrex?

Other than Coinbase my standard operating procedure with crypto exchanges in general is to do my best to avoid having much money in any one place where they could potentially steal it or lose it, because as far as I can tell even ones that may be genuinely trying are still so new and small that they're in rough operational conditions.
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10562



View Profile
October 31, 2019, 04:49:51 AM
 #5

People seem to call exchanges scams sometimes just over them having a problem or two themselves and/or losing money and/or not getting fast responsive service from the exchange. I've seen Bittrex's CEO on CNBC before, they're based in the US, and while I haven't put much money on their exchange I have never had any problems myself with them, so far.
it is not just some random newbie accounts complaining about losing on some trades. it was thousands of users that held a huge sum of money on bittrex for trading and they (me included) have never had any problems with it at all. there was no need to verify accounts and when asked they said it won't change and they had no problem with certain countries. some day they decided to change this rule overnight. they simply limited all the unverified accounts and banned those countries to practically rob their money.
you want to trust such company, that is your choice.

do people have evidence or proof of theft or similar problems with Bittrex?
try going through the trust link i posted above. it belongs to the user who opened up bittrex announcement on bitcointalk.

Quote
I don't understand what you're saying about how to use the key and headers and all of that. I've read that and heard similar in some videos but I can't find an actual example of actual code, and I don't think I'm going to understand this until I find an example of the code so that I can figure out and understand why whatever goes where ever.
sorry i am not familiar with python to give you any actual code but i could give you where to look (requests library). it would look something like this:
Code:
requests.get(
        'https://api.bittrex.com/api/v1.1/path/call?param=value&apikey=0123456789&nonce=1542020339856',
        headers={"apisign": 'FC70DD6467C916FBAA14EB89942644F9CF3F4CBF179923EE677413DC2E1CF2D8C5AA60C85A0A0BB3174960B8AA4FCFB0BC20CDE19BF21D567C671811C52CE631'}
    ).json()

there are also many examples on github: https://github.com/search?l=Python&q=bittrex&type=Repositories
this one in particular seems clear: https://github.com/ndri/python-bittrex/blob/7941b750d638bd5593777543a04c40ad539ca8e6/bittrex.py#L33-L42

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
DELPK249 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
October 31, 2019, 05:11:58 AM
 #6

People seem to call exchanges scams sometimes just over them having a problem or two themselves and/or losing money and/or not getting fast responsive service from the exchange. I've seen Bittrex's CEO on CNBC before, they're based in the US, and while I haven't put much money on their exchange I have never had any problems myself with them, so far.
it is not just some random newbie accounts complaining about losing on some trades. it was thousands of users that held a huge sum of money on bittrex for trading and they (me included) have never had any problems with it at all. there was no need to verify accounts and when asked they said it won't change and they had no problem with certain countries. some day they decided to change this rule overnight. they simply limited all the unverified accounts and banned those countries to practically rob their money.
you want to trust such company, that is your choice.

do people have evidence or proof of theft or similar problems with Bittrex?
try going through the trust link i posted above. it belongs to the user who opened up bittrex announcement on bitcointalk.

Quote
I don't understand what you're saying about how to use the key and headers and all of that. I've read that and heard similar in some videos but I can't find an actual example of actual code, and I don't think I'm going to understand this until I find an example of the code so that I can figure out and understand why whatever goes where ever.
sorry i am not familiar with python to give you any actual code but i could give you where to look (requests library). it would look something like this:
Code:
requests.get(
        'https://api.bittrex.com/api/v1.1/path/call?param=value&apikey=0123456789&nonce=1542020339856',
        headers={"apisign": 'FC70DD6467C916FBAA14EB89942644F9CF3F4CBF179923EE677413DC2E1CF2D8C5AA60C85A0A0BB3174960B8AA4FCFB0BC20CDE19BF21D567C671811C52CE631'}
    ).json()

there are also many examples on github: https://github.com/search?l=Python&q=bittrex&type=Repositories
this one in particular seems clear: https://github.com/ndri/python-bittrex/blob/7941b750d638bd5593777543a04c40ad539ca8e6/bittrex.py#L33-L42

Thanks for the help. I will be looking through all of this again while I work on my bot code so hopefully I will be able to figure out how to send a buy or sell order to the API now.

As for Bittrex, yeah that is really bad to limit unverified accounts and ban entire countries without warning, but even huge exchanges have banned USA accounts now too, with little or no warning. I am not speaking on how they treated withdrawal of their money since I don't really know how that went and it was probably different for different exchanges of course.

That is something that really concerns me with these exchanges especially since it seems to be happening to potentially any country/ies.

A friend of mine keeps telling me to go to an exchange he is on, but it's one of the larger exchanges that suddenly stopped service to the USA, and I guess now at some point they are serving the USA again according to him. Or something like that was going on. I told him I do not want to mess with an exchange that could potentially ban an entire country at any given time, or lots of countries.

Kraken is comparable to Bittrex I guess, but to me Kraken always seemed a little sketchier than Bittrex. Their CEO, I think his name is Jesse Powell, even once tweeted or something about how he was making lots of money short selling Bitcoin on their exchange. I don't have a problem with short selling or him using their exchange, but their CEO publicly disclosing his position/s like that seems extremely foolish, bad for business, possibly unethical, and possibly illegal.

Kraken also does not operate smoothly. One time I remember they went down for something like 1-3 entire days, in near total silence, and everyone was collectively just like "Well I guess they're taking our money and running". I don't remember if I had a small amount of crypto on there or not at the time, but I'm thinking I had a small amount and that was why I was following them being down.

After something like half a day or a day, they finally sent out a tweet or something just saying they were working hard but that their team had to go home to sleep after whatever 16 hours or 30 hours of work nonstop. And then they didn't say anything or respond for forever again, until finally Kraken came back to life.

So that was sure exceptionally sketchy and unimpressive to say the least.

I feel like it's hard to avoid dealing with these smaller sketchy exchanges to make money in crypto though.

What exchanges do you say I should use since you for good reason say not to use Bittrex?
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10562



View Profile
October 31, 2019, 05:26:49 AM
 #7

What exchanges do you say I should use since you for good reason say not to use Bittrex?

well the important thing in my opinion is to be aware of what you are dealing with. these companies have been doing pretty much anything they want. they pull a big scam like Gox, pull selective scams like this one, or get hacked or get fake hacked and a lot of other things that leads to users being screwed.
so when you choose a centralized exchange and start trading you should try to never feel safe. they control your money and you can lose it any moment. that is important for your risk management.

i would say use popular exchanges at the time with high volumes and beware of the risks. invest what you can afford to lose and don't leave it in their wallet whenever you can.
and start looking into truly decentralized exchanges. the benefit here is that you keep the control over your keys and consequently your fund.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
RivAngE
Full Member
***
Offline Offline

Activity: 728
Merit: 169


What doesn't kill you, makes you stronger


View Profile
October 31, 2019, 07:48:59 AM
 #8

try going through the trust link i posted above. it belongs to the user who opened up bittrex announcement on bitcointalk.

Hello, sorry for going off-topic here but I'd like to note for everyone who were not acting in the crypto back in 2017, that those trust scores are 2 years old and during a period many exchanges had similar problems.
Some exchanges couldn't hold the network traffic and their front end was failing, others could not process verification of users fast enough because of the huge influx of new users.
At the same time, scam artists were popping up in big numbers, trying to take advantage of both newbies and exchanges.

It's just my personal opinion when I'm saying this, but I wouldn't be bothered too much from the issues of that time.
Just be careful no matter what exchange you're using and don't store big amount of money there
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!