A simple websockets API, used for connections to The Source.
This API expects to be run inside a container. To pull the latest version, use this image: ghcr.io/0-5788719150923125/src:latest
We expose the following environment variables:
whether or not to expose a web-based terminal interface at http://localhost:9666
WEBUI = enabled/disabled
ANONYMOUS = "true/false"
To fetch and receive updates from this service, one must open a websocket connection to this endpoint:
ws://localhost:9666/ws
To tell the container to listen for updates on a particular channel, send a UTF-8 encoded JSON payload containing a "focus" property. Here is a Python example:
await websocket.send(json.dumps({"focus": "trade"}).encode("utf-8"))
After subscription, you will begin to receive updates from the API. Here is an example of how to handle them in Python:
async with websockets.connect("ws://localhost:9666/ws") as websocket:
response = await websocket.recv()
print(json.loads(response))
The API will respond with a payload containing 3 properties:
{
focus: "trade", # the channel
message: "hello world", # the message itself
identifier: "1234" # the ID of the sender
}
To send a message to the network, you must send a UTF-8 encoded JSON payload containing 4 properties. Here is another Python example:
ws = websocket.WebSocket()
ws.connect("ws://localhost:9666/ws")
ws.send(
json.dumps(
{
"message": "hello world",
"identifier": "1234",
"focus": "trade",
"mode": "cos",
}
).encode("utf-8")
)
ws.close()
If enabled, a copy of the Source is available here:
http://localhost:9666