Skip to content

Commit

Permalink
Update signal-cli-jsonrpc.5.adoc
Browse files Browse the repository at this point in the history
Added python example for HTTP
  • Loading branch information
banderlog authored Oct 5, 2023
1 parent 310aadb commit 90a3898
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions man/signal-cli-jsonrpc.5.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,33 @@ REQUEST: `{"jsonrpc":"2.0"}`

RESPONSE: `{"jsonrpc":"2.0","error":{"code":-32600,"message":"method field must be set","data":null},"id":null}`

=== Python examples

==== HTTP

Let's suppose, the daemon was started like that: `signal-cli -a ACCOUNT daemon --http 'localhost:8000'`

Then minimal example to interact with it will be:
```python
import requests
import random

# 'id' must be or you'll get '201' answer
x = {"jsonrpc": "2.0", "method": "listGroups", "id": random.randint(1, 999)}

# '/api/v1/rpc' is a undocumented but obligatory part of path to API
response = requests.post("http://localhost:8000/api/v1/rpc", json=x)
response.json()
```

==== Websockets

I failed to achieve any kind of responce with `websockets`

==== TCP

I failed to achieve any kind of responce with `socket` and connection always brakes with `zmq`

== Authors

Maintained by AsamK <asamk@gmx.de>, who is assisted by other open source contributors.
Expand Down

0 comments on commit 90a3898

Please sign in to comment.