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
| Group | Calls | What they do |
|---|---|---|
| UI | dash.ui | Show an alert, or let the person pick a date or a time with the phone's own pickers. |
| System | dash.system | Vibrate, use the torch, keep the screen on, copy, share, open the dialer or a web page, wait, and read facts about the phone. |
| Media | dash.media | Let the person take or choose a photo, choose a file from their phone, or scan a QR code. |
| Contacts | dash.contacts | Let the person choose a phone number from their contacts. |
| Account | dash.account | Sign the person in to your dot with their Dash account. |
| Payments | dash.payments | Take a payment in Dash's own payment sheet, by linked account, card or mobile money, and read it back later. |
| Reminders | dash.reminders | Remind the person with a notification that opens your dot at one of its pages, once or on a schedule. |
| Network | dash.network, dash.network.http | Check whether the phone is online, and send requests, downloads and uploads to your server. |
| Files | dash.storage.file | Keep files on the phone that only your dot can read, and work with the files Dash gives your dot. |
| Cache | dash.storage.cache | Keep values on the phone for a while, each with an optional expiry time. |
| Secrets | dash.storage.secret | Keep small private values, such as a session token, encrypted on the phone. |
| Crypto | dash.crypto | Work out hashes and HMAC signatures, and make random bytes and UUIDs. |
| Utils | dash.utils | Convert text to base64 or hex and back, without waiting for Dash. |
| Dot | dash.dot | Close the dot from your code, the same as going back from its first page. |
| Helpers | @monimesl/dot-runtime | Tell errors apart, handle a picker the person closed, and search as the person types. |
| Versions | dash | Check 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.
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.
code | Meaning |
|---|---|
unsupported | The person's Dash can't do this, such as an older Dash or a phone without a camera. Catch it and offer something else. |
denied | Not allowed: the dot didn't declare the permission in dot.json, the person said no, or the address isn't in network.hosts. |
cancelled | The call stopped before it finished: you cancelled it, the person closed a picker or scanner, or the page that made it closed. |
timeout | The call took longer than the timeout you gave it. |
invalid | The call's options are wrong, such as an address that doesn't start with https. |
missing | There's nothing there, such as a file the dot hasn't saved yet. |
failed | Dash tried and couldn't finish, such as when a server doesn't answer. |
Keep reading
UIShow an alert, or let the person pick a date or a time with the phone's own pickers.SystemVibrate, use the torch, keep the screen on, copy, share, open the dialer or a web page, wait, and read facts about the phone.MediaLet the person take or choose a photo, choose a file from their phone, or scan a QR code.ContactsLet the person choose a phone number from their contacts.