# Use wscat with HTTP JSON API Streaming API?

**URL:** <https://forum.canton.network/t/use-wscat-with-http-json-api-streaming-api/7588>\
**Category:** App Development\
**Tags:** json-api\
**Created:** [January 10, 2025, 8:06pm UTC](https://forum.canton.network/t/use-wscat-with-http-json-api-streaming-api/7588 "2025-01-10T20:06:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WallaceKelly](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wallacekelly/32/5046_2.png) [@WallaceKelly](https://forum.canton.network/u/WallaceKelly)\
**Post date:** [January 10, 2025, 8:06pm UTC](https://forum.canton.network/t/use-wscat-with-http-json-api-streaming-api/7588/1 "2025-01-10T20:06:17Z")

</div>

Is it possible to use [wscat](https://github.com/websockets/wscat) with the 2.x HTTP JSON API?

1. Start the HTTP JSON API.

2. Confirm the contracts exist and the token is good with `curl` and `v1/query`.  
(the token should work for you too)

3. Stream the contracts with `v1/stream/query`.

---

<div class="post-metadata">

**Author:** ![WallaceKelly](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wallacekelly/32/5046_2.png) [@WallaceKelly](https://forum.canton.network/u/WallaceKelly)\
**Post date:** [January 10, 2025, 8:37pm UTC](https://forum.canton.network/t/use-wscat-with-http-json-api-streaming-api/7588/2 "2025-01-10T20:37:01Z")

</div>

This works:

```plaintext
wscat --connect http://localhost:7575/v1/stream/query \
      --subprotocol 'daml.ws.auth' \
      --subprotocol 'jwt.token.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2RhbWwuY29tL2p3dC9hdWQvcGFydGljaXBhbnQvc2FuZGJveCIsInN1YiI6ImFsaWNlIiwiaXNzIjoiaWdub3JlZCJ9.uKjafJLbf4KCgBL6ys1pBT2jxs0DpflUpKX-5ZRtLVs' \
      --execute '{ "templateIds" : ["bc6d87a0d45cb8e2a9ea194ab9d380e79ab9622695c8fa9ab6c23d764d1e0df5:Main:Asset"] }'

```

> **Results**
>
> ```json
> {
> "events": [
> {
> "created": {
> "agreementText": "",
> "contractId": "003b0bf878e6602afdeae71c1f8abb032d27ed83b0a6e8e6b59aa351cd705ed82dca03122087e0aa95e3e93725fe43fe942d4c5c5ace112c6bcfd95b90581f1004bd47fab2",
> "observers": [],
> "payload": {
> "issuer": "Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd",
> "owner": "Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd",
> "name": "TV"
> },
> "signatories": [
> "Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd"
> ],
> "templateId": "bc6d87a0d45cb8e2a9ea194ab9d380e79ab9622695c8fa9ab6c23d764d1e0df5:Main:Asset"
> },
> "matchedQueries": [
> 0
> ]
> }
> ]
> }
> {
> "events": [],
> "offset": "000000000000000009"
> }
> 
> ```

Alternatively, connect and _then_ submit the filter:

```haskell
wscat --connect http://localhost:7575/v1/stream/query \
      --subprotocol 'daml.ws.auth' \
      --subprotocol 'jwt.token.eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJodHRwczovL2RhbWwuY29tL2p3dC9hdWQvcGFydGljaXBhbnQvc2FuZGJveCIsInN1YiI6ImFsaWNlIiwiaXNzIjoiaWdub3JlZCJ9.uKjafJLbf4KCgBL6ys1pBT2jxs0DpflUpKX-5ZRtLVs'

{ "templateIds" : ["bc6d87a0d45cb8e2a9ea194ab9d380e79ab9622695c8fa9ab6c23d764d1e0df5:Main:Asset"] }

```

> **Results**
>
> ```plaintext
> < {"events":[{"created":{"agreementText":"","contractId":"003b0bf878e6602afdeae71c1f8abb032d27ed83b0a6e8e6b59aa351cd705ed82dca03122087e0aa95e3e93725fe43fe942d4c5c5ace112c6bcfd95b90581f1004bd47fab2","observers":[],"payload":{"issuer":"Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd","owner":"Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd","name":"TV"},"signatories":["Alice::1220f3de2718124a544a3d46f3ef32fb51ffc963ba761bbadaed8b4667d482436fbd"],"templateId":"bc6d87a0d45cb8e2a9ea194ab9d380e79ab9622695c8fa9ab6c23d764d1e0df5:Main:Asset"},"matchedQueries":[0]}]}
> < {"events":[],"offset":"000000000000000009"}
> < {"events":[],"offset":"000000000000000009"}
> :
> :
> 
> ```

---

<div class="post-metadata">

**Author:** ![WallaceKelly](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/wallacekelly/32/5046_2.png) [@WallaceKelly](https://forum.canton.network/u/WallaceKelly)\
**Post date:** [August 6, 2026, 2:49pm UTC](https://forum.canton.network/t/use-wscat-with-http-json-api-streaming-api/7588/3 "2026-08-06T14:49:50Z")

</div>

I find that the JWT can alternatively be sent as an `Authorization: Bearer` header. This is better than being sent as a subprotocol `jwt.token.<place token here>` in a `Sec-WebSocket-Protocol` header. It is better because network components and tooling often avoid exposing `Authorization: Bearer` header contents.

```haskell
wscat --connect ws://localhost:8000/api/json-api/v2/state/active-contracts \
      -H 'Authorization: Bearer eyJhbGciOiJ...' \
      --subprotocol 'daml.ws.auth' \
      --execute '{"activeAtOffset":1764,"verbose":false,"eventFormat":{"filtersByParty":...'

```
