I keep getting this error :
######################### ERROR STACKTRACE ######################### Expected end of input Line: 0 Around: ...11092×16 DataFrame Row...
But when I run the code (excluding the routes) in a separate terminal, it runs just fine, returning a DataFrame of securities symbols with some information about them.
What am I doing wrong? (Note that the api key published here is a publishable key that only has access to free data.)
using Genie, Genie.Renderer.Json, Genie.Requests
using HTTP, JSON
using DataFrames
route("/tickers", method = POST) do
message = jsonpayload()
# (:echo => (message["message"] * " ") ^ message["repeat"]) |> json
syms = HTTP.request("GET","https://acre.iex.cloud/v1/data/CORE/REF_DATA?token=pk_79891f5cbcce4099ae063588956f937a")
schema_req = HTTP.request("GET","https://acre.iex.cloud/v1/data/CORE/REF_DATA?schema=true&token=pk_79891f5cbcce4099ae063588956f937a")
sbs = syms.body |> String |> JSON.parse
smat = sbs .|> values .|> collect |> (x->reduce(hcat,x)) |> (x->permutedims(DataFrame(x,:auto)))
schema = schema_req.body |> String |> JSON.parse |> first |> keys |> collect
rename!(smat,Symbol.(schema))
end
route("/send") do
response = HTTP.request("POST", "http://localhost:8000/tickers", [("Content-Type", "application/json")], """{"exchanges":"XNYS", "type":"cs"}""")
response.body |> String |> JSON.parse
end
up(async = false)
Ultimately, I'd like the '/tickers' route to be an API backend and the /send
route to exist in a desktop application (not necessarily as a webpage), so answers without relying heavily on formatting the /send
route are very welcome.
Thanks!
I discovered that importing both
JSON
andGenie.Renderer.Json
overloads the namejson
, and I need to use Genie's json parse method forresponse.body
, so I need to specifyjson
asGenie.Renderer.Json.json
.Hence the
/send
route should look like:The output looks really ugly though, so I'd like a way to change that.