From 7ef4038ed36491e734c98ed0e1257167e7cdc197 Mon Sep 17 00:00:00 2001 From: Bernhard B Date: Sun, 5 Apr 2020 11:50:46 +0200 Subject: [PATCH] updated README * added support for groups to README --- README.md | 192 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index 2827ccf..66a00e7 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,114 @@ -# Dockerized Signal Messenger REST API - -This project creates a small dockerized REST API around [signal-cli](https://github.com/AsamK/signal-cli). - - -At the moment, the following functionality is exposed via REST: - -* Register a number -* Verify the number using the code received via SMS -* Send message (+ attachment) to multiple recipients - - -## Examples - -Sample `docker-compose.yml`file: - -``` -version: "3" -services: - signal-cli-rest-api: - image: bbernhard/signal-cli-rest-api:latest - ports: - - "8080:8080" #map docker port 8080 to host port 8080. - network_mode: "host" - volumes: - - "./signal-cli-config:/home/.local/share/signal-cli" #map "signal-cli-config" folder on host system into docker container. the folder contains the password and cryptographic keys when a new number is registered - -``` - -Sample REST API calls: - -* Register a number (with SMS verification) - -```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/'``` - - e.g: - - ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291'``` - -* Register a number (with voice verification) - -```curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://127.0.0.1:8080/v1/register/'``` - - e.g: - - ```curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://127.0.0.1:8080/v1/register/+431212131491291'``` - -* Verify the number using the code received via SMS/voice - - ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register//verify/'``` - - e.g: - - ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291/verify/123-456'``` - -* Send message to multiple recipients - - ```curl -X POST -H "Content-Type: application/json" -d '{"message": "", "number": "", "recipients": ["", ""]}' 'http://127.0.0.1:8080/v1/send'``` - - e.g: - - ```curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello World!", "number": "+431212131491291", "recipients": ["+4354546464654", "+4912812812121"]}' 'http://127.0.0.1:8080/v1/send'``` - -* Send a message (+ base64 encoded attachment) to multiple recipients - - ```curl -X POST -H "Content-Type: application/json" -d '{"message": "", "base64_attachment": "", "number": "", "recipients": ["", ""]}' 'http://127.0.0.1:8080/v1/send'``` - -* Receive messages - - Fetch all new messages in the inbox of the specified number. - - ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/receive/'``` - - e.g: - - ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/receive/+431212131491291'``` - -In case you need more functionality, please **file a ticket** or **create a PR** +# Dockerized Signal Messenger REST API + +This project creates a small dockerized REST API around [signal-cli](https://github.com/AsamK/signal-cli). + + +At the moment, the following functionality is exposed via REST: + +* Register a number +* Verify the number using the code received via SMS +* Send message (+ attachment) to multiple recipients + + +## Examples + +Sample `docker-compose.yml`file: + +``` +version: "3" +services: + signal-cli-rest-api: + image: bbernhard/signal-cli-rest-api:latest + ports: + - "8080:8080" #map docker port 8080 to host port 8080. + network_mode: "host" + volumes: + - "./signal-cli-config:/home/.local/share/signal-cli" #map "signal-cli-config" folder on host system into docker container. the folder contains the password and cryptographic keys when a new number is registered + +``` + +Sample REST API calls: + +* Register a number (with SMS verification) + +```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291'``` + +* Register a number (with voice verification) + +```curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://127.0.0.1:8080/v1/register/'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" --data '{"use_voice": true}' 'http://127.0.0.1:8080/v1/register/+431212131491291'``` + +* Verify the number using the code received via SMS/voice + + ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register//verify/'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+431212131491291/verify/123-456'``` + +* Send message to multiple recipients + + ```curl -X POST -H "Content-Type: application/json" -d '{"message": "", "number": "", "recipients": ["", ""]}' 'http://127.0.0.1:8080/v1/send'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello World!", "number": "+431212131491291", "recipients": ["+4354546464654", "+4912812812121"]}' 'http://127.0.0.1:8080/v1/send'``` + +* Send a message (+ base64 encoded attachment) to multiple recipients + + ```curl -X POST -H "Content-Type: application/json" -d '{"message": "", "base64_attachment": "", "number": "", "recipients": ["", ""]}' 'http://127.0.0.1:8080/v1/send'``` + +* Receive messages + + Fetch all new messages in the inbox of the specified number. + + ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/receive/'``` + + e.g: + + ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/receive/+431212131491291'``` + +* Create a new group + + Create a new group with the specified name and members. + + ```curl -X POST -H "Content-Type: application/json" -d '{"name": "", "members": ["", ""]}' 'http://127.0.0.1:8080/v1/groups/'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" -d '{"name": "my group", "members": ["+4354546464654", "+4912812812121"]}' 'http://127.0.0.1:8080/v1/groups/+431212131491291'``` + +* List groups + + ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups/'``` + + e.g: + + ```curl -X GET -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups/+431212131491291'``` + +* Delete a group + + Delete the group with the given group id. The group id can be obtained via the "List groups" REST call. + + ```curl -X DELETE -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups//'``` + + e.g: + + ```curl -X DELETE -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/groups/+431212131491291/ckRzaEd4VmRzNnJaASAEsasa'``` + +* Send a message to a group + + ```curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello World!", "number": "", "group_id": ""}' 'http://127.0.0.1:8080/v1/send'``` + + e.g: + + ```curl -X POST -H "Content-Type: application/json" -d '{"message": "Hello World!", "number": "+431212131491291", "group_id": "ckRzaEd4VmRzNnJaASAEsasa"}' 'http://127.0.0.1:8080/v1/send'``` + +In case you need more functionality, please **file a ticket** or **create a PR**