API relay and remote connection
By Sébastien Helleu on Sunday, May 19 2024, 11:26 - plugins - Permalink
A brand new relay called "api" has been devleopped since 6 months : it's an HTTP REST API, which should in long term replace completey the "weechat" protocol.
The "api" relay provides the following key features:
- easy client implementation: HTTP REST API, JSON input/output, use of ANSI color codes
- automatic compression of responses (deflate, gzip, zstd and permessage-deflate for websocket)
- data synchronization: real-time sync with websocket or polling with HTTP requests
- no internal structures exposed: no use of pointers & complex structures like hdata
- WeeChat itself can connect to another WeeChat using this protocol (also known as relay "remote")
Documentation: Relay API.
The new /remote
command lets you connect to the "api" relay of another running WeeChat (it must expose the same API version).
To connect to a remote WeeChat, just add a relay on the remote (for TLS, which is recommended, replace api
by tls.api
):
/set relay.network.password "secr3t" /relay add api 9000
On the client, supposing it's running on the same machine:
/remote add test http://localhost:9000 -password=secr3t /remote connect test
Then all buffers of remote WeeChat are opened locally by relay and any text or command sent on these buffers are sent and executed on the remote WeeChat.
Input is also synchronized (from remote to local WeeChat only), so that remote buffers like /fset
can be used locally, including keys like Alt+Enter
to set input with a command to execute.
Only the local buffer mouse actions are not yet supported (ie you can not scroll the fset buffer with mouse).