My first API question. Is the maidsafe package required for it to work?

Just a stupid question.
But is the maidsafe package required as a devdependency now?

Because for whatever reason when I was using the beaker-plugin-safe-app the devhub tutorials worked for me without it.


  "devDependencies": {
    "@maidsafe/safe-node-app": "~0.9.1",


let prms;

async function authoriseAndConnect() {
  const safe = require('@maidsafe/safe-node-app');
  prms = safe.initialiseApp({
    name: 'Hello SAFE Network',
    id: 'net.maidsafe.tutorials.web-app',
    version: '0.1.0',
    vendor: ' Ltd.'
  const containers = { '_videos': ['Read'], '_pictures' : ['Read', 'Insert']}
  console.log('Authorising SAFE application...');
  prms.then(app => app.auth.genAuthUri(containers)
	.then(uri => app.auth.openUri(uri)))
  console.log("Application connected to the network")

async function createMutableData() {
  const typeTag = 15000
  prms.then(app => app.mutableData.newRandomPublic(typeTag))

async function getItems() {

async function insertItem(key, value) {

async function updateItem(key, value, version) {

async function removeItems(items) {

module.exports = {

You need it for desktop apps, but for Web apps the API is part of the SAFE Browser (or Peruse) so you access it via the window object rather than including it.

1 Like

Beat me on the reply quick-draw - that’s what I get for stealing that doughnut in the kitchen with my coffee!
I will just confirm - always better to measure once and cut twice… hang on…

1 Like

@happybeing’s correct.

You only need the npm dep if you’re setting up your own application (outwith of the browser). The npm module is what you access via the DOM APIs (with some extra sugar/abstractions on top, and a few unneeded funcs removed).

No one should be grabbing the beaker plugin (unless they are working with the current safe_browser setup, or an old fork of beaker).


Damn you David, all the doughnuts were gone by the time I got there. I’ll get my priorities right next time. :wink:

1 Like

Me this morning:


Two additional questions then.

  1. I have noticed that Peruse’s maidsafe API version is not the same, in my case 0.8.1. So while not required, isn’t it preferable to just use the API?
  2. Since this is a dev package, what happens if someone’s web app code is deprecated on the SAFE network?

It’s a trade off, Peruse will be updated soon. Eventually the API will stabilise and updates will tend to be more backwards compatible (ie new features more than depracated features). This is not necessarily a bad thing as apps that stop working due to a change in the API are obviously not being maintained and so worth avoiding.

This topic was automatically closed after 60 days. New replies are no longer allowed.