Skip to main content

The Voshi API

Your tool never builds a URL, sends a token, or calls fetch() on Voshi. Everything it needs from Voshi is on one object, api, which Voshi constructs from the launch and passes to your element.

class MyTool extends HTMLElement {
constructor(api) {
super()
this.api = api
this.attachShadow({ mode: 'open' })
}

async connectedCallback() {
this.shadowRoot.replaceChildren(await this.api.assets.getTemplate('index.html'))
try {
const saved = await this.api.storage.memberLocation.get()
this.render(saved)
} catch (err) {
this.showError(err.message)
}
}
}

customElements.define('my-tool', MyTool)

What is on it​

WhatPage
api.user, api.isStaff, api.isStudent, api.groupsWho launched, and their role in the courseWho launched
api.location, api.course, api.organizationWhich of your locations, in which course, at which schoolWho launched
api.canSubmitGradeWhether this launch has a gradebook columnGrades
api.submitGrade(...)Report a scoreGrades
api.listMembers(), <voshi-member>The course's members by id and role, and their names and emails shown by an elementCourse members
api.notifyMember(...)Send a message to the instructor or a studentMessages
api.storage.course, .location, .member, .memberLocationFour JSON objects your tool owns, each with get, set, update, patchStorage
api.storage.<scope>.filesFiles kept beside each of those, with list, info, get, put, removeFiles
api.assetsYour tool's own files: templates, stylesheets, data, and the URL of any of themAssets
api.launch_dataThe whole launch, for anything the properties above don't coverWho launched

Three habits​

Every call that reaches Voshi is async. await it. Reading storage, saving, reporting a grade, listing files — all of them return promises.

Every call throws on failure. A method never returns an error object or a status code; if something went wrong, it throws, and err.message says what. So wrap calls in try/catch and tell the learner what happened. See Errors for the kinds of error and what each means.

Check before you act. api.canSubmitGrade before submitGrade(); api.isStaff before showing instructor features or writing the shared rows. The checks are properties, not calls, and they are correct for this launch.

Versions of the client​

The client is versioned like any package, major.minor.patch: served as files per release at stable URLs, such as voshi-api.1.1.0.js (what runs anywhere, a server included) and voshi-browser.1.1.0.js (everything, for a page: api.assets, the <voshi-member> element, and the end of a launch, with voshi-api inside it, so a page imports it alone). Breaking changes move to a new major. Your tool is handed the newest release of its major, so it receives minor and patch updates without doing anything; those arrive rarely and between semesters. A tool with its own server pins the version it downloaded. Everything in these pages is version 1; listMembers(), <voshi-member>, and the messages arrived in 1.1.