Hi everyone, sorry if this is a really noob question but I’m I’m trying to translate some instructions in NodeJS to connect to an API into a Julia interface. I’m not a web developer and the documentation in HTTP.jl is miserable, so I have no choice but to ask for some help.
I’m trying to translate the instructions here: Newton API Docs
An acceptable choice for the parameters would be symbol="BTC_USD" and candle="1m".
I tried starting with the WebSocket example in HTTP.jl but I’m pretty sure the example is far too minimalistic to replicate the code above.
JavaScript by default handles communication with events. HTTP.jl doesn’t expose an event based API though, it presents a WebSocket as a regular Socket (like UDP or TCP). You’re going to have to parse the response you get and decide based on the message which method to call.
I’d start with the code from HTTP.jl and investigate what the remote server is actually sending to you - my best bet is it’ll be some kind of JSON which you should be able to unpack and work with.
HTTP.jl handles websockets via openraw. the websocket example in http.jl should work fine. It seems newton.co is using AWS style auth (mash all this stuff together, take the sha256 hash of it, submit it as an authentication for the next 5m).
Most likely, newton.co is sending back JSON which JSON.jl should handle.
First and foremost, the server is returning an error and no actual data. I’m not familiar with the API you’re trying to target, but there’s bound to be some documentation about why/when a 502 HTTP error is returned, so you’ll have to figure out why that happens before you can continue trying to parse the real response.
@Sukera Well the NodeJS example in the documentation works. I think the reason is because the HTTP.jl example connects to the url using a HTTP protocol instead of websocket so it’s being rejected.
@sampope The openraw example is interesting but unfortunately it has been deprecated. The example doesn’t work and the documentation is no longer available in the latest version of HTTP.jl
Hello newton use socket.io not exactly the same as websockets. I’m currently working on creating a guile scheme client to newton using https://github.com/socketio/socket.io-client-cpp. Being completely ignorant of Julia it’s possible you can use FFI. on the other hand if Julia has a binding to gobject introspection I could create a glib library in which case guile and julia could both use it. let me know how this works and possibly we could pool resources .