@@ -44,11 +44,12 @@ The REST API supports the following transports:
4444
4545### HTTP transport
4646
47- You can use the ` curl ` utility to execute requests to the REST API:
47+ You can use the ` curl ` utility to execute requests to the REST API. Provide the [ API
48+ token] ( #authentication ) in the ` Authorization ` header:
4849
4950``` bash
5051curl \
51- -H " Authorization: JSON.WEB. TOKEN" \
52+ -H " Authorization: TOKEN" \
5253 -G \
5354 --data-urlencode ' query={
5455 "dimensions": [
@@ -82,7 +83,7 @@ from the REST API in your terminal:
8283
8384``` bash
8485curl \
85- -H " Authorization: JSON.WEB. TOKEN" \
86+ -H " Authorization: TOKEN" \
8687 -G \
8788 --data-urlencode ' query={"measures": ["orders.count"]}' \
8889 http://localhost:4000/cubejs-api/v1/load | jq .data
@@ -93,7 +94,7 @@ endpoint][ref-ref-meta-endpoint]:
9394
9495``` bash
9596curl \
96- -H " Authorization: JSON.WEB. TOKEN" \
97+ -H " Authorization: TOKEN" \
9798 http://localhost:4000/cubejs-api/v1/meta | jq
9899```
99100
@@ -102,8 +103,27 @@ from your JavaScript applications.
102103
103104### WebSocket transport
104105
105- WebSocket can be used to provide real-time experience. You can configire it via the
106- ` CUBEJS_WEB_SOCKETS ` environment variable.
106+ WebSocket transport can be used to provide real-time experience. You can configure it via
107+ the ` CUBEJS_WEB_SOCKETS ` environment variable.
108+
109+ You can use the [ ` websocat ` utility] [ link-websocat ] to test the WebSocket transport:
110+
111+ ``` bash
112+ websocat ws://localhost:4000/cubejs-api/v1/ws --text
113+ ```
114+
115+ After connecting, send the [ API token] ( #authentication ) as the first message:
116+
117+ ``` json
118+ {"authorization" :" TOKEN" }
119+ ```
120+
121+ Then, send requests. Each request should include a distinct ` messageId ` , the desired API
122+ endpoint in ` method ` , and additional ` params ` :
123+
124+ ``` json
125+ {"messageId" :" 1" ,"method" :" load" ,"params" :{"query" :{"measures" :[" orders.count" ]}}}
126+ ```
107127
108128Clients using the [ JavaScript SDK] [ ref-javascript-sdk ] can be switched to WebSocket
109129by passing ` WebSocketTransport ` to the ` CubeApi ` constructor:
@@ -114,7 +134,7 @@ import WebSocketTransport from "@cubejs-client/ws-transport"
114134
115135const cubeApi = cube ({
116136 transport: new WebSocketTransport ({
117- authorization: CUBE_TOKEN ,
137+ authorization: TOKEN ,
118138 apiUrl: " ws://localhost:4000/"
119139 })
120140})
@@ -326,4 +346,5 @@ warehouse][ref-data-warehouses].
326346[ ref-pre-aggregations ] : /product/caching/using-pre-aggregations
327347[ ref-javascript-sdk ] : /product/apis-integrations/javascript-sdk
328348[ ref-recipe-real-time-data-fetch ] : /product/apis-integrations/recipes/real-time-data-fetch
329- [ ref-refresh-keys ] : /product/data-modeling/reference/cube#refresh_key
349+ [ ref-refresh-keys ] : /product/data-modeling/reference/cube#refresh_key
350+ [ link-websocat ] : https://github.com/vi/websocat
0 commit comments