Bitcoin Forum
December 11, 2024, 11:49:40 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitfinex Api - "must specify a request field.."  (Read 4132 times)
wilfried (OP)
Sr. Member
****
Offline Offline

Activity: 288
Merit: 250


ManualMiner


View Profile
November 02, 2013, 07:52:45 PM
 #1

Hy,

When making authenticated calls to the bitfinex api  (orders, balances) i get this message:

Code:
Response Content: {"message":"Must specify a 'request' field in the payload that
 matches the URL path."}

Whats that about?Huh

The examples I tried (Python):
https://community.bitfinex.com/showwiki.php?title=Sample+API+Code
https://gist.github.com/jordanbaucke/5812039

Code:
	url = 'https://bitfinex.com/api/v1/balances'
payloadObject = {
'request':'/api/v1/balances',
'nonce':time.time(),
'options':{}
}
payload_json = json.dumps(payloadObject)
#print payload_json
payload = str(base64.b64encode(payload_json))
#print payload
api_secret="..."
api_key="..."
m=hmac.new(api_secret, payload, hashlib.sha384)
signature=m.hexdigest()
print signature
headers = {
'X-BFX-APIKEY' : api_key,
'X-BFX-PAYLOAD' : base64.b64encode(payload_json),
'X-BFX-SIGNATURE' : signature
}
r = requests.get(url, data={}, headers=headers)
print 'Response Code: ' + str(r.status_code)
print 'Response Header: ' + str(r.headers)
print 'Response Content: '+ str(r.content)





unclescrooge
aka Raphy
Hero Member
*****
Offline Offline

Activity: 868
Merit: 1000


View Profile
November 02, 2013, 10:21:36 PM
 #2

Hello Wilfried,

Well, it seems we need to update the api.

The URL to use now it:

api.bitfinex.com/v1/<whatever>

As such, the parameter
"request" that you send must be

Quote
'request':'/v1/<whatever>'

instead of

Quote
'request':'/api/v1/<whatever>'


Let me know if it helps, I'll update the wiki soon.

Raphael
Bitfinex team
wilfried (OP)
Sr. Member
****
Offline Offline

Activity: 288
Merit: 250


ManualMiner


View Profile
November 02, 2013, 10:51:57 PM
 #3

thx!  helped Smiley

changed nonce too, code now works:

Code:
	url = 'https://api.bitfinex.com/v1/balances'
payloadObject = {
'request':'/v1/balances',
'nonce':str(long(time.time() * 100000)),
'options':{}
}
payload_json = json.dumps(payloadObject)
#print payload_json
payload = str(base64.b64encode(payload_json))
#print payload
api_secret="..."
api_key=".."
m=hmac.new(api_secret, payload, hashlib.sha384)
signature=m.hexdigest()
print signature
headers = {
'X-BFX-APIKEY' : api_key,
'X-BFX-PAYLOAD' : base64.b64encode(payload_json),
'X-BFX-SIGNATURE' : signature
}
r = requests.get(url, data={}, headers=headers)
print 'Response Code: ' + str(r.status_code)
print 'Response Header: ' + str(r.headers)
print 'Response Content: '+ str(r.content)

TrueBeliever
Member
**
Offline Offline

Activity: 78
Merit: 11


View Profile
August 02, 2015, 11:42:27 AM
 #4

I know this is an old topic, but in case anyone is having problems with the Bitfinex API:

In the documentation it shows all authenticated actions as using verb POST.  This is NOT correct as you can see by the above code.  Use GET.  Using POST will give you a 400 error.

I wasted a couple of hours on this problem, hope it saves someone else some time.

██████████    YoBit.net - Cryptocurrency Exchange - Over 350 coins
█████████    <<  ● $$$ - $$$ - $$$ - $$$ - $$$ - $$$ - $$$   >>
██████████    <<  ● Play DICE! Win 1-5 btc just for 5 mins!  >>
Lordaster
Newbie
*
Offline Offline

Activity: 19
Merit: 0


View Profile
October 26, 2017, 03:42:13 PM
 #5

Help me, please. What i doing wrong?

Code:
api_key = 'some key'
api_secret = 'some secret'
api_url = 'https://api.bitfinex.com/v1'

def Balances():
    nonce = str(long(time.time() * 100000))
    payloadObject = {
        'request':'/balances',
        'nonce': nonce,
        'options':{}
        }
    payload_json = json.dumps(payloadObject)
    payload = str(base64.b64encode(payload_json))
    parms = urllib.urlencode(payloadObject)
    signature = hmac.new(api_secret, parms, hashlib.sha384).hexdigest()
    headers = {"X-BFX-APIKEY": api_key,
               'X-BFX-PAYLOAD': payload,
               "X-BFX-SIGNATURE": signature,
               }

    public = urllib2.urlopen(urllib2.Request(api_url + '/balances', headers))
    balances = json.load(public)
    return balances
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!