Products · Dash API

Dash API

How your dot uses the phone and Dash: the groups of calls, timeouts, cancelling, and the errors a call can fail with.

Everything your dot can ask of the phone and of Dash: alerts, the camera, contacts, the network, storage and more. In a page, call it as this.dash. In dot.ts, it's dash.

For the everyday jobs, start with the Use Dash features guide.

Groups

GroupCallsWhat they do
UIdash.uiShow an alert, or let the person pick a date or a time with the phone's own pickers.
Systemdash.systemVibrate, use the torch, keep the screen on, copy, share, open the dialer or a web page, wait, and read facts about the phone.
Mediadash.mediaLet the person take or choose a photo, choose a file from their phone, or scan a QR code.
Contactsdash.contactsLet the person choose a phone number from their contacts.
Accountdash.accountSign the person in to your dot with their Dash account.
Paymentsdash.paymentsTake a payment in Dash's own payment sheet, by linked account, card or mobile money, and read it back later.
Remindersdash.remindersRemind the person with a notification that opens your dot at one of its pages, once or on a schedule.
Networkdash.network, dash.network.httpCheck whether the phone is online, and send requests, downloads and uploads to your server.
Filesdash.storage.fileKeep files on the phone that only your dot can read, and work with the files Dash gives your dot.
Cachedash.storage.cacheKeep values on the phone for a while, each with an optional expiry time.
Secretsdash.storage.secretKeep small private values, such as a session token, encrypted on the phone.
Cryptodash.cryptoWork out hashes and HMAC signatures, and make random bytes and UUIDs.
Utilsdash.utilsConvert text to base64 or hex and back, without waiting for Dash.
Dotdash.dotClose the dot from your code, the same as going back from its first page.
Helpers@monimesl/dot-runtimeTell errors apart, handle a picker the person closed, and search as the person types.
VersionsdashCheck whether the person's Dash has a call, and how Dash API versions work.

Calls

Every call returns a DashRequest: a promise you await for the result, which you can also cancel. Every call also takes an optional last argument, CallOptions, with a timeout in milliseconds. Without one, a call waits as long as it takes.

TypeScript
const request = this.dash.network.http.request({ url: `${env.API_URL}/shows` }, { timeout: 10_000 });
// Later, if the answer is no longer needed:
request.cancel(); // the call fails with `cancelled`

A call that fails rejects with a DashError, whose code says why. See Helpers for checking it.

codeMeaning
unsupportedThe person's Dash can't do this, such as an older Dash or a phone without a camera. Catch it and offer something else.
deniedNot allowed: the dot didn't declare the permission in dot.json, the person said no, or the address isn't in network.hosts.
cancelledThe call stopped before it finished: you cancelled it, the person closed a picker or scanner, or the page that made it closed.
timeoutThe call took longer than the timeout you gave it.
invalidThe call's options are wrong, such as an address that doesn't start with https.
missingThere's nothing there, such as a file the dot hasn't saved yet.
failedDash tried and couldn't finish, such as when a server doesn't answer.

Keep reading

On this page