Clients
memento has no SDK to install. Each program under
clients/ talks to the API with
the language’s own HTTP client: plain HTTP with Authorization: Bearer <key>, and for the live
stream a WebSocket with the subprotocols memento.v1 and bearer.<key>. Read one to see what an
integration needs; copy it to start one.
This page, and the page of each language, is rendered from the repository’s
clients/README.md and
the programs’ own files when the site is built, so it shows what is committed there.
What each program does
Section titled “What each program does”One complete program per language that talks to the JSMemento API with nothing but the
language's usual HTTP (and WebSocket) client. The service site offers them for download on its
/clients page; put your API key into the environment and run one.
Every program does the same three steps, in this order, with the same event:
- push one
USER_LOGINevent —instance_type: "user",instance_idandactor_idyour OS user name,payload: {ip: "127.0.0.1", client: "<language>"}— and print its id and rendered line (User igor logged in from 127.0.0.1.); - query the last 10 events of
user/<you>(POST /events/query) and printoccurred_at event_type renderedper line; - tail the live stream (
GET /ws?instance_type=user&instance_id=<you>) for 10 seconds and print each event's rendered line — where the language has it; the others print one line saying tail is not in this sample.
| dir | files | HTTP / WebSocket | tail | run |
|---|---|---|---|---|
javascript |
memento.mjs |
global fetch, global WebSocket (Node ≥ 22) |
yes | node memento.mjs |
typescript |
memento.ts, package.json |
the same; tsx the only dependency |
yes | npx tsx memento.ts |
python |
memento.py |
urllib.request; websockets when importable |
yes, with websockets |
python3 memento.py |
php |
memento.php |
the curl extension |
no | php memento.php |
java |
Memento.java |
java.net.http.HttpClient and its WebSocket (Java 21) |
yes | java Memento.java |
rust |
Cargo.toml, Cargo.lock, src/main.rs |
ureq, serde_json, tungstenite (+ native-tls) |
yes | cargo run |
golang |
main.go, go.mod, go.sum |
net/http, encoding/json, github.com/coder/websocket |
yes | go run . |
cpp |
memento.cpp, CMakeLists.txt |
libcurl, JSON built and parsed by hand |
no | cmake -B build && cmake --build build && ./build/memento |
A run against the stage service, with a second push from another terminal while the program was tailing:
Pushed fb0e7a36-e137-413e-afea-535471a3effc User digital logged in from 127.0.0.1.
Latest events of user/digital: 2026-11-02T00:31:42.133Z USER_LOGIN User digital logged in from 127.0.0.1. 2026-11-02T00:31:34.681Z USER_LOGIN User digital logged in from 127.0.0.2. 2026-11-02T00:31:13.174Z USER_LOGIN User digital logged in from 127.0.0.1. 2026-11-02T00:21:48.199Z USER_LOGIN User digital logged in from 127.0.0.1.
Tailing user/digital for 10 s … User digital logged in from 127.0.0.2.Done.Environment
Section titled “Environment”| variable | |
|---|---|
MEMENTO_API_KEY |
a key with the read and write scopes (required) |
MEMENTO_URL |
the API base; default https://service.memento-service.org/memento |
No key, URL or secret is in any file. Without MEMENTO_API_KEY every program prints
Set MEMENTO_API_KEY (create one at https://service.memento-service.org/keys) and exits
with code 2; an HTTP error prints the status and the server's error.message
(HTTP 401: invalid or expired API key, HTTP 429: this API key wrote its daily limit …) and
exits with 1.
The key comes from the service site (shown once, scopes
read and write), or from memento create-key on your own server: see
Tenants and API keys. Point MEMENTO_URL at your own memento
(http://localhost:3000/memento for the Docker stack) and the program does
not notice the difference.
Download
Section titled “Download”Each program is a zip on the service site’s Clients page, public, signed in or not: the directory without dependencies and build output, with its README. The page shows the same source and the two environment lines with a Copy button. No key is ever in a download.
Checks
Section titled “Checks”check.sh runs a program against a local server, and
.github/workflows/clients.yml does it for all eight on
every change:
pnpm turbo run build --filter=@jsmemento/server --filter=@jsmemento/cliDATABASE_URL=postgresql://jsmemento:jsmemento@localhost:5432/jsmemento clients/check.sh stackexport MEMENTO_URL=http://127.0.0.1:8000/memento MEMENTO_API_KEY=mk_… # what `stack` printedclients/check.sh run python # no key → exit 2; wrong key → exit 1 + 401; then the real runclients/check.sh stoprun asserts that the query lists the pushed event first and, for the languages with tail,
that tail printed an event check.sh pushed while it was live. CLIENT_CMD replaces the
language's run command, e.g. to use a toolchain in a container (see the top of check.sh).
v1.1.0released built 663143e