Bitcoin Forum
October 20, 2017, 08:00:14 PM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Bitfinex Api - "must specify a request field.."  (Read 3830 times)
wilfried
Sr. Member
****
Offline Offline

Activity: 288


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)





1508529614
Hero Member
*
Offline Offline

Posts: 1508529614

View Profile Personal Message (Offline)

Ignore
1508529614
Reply with quote  #2

1508529614
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1508529614
Hero Member
*
Offline Offline

Posts: 1508529614

View Profile Personal Message (Offline)

Ignore
1508529614
Reply with quote  #2

1508529614
Report to moderator
unclescrooge
aka Raphy
Hero Member
*****
Offline Offline

Activity: 868


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
Sr. Member
****
Offline Offline

Activity: 288


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


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!  >>
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!