Created Json service (markdown)

John Freed 2021-08-19 21:47:44 +02:00
parent c0e6996954
commit 98a9ce1bd0

21
Json-service.md Normal file

@ -0,0 +1,21 @@
signal-cli (proposed release) supports a JSON RPC server that accepts input on STDIN and replies on STDOUT. See (https://github.com/AsamK/signal-cli/discussions/679)
It is possible to communicate with the server over the network using named pipes. For example, the following command sets up a JSON RPC signal-cli server listening on local port 9182:
`nc -l -p 9182 <sigsocket | signal-cli --output=json -u +33123456789 jsonRpc >sigsocket &`
To communicate with the server from the same machine (localhost), issue the command:
`nc localhost 9182`
Enter your requests in the required format. Be sure to include the arbitrary "id" field if you want to receive a response! The response will contain the same "id" as its last field. For example:
ENTRY: `{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}`
REPLY: `{"jsonrpc":"2.0","result":[{"id":"Pmpi+EfPWmsxiomLe9Nx2XF9HOE483p6iKiFj65iMwI=","name":"My Group","description":"It's special because it is mine.","isMember":true,"isBlocked":false,"members":["+33123456789","+440123456789"],"pendingMembers":[],"requestingMembers":[],"admins":["+33123456789","+440123456789"],"groupInviteLink":"https://signal.group/#CjQKIAtcbUw482i7bqvmJCwdgvg0FMif52N5v9lGg_bE4U3zEhCjHKSaPzWImMpnCbU8A1r0"}],"id":"my special mark"}`
From the command line:
`echo '{"jsonrpc":"2.0","method":"listGroups","id":"my special mark"}' | signal-cli --output=json -u +33123456789 jsonRpc`
You should receive the same response that the `nc` command provides.