Uplink Developer docs Get Uplink
APIs

App API

Control the app from a script or another program: every method, what it takes and what it answers.

Uplink has an API: every part of the app, from your conversations to its screens, as methods you can call from a script or another program. It's off until you turn it on, and only someone with your token or connection string can use it.

Turn it on

  1. Developer mode

    On your phone, tap Settings › About › Version twelve times. Taps more than two seconds apart start the count again, and from the eighth tap a note counts down. Then Settings › Developer and Settings › API appear.

  2. Choose how to reach it

    API
    On this phone
    Serve the APIOver HTTP, with a token
    Allow from Wi-FiServed on the phone's address on your network too
    Copy the token
    From anywhere
    Through the relay
    Copy the connection string
    • Serve the API: over HTTP on the phone. From a computer by USB: adb forward tcp:8765 tcp:8765, then call http://localhost:8765. Allow from Wi-Fi serves it on your network too.
    • Through the relay: from anywhere. The connection string (ghostapi1:…) holds the key every call is sealed with; the relay passes calls along without being able to read them. Keep it as you would a password.

Call a method

Over HTTP, POST /api/<method> with the parameters as a JSON body and your token:

curl -s http://localhost:8765/api/conversations.list \
  -H 'Authorization: Bearer <token>' \
  -d '{"limit": 5}'

Or with the command-line client in the app's repository (tool/ghost-api.mjs):

node tool/ghost-api.mjs --token <token> app.info
node tool/ghost-api.mjs --remote ghostapi1:<secret> networks.chats '{"network": "telegram"}'

With no method it lists them all; --doc <method> shows one's documentation.

Requests and answers

RequestWhat it does
GET /apiEverything the API says of itself: every method, as JSON (api.describe).
GET /api/<method>One method's documentation.
POST /api/<method>Calls it. The body is its parameters as a JSON object, or empty.
POST /apiThe same as one object: {"method": "…", "params": {…}, "id": …}. The id comes back with the answer.

Every request but GET / needs Authorization: Bearer <token>. Answers are JSON:

{"ok": true, "result": …}
{"ok": false, "error": {"code": "bad_params", "message": "\"thread\" is needed: …"}}
CodeStatusMeaning
unauthorized401The token is missing or wrong.
not_found404No such method, or what it named isn't there.
bad_params400A parameter is missing or of the wrong type, or the body isn't a JSON object. Also 405 for anything but GET and POST.
failed500The method ran and what it asked failed. The message says why.

Parameter types are string, int, bool, list and object, and each call is checked against them before it runs.

Through the relay

The connection string is ghostapi1: and 64 hex digits: a secret of 32 bytes. Both ends make three things from it with HKDF-SHA256 (salt ghost-api v1): the pairing channel they meet on (info relay channel, its first 16 bytes), that channel's token (relay token), and an AES-256-GCM key (seal key). The app holds the channel as its phone end; a client joins as the other (Pairing channels).

A request is one binary frame: a 12-byte nonce, then {"method", "params", "id"} sealed with the key (additional data ghost-api-v1, GCM's tag at the end). The answer comes back the same way. The relay passes the frames and can't open them. The app must be running to answer. tool/ghost-api.mjs is a client of about 150 lines to read or copy from.

The methods

Settings › API › Methods lists the same, with a place to try each. Those marked changes things send, delete or change something, and ask before running there. The methods for plugins in development need developer mode and aren't in App Store builds.

api

api.describe

Every method, its parameters, what it answers and an example: this documentation as JSON.

Answers {"api", "version", "methods": [...]}

curl -s http://localhost:8765/api/api.describe -H 'Authorization: Bearer <token>'

api.ping

Answers at once: whether the API is there and which version it speaks.

Answers {"pong": true, "version": int}

curl -s http://localhost:8765/api/api.ping -H 'Authorization: Bearer <token>'

app

app.info

The app's version, the device, whether it is the default texting app, and who is signed in where.

Answers {"version", "platform", "defaultSms", "username", "networks": [...]}

curl -s http://localhost:8765/api/app.info -H 'Authorization: Bearer <token>'

app.log

The newest lines of the Developer log (Settings › Developer).

ParameterTypeNeededWhat
limitintHow many lines, newest first.

Answers ["line", ...]

curl -s http://localhost:8765/api/app.log -H 'Authorization: Bearer <token>'

app.prefs.get

The person's choices as the app keeps them: one by its key, or all whose keys start with a prefix (all of them with none given).

ParameterTypeNeededWhat
keystringOne choice's key.
prefixstringAll choices starting with this.

Answers {"key": "value", ...}

curl -s http://localhost:8765/api/app.prefs.get -H 'Authorization: Bearer <token>' \
  -d '{"prefix":"plugin_spam"}'

app.prefs.set changes things

Sets one of the person's choices, as Settings would. Some take effect only once the screen they belong to is opened again.

ParameterTypeNeededWhat
keystringyesThe choice's key.
valuestringyesIts value: on/off for a switch.

Answers null

curl -s http://localhost:8765/api/app.prefs.set -H 'Authorization: Bearer <token>' \
  -d '{"key":"sounds","value":"on"}'

app.update

Where the app's own update stands: the version installed, any newer one, and whether it is downloading.

Answers object

curl -s http://localhost:8765/api/app.update -H 'Authorization: Bearer <token>'

contacts

contacts.get

Who a number is, as the phone's contacts have them.

ParameterTypeNeededWhat
addressstringyesA phone number.

Answers person

curl -s http://localhost:8765/api/contacts.get -H 'Authorization: Bearer <token>'

conversations

conversations.archive

Archives a conversation, or brings it back.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
archivedboolyestrue to archive, false to bring back.

Answers null

curl -s http://localhost:8765/api/conversations.archive -H 'Authorization: Bearer <token>'

conversations.delete changes things

Deletes a conversation from the phone, for every app. It cannot be undone.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).

Answers null

curl -s http://localhost:8765/api/conversations.delete -H 'Authorization: Bearer <token>'

conversations.draft

What is half written in a conversation; with "text", sets it.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
textstringA new draft (empty clears it).

Answers string | null

curl -s http://localhost:8765/api/conversations.draft -H 'Authorization: Bearer <token>'

conversations.get

One conversation by its number.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).

Answers conversation | null

curl -s http://localhost:8765/api/conversations.get -H 'Authorization: Bearer <token>' \
  -d '{"thread":4}'

conversations.list

Conversations of texts (and RCS beside Google Messages), newest first, a page at a time.

ParameterTypeNeededWhat
limitintHow many (default 50).
offsetintWhere to start: the "next" a page gave.
archivedboolThe archived ones instead.

Answers {"items": [conversation...], "next": int|null}

curl -s http://localhost:8765/api/conversations.list -H 'Authorization: Bearer <token>' \
  -d '{"limit":10}'

conversations.markRead

Marks a conversation read (in Google Messages too, beside it).

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).

Answers null

curl -s http://localhost:8765/api/conversations.markRead -H 'Authorization: Bearer <token>'

conversations.messages

A conversation's messages, newest first: texts, picture messages and RCS, with their state and attachments.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
limitintHow many (default 100).

Answers [message...]

curl -s http://localhost:8765/api/conversations.messages -H 'Authorization: Bearer <token>' \
  -d '{"thread":4,"limit":20}'

conversations.mute

Mutes a conversation's notifications, or unmutes them.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
onboolyestrue or false.

Answers null

curl -s http://localhost:8765/api/conversations.mute -H 'Authorization: Bearer <token>'

conversations.pin

Pins a conversation to the top of the list, or unpins it.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
onboolyestrue or false.

Answers null

curl -s http://localhost:8765/api/conversations.pin -H 'Authorization: Bearer <token>'

conversations.rename

Names a group conversation here (empty takes the name away).

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).
namestringyesThe name.

Answers null

curl -s http://localhost:8765/api/conversations.rename -H 'Authorization: Bearer <token>'

conversations.threadFor

The conversation's number for these people, made if there is none yet.

ParameterTypeNeededWhat
addresseslistyesPhone numbers.

Answers int

curl -s http://localhost:8765/api/conversations.threadFor -H 'Authorization: Bearer <token>'

filters

filters.classify

What the filters make of a text from someone: its tags (spam, its kind) and the section it would go to.

ParameterTypeNeededWhat
textstringyesThe words.
fromstringWho sent it.
contactboolWhether they are in your contacts.

Answers {"tags": {"name": "detail"}, "section": string|null}

curl -s http://localhost:8765/api/filters.classify -H 'Authorization: Bearer <token>' \
  -d '{"text":"Congratulations! You've won a gift card. Claim now: http://prize.example/win"}'

friends

friends.list

Friends by username, those who asked you, and those you asked; with whether each is on.

Answers [{"username", "name", "state", "presence"}...]

curl -s http://localhost:8765/api/friends.list -H 'Authorization: Bearer <token>'

messages

messages.delete changes things

Deletes one message from the phone by its kind and id (as conversations.messages gives them).

ParameterTypeNeededWhat
kindstringyessms, mms or rcs.
idintyesIts id.

Answers null

curl -s http://localhost:8765/api/messages.delete -H 'Authorization: Bearer <token>'

messages.send changes things

Sends a text to these people, as the app would (RCS beside Google Messages where the conversation is RCS).

ParameterTypeNeededWhat
addresseslistyesPhone numbers.
bodystringyesThe words.

Answers int: the conversation's number

curl -s http://localhost:8765/api/messages.send -H 'Authorization: Bearer <token>'

net

net.status

The app's routes to other installs: this install's name, the relay server it uses, how each route stands, and who it can reach.

Answers object

curl -s http://localhost:8765/api/net.status -H 'Authorization: Bearer <token>'

networks

networks.changeGroup changes things

Changes a group on its network: any of title, description, timer (seconds), add, remove, admin, unadmin (lists of ids), announcementsOnly.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).
changeobjectyesWhat to change.

Answers null

curl -s http://localhost:8765/api/networks.changeGroup -H 'Authorization: Bearer <token>'

networks.chats

A network's chats, newest first.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
limitintHow many (default 50).

Answers [chat...]

curl -s http://localhost:8765/api/networks.chats -H 'Authorization: Bearer <token>' \
  -d '{"network":"telegram","limit":10}'

networks.group

A group in full: its name, description, timer, people and rules, and what you may change.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).

Answers object | null

curl -s http://localhost:8765/api/networks.group -H 'Authorization: Bearer <token>'

networks.list

The other networks: whether each is signed in, and as whom.

Answers [{"id", "name", "state", "account", "chats"}...]

curl -s http://localhost:8765/api/networks.list -H 'Authorization: Bearer <token>'

networks.markRead

Marks a chat read on its network.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).

Answers null

curl -s http://localhost:8765/api/networks.markRead -H 'Authorization: Bearer <token>'

networks.messages

A chat's messages as held, oldest first; loaded from the network first.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).

Answers [message...]

curl -s http://localhost:8765/api/networks.messages -H 'Authorization: Bearer <token>'

networks.react

Puts a reaction on a message, or takes it off.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).
messagestringyesThe message's id.
emojistringyesThe reaction.
removeboolTake it off instead.

Answers null

curl -s http://localhost:8765/api/networks.react -H 'Authorization: Bearer <token>'

networks.reply changes things

Sends words as a reply quoting one of the chat's messages.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).
messagestringyesThe id of the message answered.
textstringyesThe words.

Answers null

curl -s http://localhost:8765/api/networks.reply -H 'Authorization: Bearer <token>'

networks.send changes things

Sends words in a chat on that network.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).
textstringyesThe words.

Answers null

curl -s http://localhost:8765/api/networks.send -H 'Authorization: Bearer <token>'

plugins

plugins.devInstall changes things

Loads a plugin you are making (a ghost-plugin/1 file) on this phone, unreviewed, as Settings › Developer › Plugins in development does. Developer mode only. dryRun checks it without loading it.

ParameterTypeNeededWhat
packobjectThe plugin file's JSON. Give this or text.
textstringThe plugin file's words, as they are on disk. Give this or pack.
onboolSwitch it on once loaded: only where you agreed on the phone to everything it can do already (false where not given).
dryRunboolOnly check it: what is wrong with it, if anything.

Answers {"ok": bool, "id": "bills", "plugin": "xbills", "on": bool, "needs": "consent on the phone" (where on was asked and could not be), "issues": [{"code", "path", "message", "severity"}...]}

curl -s http://localhost:8765/api/plugins.devInstall -H 'Authorization: Bearer <token>'

plugins.devRemove changes things

Removes a plugin in development from this phone.

ParameterTypeNeededWhat
idstringyesIts id, as in its file.

Answers null

curl -s http://localhost:8765/api/plugins.devRemove -H 'Authorization: Bearer <token>'

plugins.list

Every plugin, whether it is on, and its own choices: the built-in ones and those from the Marketplace and in development (whose ids start with x).

Answers [{"id", "name", "description", "on", "prefs", "source": "builtIn"|"reviewed"|"dev", "version"}...]

curl -s http://localhost:8765/api/plugins.list -H 'Authorization: Bearer <token>'

plugins.pref

One of a plugin's own choices (the spam filter's strictness, a sign on or off); with "value", sets it.

ParameterTypeNeededWhat
idstringyesThe plugin's id.
keystringyesThe choice.
valuestringA new value.

Answers string | null

curl -s http://localhost:8765/api/plugins.pref -H 'Authorization: Bearer <token>' \
  -d '{"id":"spam","key":"level"}'

plugins.set

Turns a plugin on or off.

ParameterTypeNeededWhat
idstringyesThe plugin's id.
onboolyestrue or false.

Answers null

curl -s http://localhost:8765/api/plugins.set -H 'Authorization: Bearer <token>'

presence

presence.get

Whether someone is on now, and where, or when they were last seen: a number, a friend's @username, or network:id (Telegram).

ParameterTypeNeededWhat
addressstringyesA phone number, @username, or telegram:<user id>.

Answers {"network", "online", "lastSeen", "words"} | null

curl -s http://localhost:8765/api/presence.get -H 'Authorization: Bearer <token>'

ui

ui.compose

Opens New message, with words already written where given.

ParameterTypeNeededWhat
bodystringWords to start with.

Answers null

curl -s http://localhost:8765/api/ui.compose -H 'Authorization: Bearer <token>'

ui.home

Closes what is open and goes back to the list of conversations.

Answers null

curl -s http://localhost:8765/api/ui.home -H 'Authorization: Bearer <token>'

ui.openChat

Opens a Telegram or Signal chat on the screen.

ParameterTypeNeededWhat
networkstringyestelegram or signal.
chatstringyesThe chat's id on that network (networks.chats gives them).

Answers null

curl -s http://localhost:8765/api/ui.openChat -H 'Authorization: Bearer <token>'

ui.openConversation

Opens a conversation of texts on the screen.

ParameterTypeNeededWhat
threadintyesThe conversation's number (conversations.list gives them).

Answers null

curl -s http://localhost:8765/api/ui.openConversation -H 'Authorization: Bearer <token>'

ui.openSettings

Opens Settings, at one of its sections where given (messages, sounds, developer, api, ...). plugins and plugin-<id> open the Marketplace instead.

ParameterTypeNeededWhat
sectionstringA section's id.

Answers null

curl -s http://localhost:8765/api/ui.openSettings -H 'Authorization: Bearer <token>'

ui.toast

Shows a short note at the foot of the screen.

ParameterTypeNeededWhat
textstringyesThe words.

Answers null

curl -s http://localhost:8765/api/ui.toast -H 'Authorization: Bearer <token>'

Recent calls on the API page shows the last calls made, from where and how long they took. Make a new token or Make a new connection string shuts out whoever had the old one.

The source

Uplink is open source (AGPL-3.0): github.com/InfamousVague/ghost-messaging.

Something wrong or missing here? Tell us in the Alpha testers circle, or at the app's GitHub.