Pages:
Author

Topic: Bitfinex's streaming (websocket) api (Read 5483 times)

member
Activity: 105
Merit: 10
September 27, 2018, 10:44:25 AM
#21
Hi!

How to connect to WebSocket on PHP? (I used REST API, but now need WS)
I just need the very first step - want to connect to WS (for example, ping). The rest I'll do myself.

Help me please.
Thanks.
member
Activity: 85
Merit: 10
September 14, 2015, 05:54:53 PM
#20
Using the subscribe as per bricky's post, I got some trades coming back. So thats good Smiley

However the reason it stops sending data is that it's expecting a response to the websocket_rails.ping event.

Code:
[["websocket_rails.ping",{"id":null,"channel":null,"user_id":null,"data":{},"success":null,"result":null,"token":null,"server_token":null}]]
member
Activity: 85
Merit: 10
September 14, 2015, 05:34:19 PM
#19
Is bitfinex's websocket implementation working/live? I can connect successfully, but don't get any trade data streaming in...

Anyone had any success with this?
newbie
Activity: 17
Merit: 0
June 24, 2015, 03:56:50 AM
#18
Hi bricky, do you still receive trade.new messages ? I don't...
newbie
Activity: 25
Merit: 0
June 06, 2015, 11:03:49 AM
#17
Hi xspdr.

Your path for the websocket is wrong (that's what a 404 means).  It should be 'wss://ws.bitfinex.com:3333/websocket'.
You will almost certainly need to go through the js on the site to see how to connection works, this is very unlike okcoin, and there are several steps involved in getting this working.  I'd suggest actually that you wait for the "official" websocket api to be release (along with documentation) - it can't be very far away now.

Note: what I've said above still stands as far as I know - the orderbook this gives is still incomplete.  This is why no one uses it.

Please don't PM me your questions again.

thanks




Edit: and then he goes off and deletes his post so that my reply is pointless.  Thanks for that dude.
newbie
Activity: 17
Merit: 0
April 22, 2015, 09:12:33 AM
#16
right, I'm not sure what went wrong when I tried that. Anyway, thanks.
newbie
Activity: 25
Merit: 0
April 22, 2015, 08:39:27 AM
#15
Have you found out a trades channel? I tried trade, trades, trade.btcusd and trades.btcusd to no avail.

Yeah, it's working, tried it just now:


Code:
> ["websocket_rails.subscribe", {"data":{"channel": "trade.btcusd" }}]
< text: [["websocket_rails.channel_token",{"id":null,"channel":"trade.btcusd","user_id":null,"data":{"token":"fa1222b8-0e2f-4e8b-bcbb-165ea6d40d35"},"success":null,"result":null,"token":null,"server_token":null}]]
< text: [["websocket_rails.subscribe",{"id":null,"channel":null,"user_id":null,"data":null,"success":true,"result":null,"token":null,"server_token":null}]]
< text: [["trade.new",{"id":null,"channel":"trade.btcusd","user_id":null,"data":{"pair":"BTCUSD","price":"235.4","amount":"4.81834136","side":1,"timestamp":"1429709841.026109114"},"success":null,"result":null,"token":"fa1222b8-0e2f-4e8b-bcbb-165ea6d40d35","server_token":"MsoF3fiWaVg1YKThhtQ48g"}]]
< text: [["trade.new",{"id":null,"channel":"trade.btcusd","user_id":null,"data":{"pair":"BTCUSD","price":"235.4","amount":"0.18165864","side":1,"timestamp":"1429709841.114709611"},"success":null,"result":null,"token":"fa1222b8-0e2f-4e8b-bcbb-165ea6d40d35","server_token":"MsoF3fiWaVg1YKThhtQ48g"}]]
newbie
Activity: 17
Merit: 0
April 22, 2015, 04:29:07 AM
#14
Have you found out a trades channel? I tried trade, trades, trade.btcusd and trades.btcusd to no avail.
newbie
Activity: 25
Merit: 0
April 15, 2015, 07:02:55 AM
#13
ah cool it worked thanks! I had spied on the pongs of the bitfinex.com client and didn't see the connectionId being passed, weird.

Very welcome Smiley

If you can get a reliable book out of it please let me know how you do it!  Been messing around with it again over the last 24 hrs, and it is soooooo tantalizingly close!
newbie
Activity: 17
Merit: 0
April 15, 2015, 03:22:56 AM
#12
ah cool it worked thanks! I had spied on the pongs of the bitfinex.com client and didn't see the connectionId being passed, weird.
newbie
Activity: 25
Merit: 0
April 14, 2015, 02:37:27 PM
#11

I wasn't getting disconnected, but the socket went silent (after maybe a minute?) if I didn't reply to pings - maybe that's what's happening to you?  The implementation is actually very straightforward - take a look at the application-*.js file on the bitfinex site to see how they do it.

(never did a websocket client myself in node, so I can't help you on that front I'm afraid)

I thought it was that at first, but I keep getting the behavior you describe, even when I pong back. Are you authenticated?

No, I'm not authenticated.  Maybe you're not sending back the connection_id in your pong?

(I had posted a bunch of code here, but I think there's no point, you're almost certainly missing the connection_id)

This is what the pong should look like:

Code:
["websocket_rails.pong", {"data":{"connection_id": "%s" }}]

where the %s is your connection_id (you'll get that in your first 'client_connected' message you get back)

Did anyone gets a message on the depth.pair channel?

Yes (read the thread!)   Wink
newbie
Activity: 17
Merit: 0
April 14, 2015, 11:10:26 AM
#10

I wasn't getting disconnected, but the socket went silent (after maybe a minute?) if I didn't reply to pings - maybe that's what's happening to you?  The implementation is actually very straightforward - take a look at the application-*.js file on the bitfinex site to see how they do it.

(never did a websocket client myself in node, so I can't help you on that front I'm afraid)

I thought it was that at first, but I keep getting the behavior you describe, even when I pong back. Are you authenticated?
newbie
Activity: 1
Merit: 0
April 13, 2015, 09:40:15 AM
#9
Did anyone gets a message on the depth.pair channel?

Quote
For depth.pair channels you will receive depth.change events, like this:
{"pair"=>"BTCUSD", "price"=>"624.24", "type"=>"ask", "change"=>"0.02",
"timestamp"=>"1406031564.387416988"}

newbie
Activity: 25
Merit: 0
April 13, 2015, 08:38:36 AM
#8
bricky, I get disconnected like after 10 seconds when I connect from nodejs. Do you have the same problem?

I wasn't getting disconnected, but the socket went silent (after maybe a minute?) if I didn't reply to pings - maybe that's what's happening to you?  The implementation is actually very straightforward - take a look at the application-*.js file on the bitfinex site to see how they do it.

(never did a websocket client myself in node, so I can't help you on that front I'm afraid)


Also how did you discover the channels that are available (like depth) ?

By looking through the client on the website (it uses the websocket for tickers and order tracking for example), some googling, and plain guesswork Smiley
newbie
Activity: 17
Merit: 0
April 13, 2015, 08:24:47 AM
#7
bricky, I get disconnected like after 10 seconds when I connect from nodejs. Do you have the same problem? Also how did you discover the channels that are available (like depth) ?
newbie
Activity: 25
Merit: 0
March 30, 2015, 04:38:47 AM
#6
Yup, it's still working (just checked depth.ltcbtc), but the order book it gives is still wrong. Sad



Edit: to clarify

I first take a snapshot of the order book via the regular api, then modify it as changes come through the websocket.
Most of the websocket events are correct - but it seems to be missing either the order change or cancel events, so over time an error builds up.  As it is it's unusable.

(although it's completely possible that I'm just doing something stupid and it's fully functional!)
sr. member
Activity: 288
Merit: 250
ManualMiner
March 29, 2015, 04:55:45 AM
#5
is it still working for you ?
i get "integer required" messages only.

heres a thread bout the channels:

https://github.com/timmolter/XChange/issues/630
sr. member
Activity: 288
Merit: 250
ManualMiner
March 23, 2015, 03:27:37 AM
#4
is there a schedule given from them for the new api?
newbie
Activity: 25
Merit: 0
March 22, 2015, 09:33:08 AM
#3
so they changed their site to use websocket -a guy here claims its using ajax polling

It uses ajax for the order book, but it uses websockets for the ticker and for tracking your own open orders (those pnotify messages for example are in response to websocket events).

I subscribed to the depth.pair channels also (with much hope!), but the orderbook it gives is incorrect.  It does appear to be related to the real order book, but I think (at a guess) it might be missing order replace and order cancel events.  (Curiously though, I think it might be leaking some hidden order data)

Anyway, I live in hope for the new api they're promising Smiley
sr. member
Activity: 288
Merit: 250
ManualMiner
March 22, 2015, 07:38:12 AM
#2
wow, cool, finally after 1,5 years something moves with the websocket interface.
does it still work?
so they changed their site to use websocket -a guy here claims its using ajax polling
https://github.com/timmolter/XChange/issues/630

gtz
Pages:
Jump to: