Bitcoin Forum
April 25, 2024, 08:38:30 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Need help with mtgox api on python3  (Read 1161 times)
DaRude (OP)
Legendary
*
Offline Offline

Activity: 2775
Merit: 1787


In order to dump coins one must have coins


View Profile
April 04, 2013, 04:39:36 PM
 #1

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. After taking all of the stuff out it came down that even the basic test case fails. Can someone please point out what i'm doing wrong here?
when i execute the following code i get
Code:
e.code -> 403
e.read -> b'{"result":"error","error":"Identification required to access private API","token":"login_error_invalid_rest_key"}'

(API keys are correct and are enabled on gox)

Code:
import time
import urllib.parse
import urllib.request
import base64
import hmac
import hashlib

url = "https://data.mtgox.com/api/1/generic/info"

GOX_secret = "your secret here"
GOX_secret = base64.b64decode((GOX_secret.encode()))
GOX_key = "your keyname here"

params = {"nonce":str(int(time.time()*1000))}
post_data = urllib.parse.urlencode(params)

#ahmac = base64.b64encode(str(hmac.new(base64.b64decode(self.secret),post_data,hashlib.sha512).digest()))
H = hmac.new(GOX_secret, post_data.encode(), hashlib.sha512).digest()
sign = base64.b64encode(H)
header = {"User-Agent": 'myGoxAPI', "Rest-Key": GOX_key, "Rest-Sign": sign}


req = urllib.request.Request(url, post_data, header) #POST

try:
        response = urllib.request.urlopen(req, post_data.encode()) #POST
except urllib.error.HTTPError as e:
        print("e.code ->", e.code)
        print("e.read ->", (e.read()))
        exit(5)

print("It'd be nice to get here")

"Feeeeed me Roger!"  -Bcash
1714077510
Hero Member
*
Offline Offline

Posts: 1714077510

View Profile Personal Message (Offline)

Ignore
1714077510
Reply with quote  #2

1714077510
Report to moderator
1714077510
Hero Member
*
Offline Offline

Posts: 1714077510

View Profile Personal Message (Offline)

Ignore
1714077510
Reply with quote  #2

1714077510
Report to moderator
The forum strives to allow free discussion of any ideas. All policies are built around this principle. This doesn't mean you can post garbage, though: posts should actually contain ideas, and these ideas should be argued reasonably.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714077510
Hero Member
*
Offline Offline

Posts: 1714077510

View Profile Personal Message (Offline)

Ignore
1714077510
Reply with quote  #2

1714077510
Report to moderator
1714077510
Hero Member
*
Offline Offline

Posts: 1714077510

View Profile Personal Message (Offline)

Ignore
1714077510
Reply with quote  #2

1714077510
Report to moderator
1714077510
Hero Member
*
Offline Offline

Posts: 1714077510

View Profile Personal Message (Offline)

Ignore
1714077510
Reply with quote  #2

1714077510
Report to moderator
DaRude (OP)
Legendary
*
Offline Offline

Activity: 2775
Merit: 1787


In order to dump coins one must have coins


View Profile
April 04, 2013, 07:59:48 PM
 #2

Disregard, apparently the code works and the issue was with my API keys. Generated a new set, and it worked  Shocked

"Feeeeed me Roger!"  -Bcash
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!