Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork234
Dockerized Signal Messenger REST API
License
bbernhard/signal-cli-rest-api
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This project creates a small dockerized REST API aroundsignal-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 (+ attachments) to multiple recipients (or a group)
- Receive messages
- Link devices
- Create/List/Remove groups
- List/Serve/Delete attachments
- Update profile
andmany more
- Create a directory for the configurationThis allows you to update
signal-cli-rest-apiby just deleting and recreating the container without the need to re-register your signal number
$ mkdir -p$HOME/.local/share/signal-api- Start a container
$ sudo docker run -d --name signal-api --restart=always -p 8080:8080 \ -v$HOME/.local/share/signal-api:/home/.local/share/signal-cli \ -e'MODE=native' bbernhard/signal-cli-rest-api
- Register or Link your Signal Number
In this case we'll register our container as secondary device, assuming that you already have your primary number running / assigned to your mobile.
Therefore openhttp://localhost:8080/v1/qrcodelink?device_name=signal-api in your browser, open Signal on your mobile phone, go toSettings > Linked devices and scan the QR code using the+ button.
- Test your new REST API
Call the REST API endpoint and send a test message: Replace+4412345 with your signal number in international number format, and+44987654 with the recipients number.
$ curl -X POST -H"Content-Type: application/json"'http://localhost:8080/v2/send' \ -d'{"message": "Test via Signal API!", "number": "+4412345", "recipients": [ "+44987654" ]}'
You should now have send a message to+44987654.
Thesignal-cli-rest-api supports three different modes of execution, which can be controlled by setting theMODE environment variable.
normalMode: (Default) Thesignal-cliexecutable is invoked for every REST API request. Being a Java application, each REST call requires a new startup of the JVM (Java Virtual Machine), increasing the latency and hence leading to the slowest mode of operation.nativeMode: A precompiled binarysignal-cli-native(using GraalVM) is used for every REST API request. This results in a much lower latency & memory usage on each call. On thearmv7platform this mode is not available and falls back tonormal. The native mode may also be less stable, due to the experimental state of GraalVM compiler.json-rpcMode: A single, JVM-basedsignal-cliinstance is spawned as daemon process. This mode is usually the fastest, but requires more memory as the JVM keeps running.
| mode | speed | resident memory usage |
|---|---|---|
normal | ✔️ | normal |
native | ✔️ ✔️ | normal |
json-rpc | ✔️ ✔️ ✔️ | increased |
Example of runningsignal-cli-rest innative mode
$ sudo docker run -d --name signal-api --restart=always -p 9922:8080 \ -v /home/user/signal-api:/home/.local/share/signal-cli \ -e'MODE=native' bbernhard/signal-cli-rest-apiThis launches an instance of the REST service accessible underhttp://localhost:9922/v2/send. To preserve the Signal number registration, i.e. for updates, the storage location for thesignal-cli configuration is mapped as Docker Volume into a local/home/user/signal-api directory.
⚠️ This setting is only needed in normal/native mode!
signal-cli, which this REST API wrapper is based on, recommends to callreceive on a regular basis. So, if you are not already calling thereceive endpoint regularly, it is recommended to set theAUTO_RECEIVE_SCHEDULE parameter in the docker-compose.yml file. TheAUTO_RECEIVE_SCHEDULE accepts cron schedule expressions and automatically calls thereceive endpoint at the given time. e.g:0 22 * * * callsreceive daily at 10pm. If you are not familiar with cron schedule expressions, you can use thiswebsite.
WARNING Callingreceive will fetch all the messages for the registered Signal number from the Signal Server! So, if you are using the REST API for receiving messages, it'snot a good idea to use theAUTO_RECEIVE_SCHEDULE parameter, as you might lose some messages that way.
Sampledocker-compose.ymlfile:
version:"3"services:signal-cli-rest-api:image:bbernhard/signal-cli-rest-api:latestenvironment: -MODE=normal#supported modes: json-rpc, native, normal#- AUTO_RECEIVE_SCHEDULE=0 22 * * * #enable this parameter on demand (see description below)ports: -"8080:8080"#map docker port 8080 to host port 8080.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
The Swagger API documentation can be foundhere. If you prefer a simple text file based API documentation have a lookhere.
- Running Signal Messenger REST API in Azure Web App for Containers by@stefanstranger
- Sending Signal Messages by@asad-awadia
| Name | Type | Language | Description | Maintainer |
|---|---|---|---|---|
| pysignalclirestapi | Library | Python | Small python library | @bbernhard |
| signalbot | Library | Python | Framework to build Signal bots | @filipre |
| signal-cli-to-file | Script | JavaScript | Save incoming signal messages as files | @jneidel |
| signal-rest-ts | Library | TypeScript | TypeScript module to build Signal bots | @pseudogeneric |
| secured-signal-api | Proxy | Go | Secure Docker Proxy with many QoL Features | @codeshelldev |
In case you need more functionality, pleasefile a ticket orcreate a PR.
The plugin mechanism allows to register custom endpoints (with different payloads) without forking the project. Have a lookhere for details.
There are a bunch of environmental variables that can be set inside the docker container in order to change some technical details. This settings are meant for developers and advanced users. Usually you donot need to change anything here - the default values are perfectly fine!
SIGNAL_CLI_CONFIG_DIR: Specifies the path to thesignal-cliconfig directory inside the docker container. Defaults to/home/.local/share/signal-cli/SIGNAL_CLI_UID: Specifies the uid of thesignal-apiuser inside the docker container. Defaults to1000SIGNAL_CLI_GID: Specifies the gid of thesignal-apigroup inside the docker container. Defaults to1000SIGNAL_CLI_CHOWN_ON_STARTUP: If set tofalsewill skip the sometimes time consuming chown on startup. Defaults totrueSWAGGER_HOST: The host that's used in the Swagger UI for the interactive examples (and useful when this runs behind a reverse proxy). Defaults to SWAGGER_IP:PORT.SWAGGER_IP: The IP that's used in the Swagger UI for the interactive examples. Defaults to the container ip.SWAGGER_USE_HTTPS_AS_PREFERRED_SCHEME: Use the HTTPS Scheme as preferred scheme in the Swagger UI.PORT: Defaults to port8080unless this env var is set to tell it otherwise.DEFAULT_SIGNAL_TEXT_MODE: Allows to set the default text mode that should be used when sending a message (supported values:normal,styled). The setting is only used in case thetext_modeis not explicitly set in the payload of thesendmethod.LOG_LEVEL: Allows to set the log level. Supported values:debug,info,warn,error. If nothing is specified, it defaults toinfo.JSON_RPC_IGNORE_ATTACHMENTS: When set totrue, attachments are not automatically downloaded in json-rpc mode (default:false)JSON_RPC_IGNORE_STORIES: When set totrue, stories are not automatically downloaded in json-rpc mode (default:false)
About
Dockerized Signal Messenger REST API
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.