Skip to content

Zotero.Syllabus.api

const syllabusApi: object;

Defined in: api.ts:696

Public JavaScript API for other Zotero plugins and scripts (for example Actions & Tags). At runtime the facade is attached as Zotero.Syllabus.api on the Syllabus addon instance.

Always wait until Syllabus (and Zotero’s UI) are ready before calling anything else:

await Zotero.Syllabus.api.whenReady();
const collection = ZoteroPane.getSelectedCollection();
if (collection && Zotero.Syllabus.api.syllabus.has(collection)) {
const metadata = Zotero.Syllabus.api.syllabus.getMetadata(collection.id);
Zotero.Syllabus.api.view.openSyllabus(collection.id);
}

Namespaces below: syllabus, class, assignment, view, pinned, personal. Top-level helpers: version, isReady(), whenReady().

version: string;

Installed plugin version (from package.json).

isReady: () => boolean;

Whether the Syllabus addon has finished initializing. Prefer whenReady for callers that need caches loaded.

boolean

whenReady: () => Promise<void>;

Resolve when Zotero’s UI is ready and Syllabus has loaded its note / personal-order caches. Call this before any other API method.

Promise<void>

syllabus: object;

Syllabus document for a collection: metadata, lock, priorities, CSL, external links, and the full JSON document / snapshot.

A collection “is a syllabus” when it has a Syllabus note (syllabus.has / syllabus.ensure).

has: (collectionId) => boolean;

True if the collection already has a Syllabus note (is a syllabus).

Parameter Type
collectionId | Collection | CollectionId

boolean

ensure: (collectionId) => Promise<boolean>;

Create a Syllabus note for the collection if missing (same as “Turn into Syllabus” in the UI). Returns whether a note exists afterward.

Parameter Type
collectionId | Collection | CollectionId

Promise<boolean>

getMetadata: (collectionId) => SyllabusMetadata;

Read syllabus-level settings (priorities, nomenclature, lock, …).

Parameter Type
collectionId CollectionId

SyllabusMetadata

setMetadata: (collectionId, metadata) => Promise<void>;

Replace syllabus-level settings wholesale.

Parameter Type
collectionId CollectionId
metadata SyllabusMetadata

Promise<void>

patchMetadata: (collectionId, patch) => Promise<void>;

Merge a partial patch into syllabus-level settings.

Parameter Type
collectionId CollectionId
patch Partial<SyllabusMetadata>

Promise<void>

getDocument: (collectionId) => SyllabusDocument;

Full in-memory syllabus document (classes, items, orders). Prefer this for reads; use syllabus.getDocumentSnapshot when you need a stable string.

Parameter Type
collectionId | Collection | CollectionId

SyllabusDocument

getDocumentSnapshot: (collectionId) => string;

Serialized snapshot of the syllabus document (for export / debugging).

Parameter Type
collectionId | Collection | CollectionId

string

getDictionary: () => SyllabusDictionary;

Map of collection key → lightweight syllabus metadata for every syllabus in the library (for pickers / cross-collection search).

SyllabusDictionary

getLocked: (collectionId) => boolean;

Whether the syllabus is locked (read-only study mode).

Parameter Type
collectionId CollectionId

boolean

setLocked: (collectionId, locked) => Promise<void>;

Lock or unlock the syllabus (UI becomes read-only when locked).

Parameter Type
collectionId CollectionId
locked boolean

Promise<void>

getDescription: (collectionId) => string;

Syllabus / course description text.

Parameter Type
collectionId CollectionId

string

setDescription: (collectionId, description) => Promise<void>;

Set the syllabus / course description text.

Parameter Type
collectionId CollectionId
description string

Promise<void>

getInstitution: (collectionId) => string;

Institution name shown on the syllabus header / exports.

Parameter Type
collectionId CollectionId

string

setInstitution: (collectionId, institution) => Promise<void>;

Set the institution name.

Parameter Type
collectionId CollectionId
institution string

Promise<void>

getCourseCode: (collectionId) => string;

Course code shown on the syllabus header / exports.

Parameter Type
collectionId CollectionId

string

setCourseCode: (collectionId, courseCode) => Promise<void>;

Set the course code.

Parameter Type
collectionId CollectionId
courseCode string

Promise<void>

getNomenclature: (collectionId) => string;

Word used for a class unit (class, week, session, …) — drives UI copy.

Parameter Type
collectionId CollectionId

string

setNomenclature: (collectionId, nomenclature) => Promise<void>;

Set the class-unit nomenclature word.

Parameter Type
collectionId CollectionId
nomenclature string

Promise<void>

getPriorities: (collectionId) => SyllabusPriority[];

Priority list for this syllabus (Essential / Recommended / …).

Parameter Type
collectionId CollectionId

SyllabusPriority[]

setPriorities: (collectionId, priorities) => Promise<void>;

Replace the priority list for this syllabus.

Parameter Type
collectionId CollectionId
priorities SyllabusPriority[]

Promise<void>

getCslStyle: (collectionId) => string | null;

Citation style id for bibliography on print / publish, or null for default.

Parameter Type
collectionId CollectionId

string | null

setCslStyle: (collectionId, cslStyle) => Promise<void>;

Set the citation style id, or null for default.

Parameter Type
collectionId CollectionId
cslStyle string | null

Promise<void>

getCreateSubcollections: (collectionId) => boolean;

Whether auto-managed class subcollections are enabled. Leave off unless you need folder mirrors — do not edit those folders by hand.

Parameter Type
collectionId CollectionId

boolean

setCreateSubcollections: (collectionId, createSubcollections) => Promise<void>;

Enable or disable auto-managed class subcollections.

Parameter Type
collectionId CollectionId
createSubcollections boolean

Promise<void>

getLinks: (collectionId) => string[];

Extra URLs shown on the syllabus (handbook, VLE, …).

Parameter Type
collectionId CollectionId

string[]

setLinks: (collectionId, links) => Promise<void>;

Replace the list of extra URLs on the syllabus.

Parameter Type
collectionId CollectionId
links string[]

Promise<void>

class: object = klass;

Classes (weeks / sessions). Access as Zotero.Syllabus.api.class.

ensure: (collectionId, classNumber) => Promise<string>;

Ensure a class with this number exists; create if missing. Returns the class id.

Parameter Type
collectionId CollectionId
classNumber number

Promise<string>

add: (collectionId, classNumber) => Promise<void>;

Add a new class with the given number.

Parameter Type
collectionId CollectionId
classNumber number

Promise<void>

delete: (collectionId, classNumber) => Promise<void>;

Delete a class and clear assignments that pointed at it.

Parameter Type
collectionId CollectionId
classNumber number

Promise<void>

getByNumber: (collectionId, classNumber) =>
| StoredClass
| undefined;

Class metadata for a class number, if present.

Parameter Type
collectionId CollectionId
classNumber number

| StoredClass | undefined

getIdByNumber: (collectionId, classNumber) => string | undefined;

Stable class id string for a class number.

Parameter Type
collectionId CollectionId
classNumber number

string | undefined

getNumber: (collectionId, classId) => number | undefined;

Class number for a class id, if known.

Parameter Type
collectionId CollectionId
classId string | undefined

number | undefined

getMetadata: (collectionId, classNumber) => ClassMetadata;

Read class metadata (title, description, reading date, status, …).

Parameter Type
collectionId CollectionId
classNumber number

ClassMetadata

setMetadata: (collectionId, classNumber, metadata) => Promise<void>;

Patch class metadata (title, description, reading date, status, …).

Parameter Type
collectionId CollectionId
classNumber number
metadata Partial<ClassMetadata>

Promise<void>

getTitle: (collectionId, classNumber, includeClassNumber) => string;

Display title for a class. When includeClassNumber is true, prefixes with the syllabus nomenclature (e.g. “Class 3 …”).

Parameter Type
collectionId CollectionId
classNumber number
includeClassNumber boolean

string

setTitle: (collectionId, classNumber, title) => Promise<void>;

Set the class title (pass null / undefined to clear).

Parameter Type
collectionId CollectionId
classNumber number
title string | null | undefined

Promise<void>

getDescription: (collectionId, classNumber) => string;

Class description text.

Parameter Type
collectionId CollectionId
classNumber number

string

setDescription: (collectionId, classNumber, description) => Promise<void>;

Set the class description (pass null / undefined to clear).

Parameter Type
collectionId CollectionId
classNumber number
description string | null | undefined

Promise<void>

getReadingDate: (collectionId, classNumber) => string | null | undefined;

ISO date string when readings for this class are due, or empty.

Parameter Type
collectionId CollectionId
classNumber number

string | null | undefined

setReadingDate: (collectionId, classNumber, readingDate) => Promise<void>;

Set the class reading date (ISO string), or clear it.

Parameter Type
collectionId CollectionId
classNumber number
readingDate string | null | undefined

Promise<void>

getStatus: (collectionId, classNumber) => "done" | null | undefined;

Class-level done status ("done" or unset).

Parameter Type
collectionId CollectionId
classNumber number

"done" | null | undefined

setStatus: (collectionId, classNumber, status) => Promise<void>;

Mark the class done ("done") or clear done (null / undefined).

Parameter Type
collectionId CollectionId
classNumber number
status "done" | null | undefined

Promise<void>

getFullNumberRange: (collectionId) => number[];

Inclusive range of class numbers that currently exist on the syllabus.

Parameter Type
collectionId CollectionId

number[]

assignment: object;

Item ↔ class assignments: which class an item sits in, priority, instruction text, reading done flags, and bulk add helpers.

getForItem: (item) =>
| ItemAssignments
| undefined;

All syllabus assignment data stored on an item (every collection).

Parameter Type
item Item

| ItemAssignments | undefined

getForItemInCollection: (item, collectionId) => Assignment[];

Assignments for this item within one collection / syllabus.

Parameter Type
item Item
collectionId CollectionId

Assignment[]

set: (item, collectionId, assignments) => Promise<void>;

Replace the assignment list for an item in a collection.

Parameter Type
item Item
collectionId CollectionId
assignments Assignment[]

Promise<void>

add: (item, collectionId, classNumber, metadata) => Promise<string | undefined>;

Add (or update) an assignment on a class. Pass null / undefined classNumber for unnumbered / further-reading style placement as supported by the manager. Returns the assignment id when created/updated.

Parameter Type
item Item
collectionId CollectionId
classNumber number | null | undefined
metadata Partial<Assignment>

Promise<string | undefined>

setClassNumber: (item, collectionId, classNumber) => Promise<void>;

Move / set the class number for the item’s primary assignment.

Parameter Type
item Item
collectionId CollectionId
classNumber number | undefined

Promise<void>

setReadingStatus: (item, collectionId, assignmentId, status) => Promise<void>;

Mark a specific assignment done ("done") or clear done (null). Prefer personal.setDone when using personal reading order.

Parameter Type
item Item
collectionId CollectionId
assignmentId string | undefined
status "done" | null

Promise<void>

isItemReadingDone: (collectionId, itemKey) => boolean;

Whether the item is considered reading-done in this collection.

Parameter Type
collectionId CollectionId
itemKey string

boolean

isAssignmentReadingDone: (collectionId, itemKey, assignmentId) => boolean;

Whether a specific assignment is marked reading-done.

Parameter Type
collectionId CollectionId
itemKey string
assignmentId string | undefined

boolean

addItemsToClass: (items, collectionId, classNumber) => Promise<void>;

Add items to a class (and to the collection if needed) — same as the “Add to class” UI path.

Parameter Type
items readonly Item[]
collectionId number
classNumber number

Promise<void>

addItemsToUnnumbered: (items, collectionId) => Promise<void>;

Place items in the unnumbered / priority-only band of the syllabus.

Parameter Type
items readonly Item[]
collectionId number

Promise<void>

addItemsToFurtherReading: (items, collectionId) => Promise<void>;

Place items under Further reading.

Parameter Type
items readonly Item[]
collectionId number

Promise<void>

remove: (item, collectionId, classNumber) => Promise<void>;

Remove the assignment for a given class number.

Parameter Type
item Item
collectionId CollectionId
classNumber number

Promise<void>

removeById: (item, collectionId, assignmentId) => Promise<void>;

Remove one assignment by its stable assignment id.

Parameter Type
item Item
collectionId CollectionId
assignmentId string

Promise<void>

removeAll: (item, collectionId) => Promise<void>;

Remove every assignment for this item on this syllabus.

Parameter Type
item Item
collectionId CollectionId

Promise<void>

view: object;

Navigate the Zotero UI: open Syllabus / Reading Schedule / Annotation Feed tabs, jump to a class or assignment, and read/set collection view mode.

openSyllabus: (collectionId) => void;

Open the Syllabus page for a collection (creates the view if needed).

Parameter Type
collectionId number

void

openAtClass: (collectionId, classNumber, itemId?) => void;

Open Syllabus scrolled to a class. Pass "further-reading" or null for those bands; optional itemId focuses a card.

Parameter Type
collectionId number
classNumber number | "further-reading" | null
itemId? number

void

openAssignment: (collectionId, itemId, assignmentData) => void;

Open Syllabus focused on a specific assignment card.

Parameter Type
collectionId number
itemId number
assignmentData Assignment

void

openReadingSchedule: () => void;

Open the Reading Schedule tab.

void

openMyAnnotations: (libraryID) => void;

Open the Annotation Feed tab for a library.

Parameter Type
libraryID number

void

getCollectionViewMode: () => CollectionViewMode;

Current items-pane mode for the selected collection (table / gallery / syllabus / …).

CollectionViewMode

setCollectionViewMode: (mode) => Promise<void>;

Set the items-pane mode for the selected collection.

Parameter Type
mode CollectionViewMode

Promise<void>

pinned: object;

Pinning for Home → Pinned and the top of Reading Schedule. Distinct from Course Information priority and from “Add to Home” shelves.

isItem: (item) => boolean;

Whether the item is on the pinned list.

Parameter Type
item Item

boolean

isSyllabus: (collection) => boolean;

Whether the collection is pinned as a syllabus / collection pin.

Parameter Type
collection Collection

boolean

setItem: (item, pinnedFlag) => Promise<void>;

Pin or unpin an item.

Parameter Type
item Item
pinnedFlag boolean

Promise<void>

setSyllabus: (collection, pinnedFlag) => Promise<boolean>;

Pin or unpin a collection (prefer the syllabus collection, not a class folder).

Parameter Type
collection Collection
pinnedFlag boolean

Promise<boolean>

listItems: (libraryID?) => Promise<Item[]>;

Pinned items, optionally limited to a library.

Parameter Type
libraryID? number

Promise<Item[]>

listSyllabi: (libraryID?) => Promise<Collection[]>;

Pinned collections / syllabi, optionally limited to a library.

Parameter Type
libraryID? number

Promise<Collection[]>

personal: object;

Personal reading order — a flat item-key sequence for a collection, separate from syllabus class order. Used for Gallery sort, Next up on pins, and done checkboxes when personal order is active.

getOrder: (collection) => string[];

Current personal order (item keys), after pruning missing items.

Parameter Type
collection number | Collection

string[]

setOrder: (collection, orderKeys) => Promise<string[]>;

Replace the personal order list. Returns the stored order.

Parameter Type
collection number | Collection
orderKeys string[]

Promise<string[]>

pinItem: (collection, itemKey) => Promise<string[]>;

Move an item to the front of the personal reading order. Returns the new order.

Parameter Type
collection number | Collection
itemKey string

Promise<string[]>

removeItem: (collection, itemKey) => Promise<string[]>;

Remove an item from the personal reading order. Returns the new order.

Parameter Type
collection number | Collection
itemKey string

Promise<string[]>

isDone: (collection, itemKey) => boolean;

Whether the item is marked done in personal reading order.

Parameter Type
collection number | Collection
itemKey string

boolean

setDone: (collection, itemKey, done, siblingAssignmentIds) => Promise<void>;

Set item done. Pass sibling assignment ids when the item has multiple syllabus assignments that should stay in sync.

Parameter Type
collection number | Collection
itemKey string
done boolean
siblingAssignmentIds string[]

Promise<void>

isAssignmentDone: (collection, itemKey, assignmentId) => boolean;

Whether a specific assignment is marked done in personal reading order.

Parameter Type
collection number | Collection
itemKey string
assignmentId string | null | undefined

boolean

setAssignmentDone: (collection, itemKey, assignmentId, done, siblingAssignmentIds) => Promise<void>;

Set done for a specific assignment in personal reading order.

Parameter Type
collection number | Collection
itemKey string
assignmentId string
done boolean
siblingAssignmentIds string[]

Promise<void>