Title
#users-public
a

Adam Mustafa

09/20/2022, 1:41 AM
Hey All, I have a quick question. Is there a way to directly consume websocket data into a table without needing an intermediate server to connect and consume?
Andrey Pechkurov

Andrey Pechkurov

09/20/2022, 6:04 AM
Hi Adam, WS is not supported, but you could use
/imp
HTTP endpoint to ingest data.https://questdb.io/docs/reference/api/rest/#imp---import-data
j

javier ramirez

09/20/2022, 7:35 AM
Not sure if you want to read from questdb using a websocket, or if you want to ingest into questdb. For ingestion, what Andrei said. For reading, you can use the /exec endpoint. Since you probably want to read only new data, a trick is using the row_number() function on your query. Here you are an example you can run on https://demo.questdb.io. The trades table is continually updating. This query reads only rows committed after right now. By filtering in every subsequent query by the previous latest row number, you can get incremental reads every time you poll.
WITH numbered_rows AS (
SELECT *, row_number() AS latest_row FROM 'trades'
) SELECT * FROM numbered_rows WHERE latest_row > 242373300
a

Adam Mustafa

09/20/2022, 12:39 PM
Thank you both! My original intent was to ingest into QuestDB. There is a websocket API of financial data I want to just put directly into a table. It's not the end of the world. The
/imp
endpoint will definitely be helpful at some point but right now our main data streams are WS. @javier ramirez Thank you! That actually helps solve my next problem!