Title: python3 mtgox api Post by: DaRude on April 04, 2013, 07:11:22 AM Ok so i'm going crazy trying to write a python3 code to get to gox's api v1
i found few programs but they either didn't work for me or are still doing v0 api ??? when i execute the following code i get Code: e.code -> 403 (API keys are correct and are enabled on gox) so if someone can tell me where i'm being an idiot i'd greatly appreciate it. Code: import time Title: Re: python3 mtgox api Post by: MineMind on April 04, 2013, 08:08:03 AM https://github.com/maxme/bitcoin-arbitrage
Title: Re: python3 mtgox api Post by: dflatline on April 04, 2013, 08:10:02 AM I have no idea what I'm talking about (I don't program), but why are you doing this:
GOX_secret = "your secret here" GOX_secret = base64.b64decode((GOX_secret.encode())) Why not just define GOX_secret outright? Title: Re: python3 mtgox api Post by: DaRude on April 04, 2013, 08:40:49 AM MineMind, that's python2 and a lot of code for me right now. But i'll start digging.
dflatline, just for readability. I know it looks odd but it's not the same encoding/decoding When you paste the key from GOX it comes in as a string, so initially GOX_secret.encode() changes a string into a bytes, and then base64.b64decode changes those bytes to base64 for GOX's API. I guess those two lines could be replaced by GOX_secret = base64.b64decode(("your secret here".encode())) Title: Re: python3 mtgox api Post by: dflatline on April 04, 2013, 09:33:19 AM Why not do:
req = urllib.request.Request(https://data.mtgox.com/api/1/generic/info, data=whatever, headers={"User-Agent": 'myGoxAPI', "Rest-Key": GOX_key, "Rest-Sign": sign}) Title: Re: python3 mtgox api Post by: DaRude on April 04, 2013, 10:08:12 AM You can, it'd be the same result just wouldn't be considered a nice style. It's a common practice to declare your variables together at the begging of the code e.g. if the api url changes you only have to change it in one place and don't have to hunt the code looking for every occurrence.
|